diff options
Diffstat (limited to 'scene/3d/node_3d.cpp')
-rw-r--r-- | scene/3d/node_3d.cpp | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp index 913a3ea49f..c823e7e532 100644 --- a/scene/3d/node_3d.cpp +++ b/scene/3d/node_3d.cpp @@ -74,7 +74,6 @@ Node3DGizmo::Node3DGizmo() { } void Node3D::_notify_dirty() { - #ifdef TOOLS_ENABLED if ((data.gizmo.is_valid() || data.notify_transform) && !data.ignore_notification && !xform_change.in_list()) { #else @@ -91,7 +90,6 @@ void Node3D::_update_local_transform() const { data.dirty &= ~DIRTY_LOCAL; } void Node3D::_propagate_transform_changed(Node3D *p_origin) { - if (!is_inside_tree()) { return; } @@ -104,7 +102,6 @@ void Node3D::_propagate_transform_changed(Node3D *p_origin) { data.children_lock++; for (List<Node3D *>::Element *E = data.children.front(); E; E = E->next()) { - if (E->get()->data.toplevel_active) continue; //don't propagate to a toplevel E->get()->_propagate_transform_changed(p_origin); @@ -122,7 +119,6 @@ void Node3D::_propagate_transform_changed(Node3D *p_origin) { } void Node3D::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_ENTER_TREE: { ERR_FAIL_COND(!get_tree()); @@ -137,7 +133,6 @@ void Node3D::_notification(int p_what) { data.C = nullptr; if (data.toplevel && !Engine::get_singleton()->is_editor_hint()) { - if (data.parent) { data.local_transform = data.parent->get_global_transform() * get_transform(); data.dirty = DIRTY_VECTORS; //global is always dirty upon entering a scene @@ -152,7 +147,6 @@ void Node3D::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { - notification(NOTIFICATION_EXIT_WORLD, true); if (xform_change.in_list()) get_tree()->xform_change_list.remove(&xform_change); @@ -163,7 +157,6 @@ void Node3D::_notification(int p_what) { data.toplevel_active = false; } break; case NOTIFICATION_ENTER_WORLD: { - data.inside_world = true; data.viewport = nullptr; Node *parent = get_parent(); @@ -175,16 +168,13 @@ void Node3D::_notification(int p_what) { ERR_FAIL_COND(!data.viewport); if (get_script_instance()) { - get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_enter_world, nullptr, 0); } #ifdef TOOLS_ENABLED if (Engine::get_singleton()->is_editor_hint() && get_tree()->is_node_being_edited(this)) { - //get_scene()->call_group(SceneMainLoop::GROUP_CALL_REALTIME,SceneStringNames::get_singleton()->_spatial_editor_group,SceneStringNames::get_singleton()->_request_gizmo,this); get_tree()->call_group_flags(0, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this); if (!data.gizmo_disabled) { - if (data.gizmo.is_valid()) { data.gizmo->create(); if (is_visible_in_tree()) { @@ -198,7 +188,6 @@ void Node3D::_notification(int p_what) { } break; case NOTIFICATION_EXIT_WORLD: { - #ifdef TOOLS_ENABLED if (data.gizmo.is_valid()) { data.gizmo->free(); @@ -207,7 +196,6 @@ void Node3D::_notification(int p_what) { #endif if (get_script_instance()) { - get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_exit_world, nullptr, 0); } @@ -217,7 +205,6 @@ void Node3D::_notification(int p_what) { } break; case NOTIFICATION_TRANSFORM_CHANGED: { - #ifdef TOOLS_ENABLED if (data.gizmo.is_valid()) { data.gizmo->transform(); @@ -231,7 +218,6 @@ void Node3D::_notification(int p_what) { } void Node3D::set_transform(const Transform &p_transform) { - data.local_transform = p_transform; data.dirty |= DIRTY_VECTORS; _change_notify("translation"); @@ -245,7 +231,6 @@ void Node3D::set_transform(const Transform &p_transform) { } void Node3D::set_global_transform(const Transform &p_transform) { - Transform xform = (data.parent && !data.toplevel_active) ? data.parent->get_global_transform().affine_inverse() * p_transform : @@ -255,30 +240,23 @@ void Node3D::set_global_transform(const Transform &p_transform) { } Transform Node3D::get_transform() const { - if (data.dirty & DIRTY_LOCAL) { - _update_local_transform(); } return data.local_transform; } Transform Node3D::get_global_transform() const { - ERR_FAIL_COND_V(!is_inside_tree(), Transform()); if (data.dirty & DIRTY_GLOBAL) { - if (data.dirty & DIRTY_LOCAL) { - _update_local_transform(); } if (data.parent && !data.toplevel_active) { - data.global_transform = data.parent->get_global_transform() * data.local_transform; } else { - data.global_transform = data.local_transform; } @@ -303,12 +281,10 @@ Transform Node3D::get_local_gizmo_transform() const { #endif Node3D *Node3D::get_parent_spatial() const { - return data.parent; } Transform Node3D::get_relative_transform(const Node *p_parent) const { - if (p_parent == this) return Transform(); @@ -321,7 +297,6 @@ Transform Node3D::get_relative_transform(const Node *p_parent) const { } void Node3D::set_translation(const Vector3 &p_translation) { - data.local_transform.origin = p_translation; _change_notify("transform"); _propagate_transform_changed(this); @@ -331,7 +306,6 @@ void Node3D::set_translation(const Vector3 &p_translation) { } void Node3D::set_rotation(const Vector3 &p_euler_rad) { - if (data.dirty & DIRTY_VECTORS) { data.scale = data.local_transform.basis.get_scale(); data.dirty &= ~DIRTY_VECTORS; @@ -347,12 +321,10 @@ void Node3D::set_rotation(const Vector3 &p_euler_rad) { } void Node3D::set_rotation_degrees(const Vector3 &p_euler_deg) { - set_rotation(p_euler_deg * Math_PI / 180.0); } void Node3D::set_scale(const Vector3 &p_scale) { - if (data.dirty & DIRTY_VECTORS) { data.rotation = data.local_transform.basis.get_rotation(); data.dirty &= ~DIRTY_VECTORS; @@ -368,12 +340,10 @@ void Node3D::set_scale(const Vector3 &p_scale) { } Vector3 Node3D::get_translation() const { - return data.local_transform.origin; } Vector3 Node3D::get_rotation() const { - if (data.dirty & DIRTY_VECTORS) { data.scale = data.local_transform.basis.get_scale(); data.rotation = data.local_transform.basis.get_rotation(); @@ -385,12 +355,10 @@ Vector3 Node3D::get_rotation() const { } Vector3 Node3D::get_rotation_degrees() const { - return get_rotation() * 180.0 / Math_PI; } Vector3 Node3D::get_scale() const { - if (data.dirty & DIRTY_VECTORS) { data.scale = data.local_transform.basis.get_scale(); data.rotation = data.local_transform.basis.get_rotation(); @@ -402,7 +370,6 @@ Vector3 Node3D::get_scale() const { } void Node3D::update_gizmo() { - #ifdef TOOLS_ENABLED if (!is_inside_world()) return; @@ -418,7 +385,6 @@ void Node3D::update_gizmo() { } void Node3D::set_gizmo(const Ref<Node3DGizmo> &p_gizmo) { - #ifdef TOOLS_ENABLED if (data.gizmo_disabled) @@ -427,7 +393,6 @@ void Node3D::set_gizmo(const Ref<Node3DGizmo> &p_gizmo) { data.gizmo->free(); data.gizmo = p_gizmo; if (data.gizmo.is_valid() && is_inside_world()) { - data.gizmo->create(); if (is_visible_in_tree()) { data.gizmo->redraw(); @@ -439,7 +404,6 @@ void Node3D::set_gizmo(const Ref<Node3DGizmo> &p_gizmo) { } Ref<Node3DGizmo> Node3D::get_gizmo() const { - #ifdef TOOLS_ENABLED return data.gizmo; @@ -450,7 +414,6 @@ Ref<Node3DGizmo> Node3D::get_gizmo() const { } void Node3D::_update_gizmo() { - #ifdef TOOLS_ENABLED if (!is_inside_world()) return; @@ -466,7 +429,6 @@ void Node3D::_update_gizmo() { #ifdef TOOLS_ENABLED void Node3D::set_disable_gizmo(bool p_enabled) { - data.gizmo_disabled = p_enabled; if (!p_enabled && data.gizmo.is_valid()) data.gizmo = Ref<Node3DGizmo>(); @@ -475,7 +437,6 @@ void Node3D::set_disable_gizmo(bool p_enabled) { #endif void Node3D::set_disable_scale(bool p_enabled) { - data.disable_scale = p_enabled; } @@ -484,11 +445,9 @@ bool Node3D::is_scale_disabled() const { } void Node3D::set_as_toplevel(bool p_enabled) { - if (data.toplevel == p_enabled) return; if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint()) { - if (p_enabled) set_transform(get_global_transform()); else if (data.parent) @@ -503,12 +462,10 @@ void Node3D::set_as_toplevel(bool p_enabled) { } bool Node3D::is_set_as_toplevel() const { - return data.toplevel; } Ref<World3D> Node3D::get_world_3d() const { - ERR_FAIL_COND_V(!is_inside_world(), Ref<World3D>()); ERR_FAIL_COND_V(!data.viewport, Ref<World3D>()); @@ -516,7 +473,6 @@ Ref<World3D> Node3D::get_world_3d() const { } void Node3D::_propagate_visibility_changed() { - notification(NOTIFICATION_VISIBILITY_CHANGED); emit_signal(SceneStringNames::get_singleton()->visibility_changed); _change_notify("visible"); @@ -526,7 +482,6 @@ void Node3D::_propagate_visibility_changed() { #endif for (List<Node3D *>::Element *E = data.children.front(); E; E = E->next()) { - Node3D *c = E->get(); if (!c || !c->data.visible) continue; @@ -535,7 +490,6 @@ void Node3D::_propagate_visibility_changed() { } void Node3D::show() { - if (data.visible) return; @@ -548,7 +502,6 @@ void Node3D::show() { } void Node3D::hide() { - if (!data.visible) return; @@ -561,7 +514,6 @@ void Node3D::hide() { } bool Node3D::is_visible_in_tree() const { - const Node3D *s = this; while (s) { @@ -575,7 +527,6 @@ bool Node3D::is_visible_in_tree() const { } void Node3D::set_visible(bool p_visible) { - if (p_visible) show(); else @@ -583,7 +534,6 @@ void Node3D::set_visible(bool p_visible) { } bool Node3D::is_visible() const { - return data.visible; } @@ -594,34 +544,29 @@ void Node3D::rotate_object_local(const Vector3 &p_axis, float p_angle) { } void Node3D::rotate(const Vector3 &p_axis, float p_angle) { - Transform t = get_transform(); t.basis.rotate(p_axis, p_angle); set_transform(t); } void Node3D::rotate_x(float p_angle) { - Transform t = get_transform(); t.basis.rotate(Vector3(1, 0, 0), p_angle); set_transform(t); } void Node3D::rotate_y(float p_angle) { - Transform t = get_transform(); t.basis.rotate(Vector3(0, 1, 0), p_angle); set_transform(t); } void Node3D::rotate_z(float p_angle) { - Transform t = get_transform(); t.basis.rotate(Vector3(0, 0, 1), p_angle); set_transform(t); } void Node3D::translate(const Vector3 &p_offset) { - Transform t = get_transform(); t.translate(p_offset); set_transform(t); @@ -636,7 +581,6 @@ void Node3D::translate_object_local(const Vector3 &p_offset) { } void Node3D::scale(const Vector3 &p_ratio) { - Transform t = get_transform(); t.basis.scale(p_ratio); set_transform(t); @@ -649,14 +593,12 @@ void Node3D::scale_object_local(const Vector3 &p_scale) { } void Node3D::global_rotate(const Vector3 &p_axis, float p_angle) { - Transform t = get_global_transform(); t.basis.rotate(p_axis, p_angle); set_global_transform(t); } void Node3D::global_scale(const Vector3 &p_scale) { - Transform t = get_global_transform(); t.basis.scale(p_scale); set_global_transform(t); @@ -669,25 +611,21 @@ void Node3D::global_translate(const Vector3 &p_offset) { } void Node3D::orthonormalize() { - Transform t = get_transform(); t.orthonormalize(); set_transform(t); } void Node3D::set_identity() { - set_transform(Transform()); } void Node3D::look_at(const Vector3 &p_target, const Vector3 &p_up) { - Vector3 origin(get_global_transform().origin); look_at_from_position(origin, p_target, p_up); } void Node3D::look_at_from_position(const Vector3 &p_pos, const Vector3 &p_target, const Vector3 &p_up) { - ERR_FAIL_COND_MSG(p_pos == p_target, "Node origin and target are in the same position, look_at() failed."); ERR_FAIL_COND_MSG(p_up.cross(p_target - p_pos) == Vector3(), "Up vector and direction between node origin and target are aligned, look_at() failed."); @@ -701,12 +639,10 @@ void Node3D::look_at_from_position(const Vector3 &p_pos, const Vector3 &p_target } Vector3 Node3D::to_local(Vector3 p_global) const { - return get_global_transform().affine_inverse().xform(p_global); } Vector3 Node3D::to_global(Vector3 p_local) const { - return get_global_transform().xform(p_local); } @@ -737,7 +673,6 @@ void Node3D::force_update_transform() { } void Node3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_transform", "local"), &Node3D::set_transform); ClassDB::bind_method(D_METHOD("get_transform"), &Node3D::get_transform); ClassDB::bind_method(D_METHOD("set_translation", "translation"), &Node3D::set_translation); @@ -821,7 +756,6 @@ void Node3D::_bind_methods() { Node3D::Node3D() : xform_change(this) { - data.dirty = DIRTY_NONE; data.children_lock = 0; |