diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-08-19 20:48:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-19 20:48:54 +0200 |
commit | 5b306859767d511a02618ae88a4da5fb15c9e202 (patch) | |
tree | 0b637394b2259dd36a6991f3c582ad1054f9873d /scene/resources/capsule_shape_3d.cpp | |
parent | fb8487e011fbf0310bd40cf339a58d5c60c9d259 (diff) | |
parent | 645bc94bfcb0d494e9d53e29aee1419800adcd4e (diff) |
Merge pull request #51583 from nekomatata/capsule-height-radius-setters
Fix capsule height/radius setters with linked properties
Diffstat (limited to 'scene/resources/capsule_shape_3d.cpp')
-rw-r--r-- | scene/resources/capsule_shape_3d.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/scene/resources/capsule_shape_3d.cpp b/scene/resources/capsule_shape_3d.cpp index e267941d6a..afec7b1877 100644 --- a/scene/resources/capsule_shape_3d.cpp +++ b/scene/resources/capsule_shape_3d.cpp @@ -81,7 +81,7 @@ void CapsuleShape3D::_update_shape() { void CapsuleShape3D::set_radius(float p_radius) { radius = p_radius; if (radius > height * 0.5) { - radius = height * 0.5; + height = radius * 2.0; } _update_shape(); notify_change_to_owners(); @@ -94,7 +94,7 @@ float CapsuleShape3D::get_radius() const { void CapsuleShape3D::set_height(float p_height) { height = p_height; if (radius > height * 0.5) { - height = radius * 2; + radius = height * 0.5; } _update_shape(); notify_change_to_owners(); @@ -112,6 +112,8 @@ void CapsuleShape3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.001,4096,0.001"), "set_radius", "get_radius"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_RANGE, "0.001,4096,0.001"), "set_height", "get_height"); + ADD_LINKED_PROPERTY("radius", "height"); + ADD_LINKED_PROPERTY("height", "radius"); } CapsuleShape3D::CapsuleShape3D() : |