summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
authorPouleyKetchoupp <pouleyketchoup@gmail.com>2021-12-06 18:10:13 -0700
committerPouleyKetchoupp <pouleyketchoup@gmail.com>2021-12-07 12:08:04 -0700
commit8682adcb8726459d2a0366dcea0a59ce742bee43 (patch)
tree5eade5f25ecd9247d3a926d9b27bddc7416287cb /scene/resources
parent4bce5e302ef8cc6fcd0caf5137f0c1d3abdb88c2 (diff)
Add physics solver settings to project settings
Helps with discovery and setup of physics solver settings, in a specific project settings section for both 2D and 3D. Other changes for cleanup: -Removed unused space parameters in 3D SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS -Added custom solver bias for Shape3D (same as Shape2D) -Improved documentation for solver settings
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/shape_3d.cpp13
-rw-r--r--scene/resources/shape_3d.h4
2 files changed, 17 insertions, 0 deletions
diff --git a/scene/resources/shape_3d.cpp b/scene/resources/shape_3d.cpp
index a02a0e5488..044268864a 100644
--- a/scene/resources/shape_3d.cpp
+++ b/scene/resources/shape_3d.cpp
@@ -48,6 +48,15 @@ void Shape3D::add_vertices_to_array(Vector<Vector3> &array, const Transform3D &p
}
}
+void Shape3D::set_custom_solver_bias(real_t p_bias) {
+ custom_bias = p_bias;
+ PhysicsServer3D::get_singleton()->shape_set_custom_solver_bias(shape, custom_bias);
+}
+
+real_t Shape3D::get_custom_solver_bias() const {
+ return custom_bias;
+}
+
real_t Shape3D::get_margin() const {
return margin;
}
@@ -99,11 +108,15 @@ void Shape3D::_update_shape() {
}
void Shape3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_custom_solver_bias", "bias"), &Shape3D::set_custom_solver_bias);
+ ClassDB::bind_method(D_METHOD("get_custom_solver_bias"), &Shape3D::get_custom_solver_bias);
+
ClassDB::bind_method(D_METHOD("set_margin", "margin"), &Shape3D::set_margin);
ClassDB::bind_method(D_METHOD("get_margin"), &Shape3D::get_margin);
ClassDB::bind_method(D_METHOD("get_debug_mesh"), &Shape3D::get_debug_mesh);
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "custom_solver_bias", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_custom_solver_bias", "get_custom_solver_bias");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "margin", PROPERTY_HINT_RANGE, "0.001,10,0.001"), "set_margin", "get_margin");
}
diff --git a/scene/resources/shape_3d.h b/scene/resources/shape_3d.h
index b8e529cd3c..f3a7aa5b12 100644
--- a/scene/resources/shape_3d.h
+++ b/scene/resources/shape_3d.h
@@ -40,6 +40,7 @@ class Shape3D : public Resource {
OBJ_SAVE_TYPE(Shape3D);
RES_BASE_EXTENSION("shape");
RID shape;
+ real_t custom_bias = 0.0;
real_t margin = 0.04;
Ref<ArrayMesh> debug_mesh_cache;
@@ -62,6 +63,9 @@ public:
void add_vertices_to_array(Vector<Vector3> &array, const Transform3D &p_xform);
+ void set_custom_solver_bias(real_t p_bias);
+ real_t get_custom_solver_bias() const;
+
real_t get_margin() const;
void set_margin(real_t p_margin);