diff options
author | Marcel Admiraal <madmiraal@users.noreply.github.com> | 2020-12-07 17:52:11 +0000 |
---|---|---|
committer | Marcel Admiraal <madmiraal@users.noreply.github.com> | 2020-12-08 11:58:21 +0000 |
commit | 43c910680620dd4c8b91bd96e4aa13cc98547def (patch) | |
tree | 7a0e50737d430d7a3ff3f8f036e752012b4c2e11 /editor | |
parent | d5d99aaed6fc2d852491f3c133eacb762656ac4c (diff) |
Use box size instead of extents for Shape dimensions
Diffstat (limited to 'editor')
-rw-r--r-- | editor/import/resource_importer_scene.cpp | 2 | ||||
-rw-r--r-- | editor/node_3d_editor_gizmos.cpp | 24 |
2 files changed, 13 insertions, 13 deletions
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index fc4f673ec4..1f059cf19b 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -429,7 +429,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> CollisionShape3D *colshape = memnew(CollisionShape3D); if (empty_draw_type == "CUBE") { BoxShape3D *boxShape = memnew(BoxShape3D); - boxShape->set_extents(Vector3(1, 1, 1)); + boxShape->set_size(Vector3(2, 2, 2)); colshape->set_shape(boxShape); colshape->set_name("BoxShape3D"); } else if (empty_draw_type == "SINGLE_ARROW") { diff --git a/editor/node_3d_editor_gizmos.cpp b/editor/node_3d_editor_gizmos.cpp index 1f6c32ed70..3221cf4b8e 100644 --- a/editor/node_3d_editor_gizmos.cpp +++ b/editor/node_3d_editor_gizmos.cpp @@ -3541,7 +3541,7 @@ String CollisionShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_g } if (Object::cast_to<BoxShape3D>(*s)) { - return "Extents"; + return "Size"; } if (Object::cast_to<CapsuleShape3D>(*s)) { @@ -3574,7 +3574,7 @@ Variant CollisionShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo if (Object::cast_to<BoxShape3D>(*s)) { Ref<BoxShape3D> bs = s; - return bs->get_extents(); + return bs->get_size(); } if (Object::cast_to<CapsuleShape3D>(*s)) { @@ -3658,9 +3658,9 @@ void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_i d = 0.001; } - Vector3 he = bs->get_extents(); - he[p_idx] = d; - bs->set_extents(he); + Vector3 he = bs->get_size(); + he[p_idx] = d * 2; + bs->set_size(he); } if (Object::cast_to<CapsuleShape3D>(*s)) { @@ -3737,14 +3737,14 @@ void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int if (Object::cast_to<BoxShape3D>(*s)) { Ref<BoxShape3D> ss = s; if (p_cancel) { - ss->set_extents(p_restore); + ss->set_size(p_restore); return; } UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); - ur->create_action(TTR("Change Box Shape Extents")); - ur->add_do_method(ss.ptr(), "set_extents", ss->get_extents()); - ur->add_undo_method(ss.ptr(), "set_extents", p_restore); + ur->create_action(TTR("Change Box Shape Size")); + ur->add_do_method(ss.ptr(), "set_size", ss->get_size()); + ur->add_undo_method(ss.ptr(), "set_size", p_restore); ur->commit_action(); } @@ -3878,8 +3878,8 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Ref<BoxShape3D> bs = s; Vector<Vector3> lines; AABB aabb; - aabb.position = -bs->get_extents(); - aabb.size = aabb.position * -2; + aabb.position = -bs->get_size() / 2; + aabb.size = bs->get_size(); for (int i = 0; i < 12; i++) { Vector3 a, b; @@ -3892,7 +3892,7 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { for (int i = 0; i < 3; i++) { Vector3 ax; - ax[i] = bs->get_extents()[i]; + ax[i] = bs->get_size()[i] / 2; handles.push_back(ax); } |