aboutsummaryrefslogtreecommitdiff
path: root/scene/3d/scenario_fx.cpp
diff options
context:
space:
mode:
authorJuan Linietsky2014-09-22 00:50:48 -0300
committerJuan Linietsky2014-09-22 00:50:48 -0300
commit048fdc8aeabbd80ba9cc8914ec7f7baa00ad0c3d (patch)
treeddd39a348b41cfe3927075a8c6b11aa692511518 /scene/3d/scenario_fx.cpp
parentf195bf673fa8f282d2508e20ca6f08260c4e1fe7 (diff)
downloadgodot-048fdc8aeabbd80ba9cc8914ec7f7baa00ad0c3d.tar.gz
godot-048fdc8aeabbd80ba9cc8914ec7f7baa00ad0c3d.tar.zst
godot-048fdc8aeabbd80ba9cc8914ec7f7baa00ad0c3d.zip
Diffstat (limited to 'scene/3d/scenario_fx.cpp')
-rw-r--r--scene/3d/scenario_fx.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/scene/3d/scenario_fx.cpp b/scene/3d/scenario_fx.cpp
index 05546ee4d..d8e5fc8bd 100644
--- a/scene/3d/scenario_fx.cpp
+++ b/scene/3d/scenario_fx.cpp
@@ -35,20 +35,35 @@ void WorldEnvironment::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_WORLD) {
- get_world()->set_environment(environment);
+ if (environment.is_valid()) {
+ if (get_world()->get_environment().is_valid()) {
+ WARN_PRINT("World already has an environment (Another WorldEnvironment?), overriding.");
+ }
+ get_world()->set_environment(environment);
+ }
+
} else if (p_what==NOTIFICATION_EXIT_WORLD) {
- get_world()->set_environment(Ref<Environment>());
+ if (environment.is_valid() && get_world()->get_environment()==environment)
+ get_world()->set_environment(Ref<Environment>());
}
}
void WorldEnvironment::set_environment(const Ref<Environment>& p_environment) {
+ if (is_inside_world() && environment.is_valid() && get_world()->get_environment()==environment) {
+ get_world()->set_environment(Ref<Environment>());
+ //clean up
+ }
+
+
environment=p_environment;
- if (is_inside_world()) {
+ if (is_inside_world() && environment.is_valid()) {
+ if (get_world()->get_environment().is_valid()) {
+ WARN_PRINT("World already has an environment (Another WorldEnvironment?), overriding.");
+ }
get_world()->set_environment(environment);
}
-
}
Ref<Environment> WorldEnvironment::get_environment() const {