summaryrefslogtreecommitdiff
path: root/scene/3d/scenario_fx.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d/scenario_fx.cpp')
-rw-r--r--scene/3d/scenario_fx.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/scene/3d/scenario_fx.cpp b/scene/3d/scenario_fx.cpp
index 874c21546d..abc7766ecb 100644
--- a/scene/3d/scenario_fx.cpp
+++ b/scene/3d/scenario_fx.cpp
@@ -28,43 +28,44 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "scenario_fx.h"
+#include "scene/main/viewport.h"
void WorldEnvironment::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_WORLD) {
+ if (p_what == Spatial::NOTIFICATION_ENTER_WORLD || p_what == Spatial::NOTIFICATION_ENTER_TREE) {
if (environment.is_valid()) {
- if (get_world()->get_environment().is_valid()) {
+ if (get_viewport()->find_world()->get_environment().is_valid()) {
WARN_PRINT("World already has an environment (Another WorldEnvironment?), overriding.");
}
- get_world()->set_environment(environment);
- add_to_group("_world_environment_" + itos(get_world()->get_scenario().get_id()));
+ get_viewport()->find_world()->set_environment(environment);
+ add_to_group("_world_environment_" + itos(get_viewport()->find_world()->get_scenario().get_id()));
}
- } else if (p_what == NOTIFICATION_EXIT_WORLD) {
+ } else if (p_what == Spatial::NOTIFICATION_EXIT_WORLD || p_what == Spatial::NOTIFICATION_EXIT_TREE) {
- if (environment.is_valid() && get_world()->get_environment() == environment) {
- get_world()->set_environment(Ref<Environment>());
- remove_from_group("_world_environment_" + itos(get_world()->get_scenario().get_id()));
+ if (environment.is_valid() && get_viewport()->find_world()->get_environment() == environment) {
+ get_viewport()->find_world()->set_environment(Ref<Environment>());
+ remove_from_group("_world_environment_" + itos(get_viewport()->find_world()->get_scenario().get_id()));
}
}
}
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>());
- remove_from_group("_world_environment_" + itos(get_world()->get_scenario().get_id()));
+ if (is_inside_tree() && environment.is_valid() && get_viewport()->find_world()->get_environment() == environment) {
+ get_viewport()->find_world()->set_environment(Ref<Environment>());
+ remove_from_group("_world_environment_" + itos(get_viewport()->find_world()->get_scenario().get_id()));
//clean up
}
environment = p_environment;
- if (is_inside_world() && environment.is_valid()) {
- if (get_world()->get_environment().is_valid()) {
+ if (is_inside_tree() && environment.is_valid()) {
+ if (get_viewport()->find_world()->get_environment().is_valid()) {
WARN_PRINT("World already has an environment (Another WorldEnvironment?), overriding.");
}
- get_world()->set_environment(environment);
- add_to_group("_world_environment_" + itos(get_world()->get_scenario().get_id()));
+ get_viewport()->find_world()->set_environment(environment);
+ add_to_group("_world_environment_" + itos(get_viewport()->find_world()->get_scenario().get_id()));
}
update_configuration_warning();
@@ -77,11 +78,11 @@ Ref<Environment> WorldEnvironment::get_environment() const {
String WorldEnvironment::get_configuration_warning() const {
- if (!is_visible_in_tree() || !is_inside_tree() || !environment.is_valid())
+ if (/*!is_visible_in_tree() ||*/ !is_inside_tree() || !environment.is_valid())
return String();
List<Node *> nodes;
- get_tree()->get_nodes_in_group("_world_environment_" + itos(get_world()->get_scenario().get_id()), &nodes);
+ get_tree()->get_nodes_in_group("_world_environment_" + itos(get_viewport()->find_world()->get_scenario().get_id()), &nodes);
if (nodes.size() > 1) {
return TTR("Only one WorldEnvironment is allowed per scene (or set of instanced scenes).");