Skip to content

Commit

Permalink
Reduce minimum capsule/cylinder mesh rings to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronfranke committed Dec 6, 2023
1 parent 7233bc6 commit 6ee9edb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions scene/resources/primitive_meshes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, "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_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("height", "radius");
Expand Down Expand Up @@ -594,7 +594,8 @@ int CapsuleMesh::get_radial_segments() const {
}

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();
}

Expand Down Expand Up @@ -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, "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, "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_bottom"), "set_cap_bottom", "is_cap_bottom");
}
Expand Down Expand Up @@ -1206,7 +1207,8 @@ int CylinderMesh::get_radial_segments() const {
}

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();
}

Expand Down Expand Up @@ -1919,7 +1921,8 @@ int SphereMesh::get_radial_segments() const {
}

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();
}

Expand Down
2 changes: 1 addition & 1 deletion tests/scene/test_primitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ TEST_CASE("[SceneTree][Primitive][Cylinder] Cylinder Primitive") {
CHECK(cylinder->get_bottom_radius() > 0);
CHECK(cylinder->get_height() > 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") {
Expand Down

0 comments on commit 6ee9edb

Please sign in to comment.