From 24905becb26771e14c05d0976628cd494513f49a Mon Sep 17 00:00:00 2001 From: TwistedTwigleg Date: Tue, 26 May 2020 14:17:11 -0400 Subject: Made low level changes to the Skeleton3D class and Skeleton3D inspector. Changes listed below: * Added helper functions to Skeleton3D for converting transforms from bone space to global space, and vice versa. * Updated the Skeleton3D class reference. * Changed the icon used for bones in the Skeleton3D inspector to use BoneAttachement3D's icon. * Changed the Skeleton3D inspector to use EditorPropertyTransform and EditorPropertyVector3 when possible. * Placed the Transform/Matrix for each bone in a sub-section, so it is visually similar to the Node3D inspector. --- editor/editor_properties.cpp | 53 +++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 20 deletions(-) (limited to 'editor/editor_properties.cpp') diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index cfa0c7a063..74267452e6 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -1283,14 +1283,25 @@ void EditorPropertyVector3::_value_changed(double val, const String &p_name) { } void EditorPropertyVector3::update_property() { - Vector3 val = get_edited_object()->get(get_edited_property()); + update_using_vector(get_edited_object()->get(get_edited_property())); +} + +void EditorPropertyVector3::update_using_vector(Vector3 p_vector) { setting = true; - spin[0]->set_value(val.x); - spin[1]->set_value(val.y); - spin[2]->set_value(val.z); + spin[0]->set_value(p_vector.x); + spin[1]->set_value(p_vector.y); + spin[2]->set_value(p_vector.z); setting = false; } +Vector3 EditorPropertyVector3::get_vector() { + Vector3 v3; + v3.x = spin[0]->get_value(); + v3.y = spin[1]->get_value(); + v3.z = spin[2]->get_value(); + return v3; +} + void EditorPropertyVector3::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { Color base = get_theme_color("accent_color", "Editor"); @@ -1434,7 +1445,7 @@ EditorPropertyVector2i::EditorPropertyVector2i(bool p_force_wide) { setting = false; } -///////////////////// RECT2 ///////////////////////// +///////////////////// RECT2i ///////////////////////// void EditorPropertyRect2i::_value_changed(double val, const String &p_name) { if (setting) { @@ -1520,7 +1531,7 @@ EditorPropertyRect2i::EditorPropertyRect2i(bool p_force_wide) { setting = false; } -///////////////////// VECTOR3 ///////////////////////// +///////////////////// VECTOR3i ///////////////////////// void EditorPropertyVector3i::_value_changed(double val, const String &p_name) { if (setting) { @@ -2029,21 +2040,23 @@ void EditorPropertyTransform::_value_changed(double val, const String &p_name) { } void EditorPropertyTransform::update_property() { - Transform val = get_edited_object()->get(get_edited_property()); - setting = true; - spin[0]->set_value(val.basis[0][0]); - spin[1]->set_value(val.basis[1][0]); - spin[2]->set_value(val.basis[2][0]); - spin[3]->set_value(val.basis[0][1]); - spin[4]->set_value(val.basis[1][1]); - spin[5]->set_value(val.basis[2][1]); - spin[6]->set_value(val.basis[0][2]); - spin[7]->set_value(val.basis[1][2]); - spin[8]->set_value(val.basis[2][2]); - spin[9]->set_value(val.origin[0]); - spin[10]->set_value(val.origin[1]); - spin[11]->set_value(val.origin[2]); + update_using_transform(get_edited_object()->get(get_edited_property())); +} +void EditorPropertyTransform::update_using_transform(Transform p_transform) { + setting = true; + spin[0]->set_value(p_transform.basis[0][0]); + spin[1]->set_value(p_transform.basis[1][0]); + spin[2]->set_value(p_transform.basis[2][0]); + spin[3]->set_value(p_transform.basis[0][1]); + spin[4]->set_value(p_transform.basis[1][1]); + spin[5]->set_value(p_transform.basis[2][1]); + spin[6]->set_value(p_transform.basis[0][2]); + spin[7]->set_value(p_transform.basis[1][2]); + spin[8]->set_value(p_transform.basis[2][2]); + spin[9]->set_value(p_transform.origin[0]); + spin[10]->set_value(p_transform.origin[1]); + spin[11]->set_value(p_transform.origin[2]); setting = false; } -- cgit v1.2.3