Reduce minimum capsule/cylinder mesh rings to 0

This commit is contained in:
Aaron Franke 2023-10-05 20:12:29 -05:00
parent 7233bc6736
commit 6ee9edb946
No known key found for this signature in database
GPG Key ID: 40A1750B977E56BF
2 changed files with 9 additions and 6 deletions

View File

@ -552,7 +552,7 @@ void CapsuleMesh::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.001,100.0,0.001,or_greater,suffix:m"), "set_radius", "get_radius"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.001,100.0,0.001,or_greater,suffix:m"), "set_radius", "get_radius");
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::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, "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_PROPERTY(PropertyInfo(Variant::INT, "rings", PROPERTY_HINT_RANGE, "0,100,1,or_greater"), "set_rings", "get_rings");
ADD_LINKED_PROPERTY("radius", "height"); ADD_LINKED_PROPERTY("radius", "height");
ADD_LINKED_PROPERTY("height", "radius"); ADD_LINKED_PROPERTY("height", "radius");
@ -594,7 +594,8 @@ int CapsuleMesh::get_radial_segments() const {
} }
void CapsuleMesh::set_rings(const int p_rings) { void CapsuleMesh::set_rings(const int p_rings) {
rings = p_rings > 1 ? p_rings : 1; ERR_FAIL_COND(p_rings < 0);
rings = p_rings;
_request_update(); _request_update();
} }
@ -1161,7 +1162,7 @@ void CylinderMesh::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "bottom_radius", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater,suffix:m"), "set_bottom_radius", "get_bottom_radius"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "bottom_radius", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater,suffix:m"), "set_bottom_radius", "get_bottom_radius");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_RANGE, "0.001,100,0.001,or_greater,suffix:m"), "set_height", "get_height"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_RANGE, "0.001,100,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, "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_PROPERTY(PropertyInfo(Variant::INT, "rings", PROPERTY_HINT_RANGE, "0,100,1,or_greater"), "set_rings", "get_rings");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cap_top"), "set_cap_top", "is_cap_top"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cap_top"), "set_cap_top", "is_cap_top");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cap_bottom"), "set_cap_bottom", "is_cap_bottom"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cap_bottom"), "set_cap_bottom", "is_cap_bottom");
} }
@ -1206,7 +1207,8 @@ int CylinderMesh::get_radial_segments() const {
} }
void CylinderMesh::set_rings(const int p_rings) { void CylinderMesh::set_rings(const int p_rings) {
rings = p_rings > 0 ? p_rings : 0; ERR_FAIL_COND(p_rings < 0);
rings = p_rings;
_request_update(); _request_update();
} }
@ -1919,7 +1921,8 @@ int SphereMesh::get_radial_segments() const {
} }
void SphereMesh::set_rings(const int p_rings) { void SphereMesh::set_rings(const int p_rings) {
rings = p_rings > 1 ? p_rings : 1; ERR_FAIL_COND(p_rings < 1);
rings = p_rings;
_request_update(); _request_update();
} }

View File

@ -232,7 +232,7 @@ TEST_CASE("[SceneTree][Primitive][Cylinder] Cylinder Primitive") {
CHECK(cylinder->get_bottom_radius() > 0); CHECK(cylinder->get_bottom_radius() > 0);
CHECK(cylinder->get_height() > 0); CHECK(cylinder->get_height() > 0);
CHECK(cylinder->get_radial_segments() > 0); CHECK(cylinder->get_radial_segments() > 0);
CHECK(cylinder->get_rings() > 0); CHECK(cylinder->get_rings() >= 0);
} }
SUBCASE("[SceneTree][Primitive][Cylinder] Set properties and get them") { SUBCASE("[SceneTree][Primitive][Cylinder] Set properties and get them") {