mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-11-21 16:37:20 +01:00
Portals - defer setting active in VisualServer
until enter tree
`set_portal_active()` was being called loading packed scenes prior to entering the tree, visual server portals had not been fully created at this point hence the call was being ignored with an error flagged. This PR defers the call until after entering the tree.
This commit is contained in:
parent
6db0214bfa
commit
91090ff296
@ -165,10 +165,13 @@ void Portal::_notification(int p_what) {
|
||||
case NOTIFICATION_ENTER_WORLD: {
|
||||
ERR_FAIL_COND(get_world_3d().is_null());
|
||||
|
||||
// defer full creation of the visual server portal to when the editor portal is in the scene tree
|
||||
RenderingServer::get_singleton()->portal_set_scenario(_portal_rid, get_world_3d()->get_scenario());
|
||||
// Defer full creation of the visual server portal to when the editor portal is in the scene tree.
|
||||
RenderingServer::get_singleton()->portal_set_scenario(_portal_rid, get_world()->get_scenario());
|
||||
|
||||
// we can't calculate world points until we have entered the tree
|
||||
// Update any components in visual server that require the scenario to be set.
|
||||
RenderingServer::get_singleton()->portal_set_active(_portal_rid, _settings_active);
|
||||
|
||||
// We can't calculate world points until we have entered the tree.
|
||||
portal_update();
|
||||
update_gizmos();
|
||||
|
||||
@ -195,7 +198,14 @@ void Portal::_notification(int p_what) {
|
||||
|
||||
void Portal::set_portal_active(bool p_active) {
|
||||
_settings_active = p_active;
|
||||
RenderingServer::get_singleton()->portal_set_active(_portal_rid, p_active);
|
||||
|
||||
// This can be called prior to entering the tree when loading packed scene,
|
||||
// where the scenario has not yet been set (and thus the visual server portal
|
||||
// is not yet fully created).
|
||||
// We therefore defer setting this until entering the tree.
|
||||
if (is_inside_tree()) {
|
||||
RenderingServer::get_singleton()->portal_set_active(_portal_rid, p_active);
|
||||
}
|
||||
}
|
||||
|
||||
bool Portal::get_portal_active() const {
|
||||
|
Loading…
Reference in New Issue
Block a user