diff options
Diffstat (limited to 'scene/3d')
-rw-r--r-- | scene/3d/camera.cpp | 28 | ||||
-rw-r--r-- | scene/3d/camera.h | 1 | ||||
-rw-r--r-- | scene/3d/collision_shape.cpp | 4 |
3 files changed, 22 insertions, 11 deletions
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp index 29002c6701..a00f2173c0 100644 --- a/scene/3d/camera.cpp +++ b/scene/3d/camera.cpp @@ -106,9 +106,15 @@ void Camera::_notification(int p_what) { case NOTIFICATION_ENTER_WORLD: { - bool first_camera = get_viewport()->_camera_add(this); - if (!get_tree()->is_node_being_edited(this) && (current || first_camera)) - make_current(); + // Needs to track the Viewport because it's needed on NOTIFICATION_EXIT_WORLD + // and Spatial will handle it first, including clearing its reference to the Viewport, + // therefore making it impossible to subclasses to access it + viewport = get_viewport(); + ERR_FAIL_COND(!viewport); + + bool first_camera = viewport->_camera_add(this); + if (current || first_camera) + viewport->_camera_set(this); } break; case NOTIFICATION_TRANSFORM_CHANGED: { @@ -130,17 +136,20 @@ void Camera::_notification(int p_what) { } } - get_viewport()->_camera_remove(this); + if (viewport) { + viewport->_camera_remove(this); + viewport = NULL; + } } break; case NOTIFICATION_BECAME_CURRENT: { - if (get_world().is_valid()) { - get_world()->_register_camera(this); + if (viewport) { + viewport->find_world()->_register_camera(this); } } break; case NOTIFICATION_LOST_CURRENT: { - if (get_world().is_valid()) { - get_world()->_remove_camera(this); + if (viewport) { + viewport->find_world()->_remove_camera(this); } } break; } @@ -255,8 +264,6 @@ bool Camera::is_current() const { return get_viewport()->get_camera() == this; } else return current; - - return false; } bool Camera::_can_gizmo_scale() const { @@ -694,6 +701,7 @@ Camera::Camera() { near = 0; far = 0; current = false; + viewport = NULL; force_change = false; mode = PROJECTION_PERSPECTIVE; set_perspective(70.0, 0.05, 100.0); diff --git a/scene/3d/camera.h b/scene/3d/camera.h index cbcefbb0ae..1cd729199d 100644 --- a/scene/3d/camera.h +++ b/scene/3d/camera.h @@ -64,6 +64,7 @@ public: private: bool force_change; bool current; + Viewport *viewport; Projection mode; diff --git a/scene/3d/collision_shape.cpp b/scene/3d/collision_shape.cpp index 3190e1e0b2..219ea56681 100644 --- a/scene/3d/collision_shape.cpp +++ b/scene/3d/collision_shape.cpp @@ -228,7 +228,9 @@ void CollisionShape::_update_debug_shape() { void CollisionShape::_shape_changed() { // If this is a heightfield shape our center may have changed - _update_in_shape_owner(true); + if (parent) { + _update_in_shape_owner(true); + } if (is_inside_tree() && get_tree()->is_debugging_collisions_hint() && !debug_shape_dirty) { debug_shape_dirty = true; |