diff options
-rw-r--r-- | doc/classes/BoxShape3D.xml | 4 | ||||
-rw-r--r-- | editor/import/resource_importer_scene.cpp | 2 | ||||
-rw-r--r-- | editor/node_3d_editor_gizmos.cpp | 24 | ||||
-rw-r--r-- | modules/gdnavigation/navigation_mesh_generator.cpp | 2 | ||||
-rw-r--r-- | scene/resources/box_shape_3d.cpp | 26 | ||||
-rw-r--r-- | scene/resources/box_shape_3d.h | 6 |
6 files changed, 32 insertions, 32 deletions
diff --git a/doc/classes/BoxShape3D.xml b/doc/classes/BoxShape3D.xml index d8cbd8b980..f5051413ce 100644 --- a/doc/classes/BoxShape3D.xml +++ b/doc/classes/BoxShape3D.xml @@ -14,8 +14,8 @@ <methods> </methods> <members> - <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3( 1, 1, 1 )"> - The box's half extents. The width, height and depth of this shape is twice the half extents. + <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3( 2, 2, 2 )"> + The box's width, height and depth. </member> </members> <constants> 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); } diff --git a/modules/gdnavigation/navigation_mesh_generator.cpp b/modules/gdnavigation/navigation_mesh_generator.cpp index 3310123ca9..5ac153d077 100644 --- a/modules/gdnavigation/navigation_mesh_generator.cpp +++ b/modules/gdnavigation/navigation_mesh_generator.cpp @@ -178,7 +178,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform, if (box) { Ref<BoxMesh> box_mesh; box_mesh.instance(); - box_mesh->set_size(box->get_extents() * 2.0); + box_mesh->set_size(box->get_size()); mesh = box_mesh; } diff --git a/scene/resources/box_shape_3d.cpp b/scene/resources/box_shape_3d.cpp index e1c8a377c0..dcfd211451 100644 --- a/scene/resources/box_shape_3d.cpp +++ b/scene/resources/box_shape_3d.cpp @@ -34,8 +34,8 @@ Vector<Vector3> BoxShape3D::get_debug_mesh_lines() const { Vector<Vector3> lines; AABB aabb; - aabb.position = -get_extents(); - aabb.size = aabb.position * -2; + aabb.position = -size / 2; + aabb.size = size; for (int i = 0; i < 12; i++) { Vector3 a, b; @@ -48,33 +48,33 @@ Vector<Vector3> BoxShape3D::get_debug_mesh_lines() const { } real_t BoxShape3D::get_enclosing_radius() const { - return extents.length(); + return size.length() / 2; } void BoxShape3D::_update_shape() { - PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), extents); + PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), size / 2); Shape3D::_update_shape(); } -void BoxShape3D::set_extents(const Vector3 &p_extents) { - extents = p_extents; +void BoxShape3D::set_size(const Vector3 &p_size) { + size = p_size; _update_shape(); notify_change_to_owners(); - _change_notify("extents"); + _change_notify("size"); } -Vector3 BoxShape3D::get_extents() const { - return extents; +Vector3 BoxShape3D::get_size() const { + return size; } void BoxShape3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_extents", "extents"), &BoxShape3D::set_extents); - ClassDB::bind_method(D_METHOD("get_extents"), &BoxShape3D::get_extents); + ClassDB::bind_method(D_METHOD("set_size", "size"), &BoxShape3D::set_size); + ClassDB::bind_method(D_METHOD("get_size"), &BoxShape3D::get_size); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents"), "set_extents", "get_extents"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "size"), "set_size", "get_size"); } BoxShape3D::BoxShape3D() : Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_BOX)) { - set_extents(Vector3(1, 1, 1)); + set_size(Vector3(2, 2, 2)); } diff --git a/scene/resources/box_shape_3d.h b/scene/resources/box_shape_3d.h index fe634ce568..54840bc696 100644 --- a/scene/resources/box_shape_3d.h +++ b/scene/resources/box_shape_3d.h @@ -35,7 +35,7 @@ class BoxShape3D : public Shape3D { GDCLASS(BoxShape3D, Shape3D); - Vector3 extents; + Vector3 size; protected: static void _bind_methods(); @@ -43,8 +43,8 @@ protected: virtual void _update_shape() override; public: - void set_extents(const Vector3 &p_extents); - Vector3 get_extents() const; + void set_size(const Vector3 &p_size); + Vector3 get_size() const; virtual Vector<Vector3> get_debug_mesh_lines() const override; virtual real_t get_enclosing_radius() const override; |