diff options
author | Aaron Franke <arnfranke@yahoo.com> | 2021-04-04 22:27:00 -0400 |
---|---|---|
committer | Aaron Franke <arnfranke@yahoo.com> | 2021-08-29 10:34:50 -0500 |
commit | ee7bb9bbb9ebf5f4bb6d046340807e2982879428 (patch) | |
tree | d419ed8886352e30e16e3467a0d004de59c20dae /scene/3d/node_3d.cpp | |
parent | 4d08a737fb868b4c2f47946aea7c9ec4ee97894d (diff) | |
download | redot-engine-ee7bb9bbb9ebf5f4bb6d046340807e2982879428.tar.gz |
Display a matrix for Node2D and don't display a duplicate origin
Diffstat (limited to 'scene/3d/node_3d.cpp')
-rw-r--r-- | scene/3d/node_3d.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp index 12470939f5..c4abecfc82 100644 --- a/scene/3d/node_3d.cpp +++ b/scene/3d/node_3d.cpp @@ -220,6 +220,15 @@ void Node3D::_notification(int p_what) { } } +void Node3D::set_basis(const Basis &p_basis) { + data.local_transform = Transform3D(p_basis, data.local_transform.origin); + data.dirty |= DIRTY_VECTORS; + _propagate_transform_changed(this); + if (data.notify_local_transform) { + notification(NOTIFICATION_LOCAL_TRANSFORM_CHANGED); + } +} + void Node3D::set_transform(const Transform3D &p_transform) { data.local_transform = p_transform; data.dirty |= DIRTY_VECTORS; @@ -238,6 +247,14 @@ void Node3D::set_global_transform(const Transform3D &p_transform) { set_transform(xform); } +Basis Node3D::get_basis() const { + if (data.dirty & DIRTY_LOCAL) { + _update_local_transform(); + } + + return data.local_transform.basis; +} + Transform3D Node3D::get_transform() const { if (data.dirty & DIRTY_LOCAL) { _update_local_transform(); @@ -765,7 +782,9 @@ NodePath Node3D::get_visibility_parent() const { } void Node3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_transform", "local"), &Node3D::set_transform); + ClassDB::bind_method(D_METHOD("set_basis", "basis"), &Node3D::set_basis); + ClassDB::bind_method(D_METHOD("get_basis"), &Node3D::get_basis); + ClassDB::bind_method(D_METHOD("set_transform", "transform"), &Node3D::set_transform); ClassDB::bind_method(D_METHOD("get_transform"), &Node3D::get_transform); ClassDB::bind_method(D_METHOD("set_position", "position"), &Node3D::set_position); ClassDB::bind_method(D_METHOD("get_position"), &Node3D::get_position); @@ -838,8 +857,12 @@ void Node3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_lesser,or_greater,radians", PROPERTY_USAGE_EDITOR), "set_rotation", "get_rotation"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_scale", "get_scale"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "top_level"), "set_as_top_level", "is_set_as_top_level"); - ADD_GROUP("Matrix", ""); - ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "transform", PROPERTY_HINT_NONE, ""), "set_transform", "get_transform"); + + ADD_GROUP("Raw Matrix", ""); + // No need to display the full Transform, we already have the translation above. + ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "transform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_transform", "get_transform"); + ADD_PROPERTY(PropertyInfo(Variant::BASIS, "basis", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_basis", "get_basis"); + ADD_GROUP("Visibility", ""); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "visible"), "set_visible", "is_visible"); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "visibility_parent", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "GeometryInstance3D"), "set_visibility_parent", "get_visibility_parent"); |