浏览代码

Improve range property hints for various collision shapes

Fixes #36419.

Co-authored-by: Andrii Doroshenko (Xrayez) <[email protected]>
(cherry picked from commit 0d772c6e6ecf210fa5b38df790b448cb80d4eb8c)
Rémi Verschelde 3 年之前
父节点
当前提交
c4897c4b8d

+ 3 - 2
scene/resources/capsule_shape.cpp

@@ -29,6 +29,7 @@
 /*************************************************************************/
 /*************************************************************************/
 
 
 #include "capsule_shape.h"
 #include "capsule_shape.h"
+
 #include "servers/physics_server.h"
 #include "servers/physics_server.h"
 
 
 Vector<Vector3> CapsuleShape::get_debug_mesh_lines() {
 Vector<Vector3> CapsuleShape::get_debug_mesh_lines() {
@@ -106,8 +107,8 @@ void CapsuleShape::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("set_height", "height"), &CapsuleShape::set_height);
 	ClassDB::bind_method(D_METHOD("set_height", "height"), &CapsuleShape::set_height);
 	ClassDB::bind_method(D_METHOD("get_height"), &CapsuleShape::get_height);
 	ClassDB::bind_method(D_METHOD("get_height"), &CapsuleShape::get_height);
 
 
-	ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0.01,4096,0.01"), "set_radius", "get_radius");
-	ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_RANGE, "0.01,4096,0.01"), "set_height", "get_height");
+	ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0.001,100,0.001,or_greater"), "set_radius", "get_radius");
+	ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_RANGE, "0.001,100,0.001,or_greater"), "set_height", "get_height");
 }
 }
 
 
 CapsuleShape::CapsuleShape() :
 CapsuleShape::CapsuleShape() :

+ 2 - 2
scene/resources/capsule_shape_2d.cpp

@@ -109,8 +109,8 @@ void CapsuleShape2D::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("set_height", "height"), &CapsuleShape2D::set_height);
 	ClassDB::bind_method(D_METHOD("set_height", "height"), &CapsuleShape2D::set_height);
 	ClassDB::bind_method(D_METHOD("get_height"), &CapsuleShape2D::get_height);
 	ClassDB::bind_method(D_METHOD("get_height"), &CapsuleShape2D::get_height);
 
 
-	ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
-	ADD_PROPERTY(PropertyInfo(Variant::REAL, "height"), "set_height", "get_height");
+	ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_radius", "get_radius");
+	ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_height", "get_height");
 }
 }
 
 
 CapsuleShape2D::CapsuleShape2D() :
 CapsuleShape2D::CapsuleShape2D() :

+ 1 - 1
scene/resources/circle_shape_2d.cpp

@@ -55,7 +55,7 @@ void CircleShape2D::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("set_radius", "radius"), &CircleShape2D::set_radius);
 	ClassDB::bind_method(D_METHOD("set_radius", "radius"), &CircleShape2D::set_radius);
 	ClassDB::bind_method(D_METHOD("get_radius"), &CircleShape2D::get_radius);
 	ClassDB::bind_method(D_METHOD("get_radius"), &CircleShape2D::get_radius);
 
 
-	ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0.01,16384,0.5"), "set_radius", "get_radius");
+	ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_radius", "get_radius");
 }
 }
 
 
 Rect2 CircleShape2D::get_rect() const {
 Rect2 CircleShape2D::get_rect() const {

+ 3 - 2
scene/resources/cylinder_shape.cpp

@@ -29,6 +29,7 @@
 /*************************************************************************/
 /*************************************************************************/
 
 
 #include "cylinder_shape.h"
 #include "cylinder_shape.h"
+
 #include "servers/physics_server.h"
 #include "servers/physics_server.h"
 
 
 Vector<Vector3> CylinderShape::get_debug_mesh_lines() {
 Vector<Vector3> CylinderShape::get_debug_mesh_lines() {
@@ -99,8 +100,8 @@ void CylinderShape::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("set_height", "height"), &CylinderShape::set_height);
 	ClassDB::bind_method(D_METHOD("set_height", "height"), &CylinderShape::set_height);
 	ClassDB::bind_method(D_METHOD("get_height"), &CylinderShape::get_height);
 	ClassDB::bind_method(D_METHOD("get_height"), &CylinderShape::get_height);
 
 
-	ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0.01,4096,0.01"), "set_radius", "get_radius");
-	ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_RANGE, "0.01,4096,0.01"), "set_height", "get_height");
+	ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_RANGE, "0.001,100,0.001,or_greater"), "set_height", "get_height");
+	ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0.001,100,0.001,or_greater"), "set_radius", "get_radius");
 }
 }
 
 
 CylinderShape::CylinderShape() :
 CylinderShape::CylinderShape() :

+ 3 - 2
scene/resources/height_map_shape.cpp

@@ -29,6 +29,7 @@
 /*************************************************************************/
 /*************************************************************************/
 
 
 #include "height_map_shape.h"
 #include "height_map_shape.h"
