summaryrefslogtreecommitdiff
path: root/scene/3d/reflection_probe.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d/reflection_probe.cpp')
-rw-r--r--scene/3d/reflection_probe.cpp136
1 files changed, 60 insertions, 76 deletions
diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp
index 2a5a84741f..c7948395d3 100644
--- a/scene/3d/reflection_probe.cpp
+++ b/scene/3d/reflection_probe.cpp
@@ -31,59 +31,52 @@
#include "reflection_probe.h"
void ReflectionProbe::set_intensity(float p_intensity) {
-
intensity = p_intensity;
- VS::get_singleton()->reflection_probe_set_intensity(probe, p_intensity);
+ RS::get_singleton()->reflection_probe_set_intensity(probe, p_intensity);
}
float ReflectionProbe::get_intensity() const {
-
return intensity;
}
-void ReflectionProbe::set_interior_ambient(Color p_ambient) {
-
- interior_ambient = p_ambient;
- VS::get_singleton()->reflection_probe_set_interior_ambient(probe, p_ambient);
+void ReflectionProbe::set_ambient_mode(AmbientMode p_mode) {
+ ambient_mode = p_mode;
+ RS::get_singleton()->reflection_probe_set_ambient_mode(probe, RS::ReflectionProbeAmbientMode(p_mode));
+ _change_notify();
}
-void ReflectionProbe::set_interior_ambient_energy(float p_energy) {
- interior_ambient_energy = p_energy;
- VS::get_singleton()->reflection_probe_set_interior_ambient_energy(probe, p_energy);
+ReflectionProbe::AmbientMode ReflectionProbe::get_ambient_mode() const {
+ return ambient_mode;
}
-float ReflectionProbe::get_interior_ambient_energy() const {
- return interior_ambient_energy;
+void ReflectionProbe::set_ambient_color(Color p_ambient) {
+ ambient_color = p_ambient;
+ RS::get_singleton()->reflection_probe_set_ambient_color(probe, p_ambient);
}
-Color ReflectionProbe::get_interior_ambient() const {
-
- return interior_ambient;
+void ReflectionProbe::set_ambient_color_energy(float p_energy) {
+ ambient_color_energy = p_energy;
+ RS::get_singleton()->reflection_probe_set_ambient_energy(probe, p_energy);
}
-void ReflectionProbe::set_interior_ambient_probe_contribution(float p_contribution) {
-
- interior_ambient_probe_contribution = p_contribution;
- VS::get_singleton()->reflection_probe_set_interior_ambient_probe_contribution(probe, p_contribution);
+float ReflectionProbe::get_ambient_color_energy() const {
+ return ambient_color_energy;
}
-float ReflectionProbe::get_interior_ambient_probe_contribution() const {
-
- return interior_ambient_probe_contribution;
+Color ReflectionProbe::get_ambient_color() const {
+ return ambient_color;
}
void ReflectionProbe::set_max_distance(float p_distance) {
-
max_distance = p_distance;
- VS::get_singleton()->reflection_probe_set_max_distance(probe, p_distance);
+ RS::get_singleton()->reflection_probe_set_max_distance(probe, p_distance);
}
-float ReflectionProbe::get_max_distance() const {
+float ReflectionProbe::get_max_distance() const {
return max_distance;
}
void ReflectionProbe::set_extents(const Vector3 &p_extents) {
-
extents = p_extents;
for (int i = 0; i < 3; i++) {
@@ -97,82 +90,74 @@ void ReflectionProbe::set_extents(const Vector3 &p_extents) {
}
}
- VS::get_singleton()->reflection_probe_set_extents(probe, extents);
- VS::get_singleton()->reflection_probe_set_origin_offset(probe, origin_offset);
+ RS::get_singleton()->reflection_probe_set_extents(probe, extents);
+ RS::get_singleton()->reflection_probe_set_origin_offset(probe, origin_offset);
_change_notify("extents");
update_gizmo();
}
-Vector3 ReflectionProbe::get_extents() const {
+Vector3 ReflectionProbe::get_extents() const {
return extents;
}
void ReflectionProbe::set_origin_offset(const Vector3 &p_extents) {
-
origin_offset = p_extents;
for (int i = 0; i < 3; i++) {
-
if (extents[i] - 0.01 < ABS(origin_offset[i])) {
origin_offset[i] = SGN(origin_offset[i]) * (extents[i] - 0.01);
}
}
- VS::get_singleton()->reflection_probe_set_extents(probe, extents);
- VS::get_singleton()->reflection_probe_set_origin_offset(probe, origin_offset);
+ RS::get_singleton()->reflection_probe_set_extents(probe, extents);
+ RS::get_singleton()->reflection_probe_set_origin_offset(probe, origin_offset);
_change_notify("origin_offset");
update_gizmo();
}
-Vector3 ReflectionProbe::get_origin_offset() const {
+Vector3 ReflectionProbe::get_origin_offset() const {
return origin_offset;
}
void ReflectionProbe::set_enable_box_projection(bool p_enable) {
-
box_projection = p_enable;
- VS::get_singleton()->reflection_probe_set_enable_box_projection(probe, p_enable);
+ RS::get_singleton()->reflection_probe_set_enable_box_projection(probe, p_enable);
}
-bool ReflectionProbe::is_box_projection_enabled() const {
+bool ReflectionProbe::is_box_projection_enabled() const {
return box_projection;
}
void ReflectionProbe::set_as_interior(bool p_enable) {
-
interior = p_enable;
- VS::get_singleton()->reflection_probe_set_as_interior(probe, interior);
- _change_notify();
+ RS::get_singleton()->reflection_probe_set_as_interior(probe, interior);
}
bool ReflectionProbe::is_set_as_interior() const {
-
return interior;
}
void ReflectionProbe::set_enable_shadows(bool p_enable) {
-
enable_shadows = p_enable;
- VS::get_singleton()->reflection_probe_set_enable_shadows(probe, p_enable);
+ RS::get_singleton()->reflection_probe_set_enable_shadows(probe, p_enable);
}
-bool ReflectionProbe::are_shadows_enabled() const {
+bool ReflectionProbe::are_shadows_enabled() const {
return enable_shadows;
}
void ReflectionProbe::set_cull_mask(uint32_t p_layers) {
-
cull_mask = p_layers;
- VS::get_singleton()->reflection_probe_set_cull_mask(probe, p_layers);
+ RS::get_singleton()->reflection_probe_set_cull_mask(probe, p_layers);
}
-uint32_t ReflectionProbe::get_cull_mask() const {
+uint32_t ReflectionProbe::get_cull_mask() const {
return cull_mask;
}
void ReflectionProbe::set_update_mode(UpdateMode p_mode) {
update_mode = p_mode;
- VS::get_singleton()->reflection_probe_set_update_mode(probe, VS::ReflectionProbeUpdateMode(p_mode));
+ RS::get_singleton()->reflection_probe_set_update_mode(probe, RS::ReflectionProbeUpdateMode(p_mode));
}
ReflectionProbe::UpdateMode ReflectionProbe::get_update_mode() const {
@@ -180,39 +165,36 @@ ReflectionProbe::UpdateMode ReflectionProbe::get_update_mode() const {
}
AABB ReflectionProbe::get_aabb() const {
-
AABB aabb;
aabb.position = -origin_offset;
aabb.size = origin_offset + extents;
return aabb;
}
-PoolVector<Face3> ReflectionProbe::get_faces(uint32_t p_usage_flags) const {
- return PoolVector<Face3>();
+Vector<Face3> ReflectionProbe::get_faces(uint32_t p_usage_flags) const {
+ return Vector<Face3>();
}
void ReflectionProbe::_validate_property(PropertyInfo &property) const {
-
- if (property.name == "interior/ambient_color" || property.name == "interior/ambient_energy" || property.name == "interior/ambient_contrib") {
- if (!interior) {
+ if (property.name == "interior/ambient_color" || property.name == "interior/ambient_color_energy") {
+ if (ambient_mode != AMBIENT_COLOR) {
property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL;
}
}
}
void ReflectionProbe::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_intensity", "intensity"), &ReflectionProbe::set_intensity);
ClassDB::bind_method(D_METHOD("get_intensity"), &ReflectionProbe::get_intensity);
- ClassDB::bind_method(D_METHOD("set_interior_ambient", "ambient"), &ReflectionProbe::set_interior_ambient);
- ClassDB::bind_method(D_METHOD("get_interior_ambient"), &ReflectionProbe::get_interior_ambient);
+ ClassDB::bind_method(D_METHOD("set_ambient_mode", "ambient"), &ReflectionProbe::set_ambient_mode);
+ ClassDB::bind_method(D_METHOD("get_ambient_mode"), &ReflectionProbe::get_ambient_mode);
- ClassDB::bind_method(D_METHOD("set_interior_ambient_energy", "ambient_energy"), &ReflectionProbe::set_interior_ambient_energy);
- ClassDB::bind_method(D_METHOD("get_interior_ambient_energy"), &ReflectionProbe::get_interior_ambient_energy);
+ ClassDB::bind_method(D_METHOD("set_ambient_color", "ambient"), &ReflectionProbe::set_ambient_color);
+ ClassDB::bind_method(D_METHOD("get_ambient_color"), &ReflectionProbe::get_ambient_color);
- ClassDB::bind_method(D_METHOD("set_interior_ambient_probe_contribution", "ambient_probe_contribution"), &ReflectionProbe::set_interior_ambient_probe_contribution);
- ClassDB::bind_method(D_METHOD("get_interior_ambient_probe_contribution"), &ReflectionProbe::get_interior_ambient_probe_contribution);
+ ClassDB::bind_method(D_METHOD("set_ambient_color_energy", "ambient_energy"), &ReflectionProbe::set_ambient_color_energy);
+ ClassDB::bind_method(D_METHOD("get_ambient_color_energy"), &ReflectionProbe::get_ambient_color_energy);
ClassDB::bind_method(D_METHOD("set_max_distance", "max_distance"), &ReflectionProbe::set_max_distance);
ClassDB::bind_method(D_METHOD("get_max_distance"), &ReflectionProbe::get_max_distance);
@@ -239,30 +221,33 @@ void ReflectionProbe::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_update_mode"), &ReflectionProbe::get_update_mode);
ADD_PROPERTY(PropertyInfo(Variant::INT, "update_mode", PROPERTY_HINT_ENUM, "Once,Always"), "set_update_mode", "get_update_mode");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "intensity", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_intensity", "get_intensity");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_distance", PROPERTY_HINT_EXP_RANGE, "0,16384,0.1,or_greater"), "set_max_distance", "get_max_distance");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "intensity", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_intensity", "get_intensity");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "max_distance", PROPERTY_HINT_EXP_RANGE, "0,16384,0.1,or_greater"), "set_max_distance", "get_max_distance");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents"), "set_extents", "get_extents");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "origin_offset"), "set_origin_offset", "get_origin_offset");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "box_projection"), "set_enable_box_projection", "is_box_projection_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "interior"), "set_as_interior", "is_set_as_interior");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enable_shadows"), "set_enable_shadows", "are_shadows_enabled");
ADD_PROPERTY(PropertyInfo(Variant::INT, "cull_mask", PROPERTY_HINT_LAYERS_3D_RENDER), "set_cull_mask", "get_cull_mask");
- ADD_GROUP("Interior", "interior_");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "interior_enable"), "set_as_interior", "is_set_as_interior");
- ADD_PROPERTY(PropertyInfo(Variant::COLOR, "interior_ambient_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_interior_ambient", "get_interior_ambient");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "interior_ambient_energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_interior_ambient_energy", "get_interior_ambient_energy");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "interior_ambient_contrib", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_interior_ambient_probe_contribution", "get_interior_ambient_probe_contribution");
+ ADD_GROUP("Ambient", "ambient_");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "ambient_mode", PROPERTY_HINT_ENUM, "Disabled,Environment,ConstantColor"), "set_ambient_mode", "get_ambient_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "ambient_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_ambient_color", "get_ambient_color");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ambient_color_energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_ambient_color_energy", "get_ambient_color_energy");
BIND_ENUM_CONSTANT(UPDATE_ONCE);
BIND_ENUM_CONSTANT(UPDATE_ALWAYS);
+
+ BIND_ENUM_CONSTANT(AMBIENT_DISABLED);
+ BIND_ENUM_CONSTANT(AMBIENT_ENVIRONMENT);
+ BIND_ENUM_CONSTANT(AMBIENT_COLOR);
}
ReflectionProbe::ReflectionProbe() {
-
intensity = 1.0;
- interior_ambient = Color(0, 0, 0);
- interior_ambient_probe_contribution = 0;
- interior_ambient_energy = 1.0;
+ ambient_mode = AMBIENT_ENVIRONMENT;
+ ambient_color = Color(0, 0, 0);
+ ambient_color_energy = 1.0;
max_distance = 0;
extents = Vector3(1, 1, 1);
origin_offset = Vector3(0, 0, 0);
@@ -272,12 +257,11 @@ ReflectionProbe::ReflectionProbe() {
cull_mask = (1 << 20) - 1;
update_mode = UPDATE_ONCE;
- probe = VisualServer::get_singleton()->reflection_probe_create();
- VS::get_singleton()->instance_set_base(get_instance(), probe);
+ probe = RenderingServer::get_singleton()->reflection_probe_create();
+ RS::get_singleton()->instance_set_base(get_instance(), probe);
set_disable_scale(true);
}
ReflectionProbe::~ReflectionProbe() {
-
- VS::get_singleton()->free(probe);
+ RS::get_singleton()->free(probe);
}