Merge pull request #62314 from tefusion/capsulemesh-radius-height-setters
Fix CapsuleMesh height/radius setters
This commit is contained in:
commit
dd743b3c78
@ -439,12 +439,15 @@ void CapsuleMesh::_bind_methods() {
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_RANGE, "0.001,100.0,0.001,or_greater,suffix:m"), "set_height", "get_height");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "radial_segments", PROPERTY_HINT_RANGE, "1,100,1,or_greater"), "set_radial_segments", "get_radial_segments");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "rings", PROPERTY_HINT_RANGE, "1,100,1,or_greater"), "set_rings", "get_rings");
|
||||
|
||||
ADD_LINKED_PROPERTY("radius", "height");
|
||||
ADD_LINKED_PROPERTY("height", "radius");
|
||||
}
|
||||
|
||||
void CapsuleMesh::set_radius(const float p_radius) {
|
||||
radius = p_radius;
|
||||
if (radius > height * 0.5) {
|
||||
radius = height * 0.5;
|
||||
height = radius * 2.0;
|
||||
}
|
||||
_request_update();
|
||||
}
|
||||
@ -456,7 +459,7 @@ float CapsuleMesh::get_radius() const {
|
||||
void CapsuleMesh::set_height(const float p_height) {
|
||||
height = p_height;
|
||||
if (radius > height * 0.5) {
|
||||
height = radius * 2;
|
||||
radius = height * 0.5;
|
||||
}
|
||||
_request_update();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user