+
 #include "servers/physics_server.h"
 #include "servers/physics_server.h"
 
 
 Vector<Vector3> HeightMapShape::get_debug_mesh_lines() {
 Vector<Vector3> HeightMapShape::get_debug_mesh_lines() {
@@ -191,8 +192,8 @@ void HeightMapShape::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("set_map_data", "data"), &HeightMapShape::set_map_data);
 	ClassDB::bind_method(D_METHOD("set_map_data", "data"), &HeightMapShape::set_map_data);
 	ClassDB::bind_method(D_METHOD("get_map_data"), &HeightMapShape::get_map_data);
 	ClassDB::bind_method(D_METHOD("get_map_data"), &HeightMapShape::get_map_data);
 
 
-	ADD_PROPERTY(PropertyInfo(Variant::INT, "map_width", PROPERTY_HINT_RANGE, "1,4096,1"), "set_map_width", "get_map_width");
-	ADD_PROPERTY(PropertyInfo(Variant::INT, "map_depth", PROPERTY_HINT_RANGE, "1,4096,1"), "set_map_depth", "get_map_depth");
+	ADD_PROPERTY(PropertyInfo(Variant::INT, "map_width", PROPERTY_HINT_RANGE, "0.001,100,0.001,or_greater"), "set_map_width", "get_map_width");
+	ADD_PROPERTY(PropertyInfo(Variant::INT, "map_depth", PROPERTY_HINT_RANGE, "0.001,100,0.001,or_greater"), "set_map_depth", "get_map_depth");
 	ADD_PROPERTY(PropertyInfo(Variant::POOL_REAL_ARRAY, "map_data"), "set_map_data", "get_map_data");
 	ADD_PROPERTY(PropertyInfo(Variant::POOL_REAL_ARRAY, "map_data"), "set_map_data", "get_map_data");
 }
 }
 
 

+ 1 - 1
scene/resources/line_shape_2d.cpp

@@ -105,7 +105,7 @@ void LineShape2D::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("get_d"), &LineShape2D::get_d);
 	ClassDB::bind_method(D_METHOD("get_d"), &LineShape2D::get_d);
 
 
 	ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "normal"), "set_normal", "get_normal");
 	ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "normal"), "set_normal", "get_normal");
-	ADD_PROPERTY(PropertyInfo(Variant::REAL, "d"), "set_d", "get_d");
+	ADD_PROPERTY(PropertyInfo(Variant::REAL, "d", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_d", "get_d");
 }
 }
 
 
 LineShape2D::LineShape2D() :
 LineShape2D::LineShape2D() :

+ 1 - 1
scene/resources/ray_shape.cpp

@@ -81,7 +81,7 @@ void RayShape::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("set_slips_on_slope", "active"), &RayShape::set_slips_on_slope);
 	ClassDB::bind_method(D_METHOD("set_slips_on_slope", "active"), &RayShape::set_slips_on_slope);
 	ClassDB::bind_method(D_METHOD("get_slips_on_slope"), &RayShape::get_slips_on_slope);
 	ClassDB::bind_method(D_METHOD("get_slips_on_slope"), &RayShape::get_slips_on_slope);
 
 
-	ADD_PROPERTY(PropertyInfo(Variant::REAL, "length", PROPERTY_HINT_RANGE, "0,4096,0.01"), "set_length", "get_length");
+	ADD_PROPERTY(PropertyInfo(Variant::REAL, "length", PROPERTY_HINT_RANGE, "0.001,100,0.001,or_greater"), "set_length", "get_length");
 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "slips_on_slope"), "set_slips_on_slope", "get_slips_on_slope");
 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "slips_on_slope"), "set_slips_on_slope", "get_slips_on_slope");
 }
 }
 
 

+ 1 - 1
scene/resources/segment_shape_2d.cpp

@@ -141,7 +141,7 @@ void RayShape2D::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("set_slips_on_slope", "active"), &RayShape2D::set_slips_on_slope);
 	ClassDB::bind_method(D_METHOD("set_slips_on_slope", "active"), &RayShape2D::set_slips_on_slope);
 	ClassDB::bind_method(D_METHOD("get_slips_on_slope"), &RayShape2D::get_slips_on_slope);
 	ClassDB::bind_method(D_METHOD("get_slips_on_slope"), &RayShape2D::get_slips_on_slope);
 
 
-	ADD_PROPERTY(PropertyInfo(Variant::REAL, "length"), "set_length", "get_length");
+	ADD_PROPERTY(PropertyInfo(Variant::REAL, "length", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_length", "get_length");
 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "slips_on_slope"), "set_slips_on_slope", "get_slips_on_slope");
 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "slips_on_slope"), "set_slips_on_slope", "get_slips_on_slope");
 }
 }
 
 

+ 2 - 1
scene/resources/sphere_shape.cpp

@@ -29,6 +29,7 @@
 /*************************************************************************/
 /*************************************************************************/
 
 
 #include "sphere_shape.h"
 #include "sphere_shape.h"
+
 #include "servers/physics_server.h"
 #include "servers/physics_server.h"
 
 
 Vector<Vector3> SphereShape::get_debug_mesh_lines() {
 Vector<Vector3> SphereShape::get_debug_mesh_lines() {
@@ -77,7 +78,7 @@ void SphereShape::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("set_radius", "radius"), &SphereShape::set_radius);
 	ClassDB::bind_method(D_METHOD("set_radius", "radius"), &SphereShape::set_radius);
 	ClassDB::bind_method(D_METHOD("get_radius"), &SphereShape::get_radius);
 	ClassDB::bind_method(D_METHOD("get_radius"), &SphereShape::get_radius);
 
 
-	ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0,4096,0.01"), "set_radius", "get_radius");
+	ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0.001,100,0.001,or_greater"), "set_radius", "get_radius");
 }
 }
 
 
 SphereShape::SphereShape() :
 SphereShape::SphereShape() :