summaryrefslogtreecommitdiff
path: root/servers/physics_2d
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 /servers/physics_2d
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 'servers/physics_2d')
-rw-r--r--servers/physics_2d/godot_space_2d.cpp18
-rw-r--r--servers/physics_2d/godot_space_2d.h14
2 files changed, 25 insertions, 7 deletions
diff --git a/servers/physics_2d/godot_space_2d.cpp b/servers/physics_2d/godot_space_2d.cpp
index 5e6f233667..2e0379fe8a 100644
--- a/servers/physics_2d/godot_space_2d.cpp
+++ b/servers/physics_2d/godot_space_2d.cpp
@@ -1208,6 +1208,24 @@ GodotSpace2D::GodotSpace2D() {
body_time_to_sleep = GLOBAL_DEF("physics/2d/time_before_sleep", 0.5);
ProjectSettings::get_singleton()->set_custom_property_info("physics/2d/time_before_sleep", PropertyInfo(Variant::FLOAT, "physics/2d/time_before_sleep", PROPERTY_HINT_RANGE, "0,5,0.01,or_greater"));
+ solver_iterations = GLOBAL_DEF("physics/2d/solver/solver_iterations", 16);
+ ProjectSettings::get_singleton()->set_custom_property_info("physics/2d/solver/solver_iterations", PropertyInfo(Variant::INT, "physics/2d/solver/solver_iterations", PROPERTY_HINT_RANGE, "1,32,1,or_greater"));
+
+ contact_recycle_radius = GLOBAL_DEF("physics/2d/solver/contact_recycle_radius", 1.0);
+ ProjectSettings::get_singleton()->set_custom_property_info("physics/2d/solver/contact_recycle_radius", PropertyInfo(Variant::FLOAT, "physics/2d/solver/contact_max_separation", PROPERTY_HINT_RANGE, "0,10,0.01,or_greater"));
+
+ contact_max_separation = GLOBAL_DEF("physics/2d/solver/contact_max_separation", 1.5);
+ ProjectSettings::get_singleton()->set_custom_property_info("physics/2d/solver/contact_max_separation", PropertyInfo(Variant::FLOAT, "physics/2d/solver/contact_max_separation", PROPERTY_HINT_RANGE, "0,10,0.01,or_greater"));
+
+ contact_max_allowed_penetration = GLOBAL_DEF("physics/2d/solver/contact_max_allowed_penetration", 0.3);
+ ProjectSettings::get_singleton()->set_custom_property_info("physics/2d/solver/contact_max_allowed_penetration", PropertyInfo(Variant::FLOAT, "physics/2d/solver/contact_max_allowed_penetration", PROPERTY_HINT_RANGE, "0,10,0.01,or_greater"));
+
+ contact_bias = GLOBAL_DEF("physics/2d/solver/default_contact_bias", 0.8);
+ ProjectSettings::get_singleton()->set_custom_property_info("physics/2d/solver/default_contact_bias", PropertyInfo(Variant::FLOAT, "physics/2d/solver/default_contact_bias", PROPERTY_HINT_RANGE, "0,1,0.01"));
+
+ constraint_bias = GLOBAL_DEF("physics/2d/solver/default_constraint_bias", 0.2);
+ ProjectSettings::get_singleton()->set_custom_property_info("physics/2d/solver/default_constraint_bias", PropertyInfo(Variant::FLOAT, "physics/2d/solver/default_constraint_bias", PROPERTY_HINT_RANGE, "0,1,0.01"));
+
broadphase = GodotBroadPhase2D::create_func();
broadphase->set_pair_callback(_broadphase_pair, this);
broadphase->set_unpair_callback(_broadphase_unpair, this);
diff --git a/servers/physics_2d/godot_space_2d.h b/servers/physics_2d/godot_space_2d.h
index c0d06706d8..e11f4c3afb 100644
--- a/servers/physics_2d/godot_space_2d.h
+++ b/servers/physics_2d/godot_space_2d.h
@@ -82,7 +82,7 @@ private:
GodotPhysicsDirectSpaceState2D *direct_access = nullptr;
RID self;
- GodotBroadPhase2D *broadphase;
+ GodotBroadPhase2D *broadphase = nullptr;
SelfList<GodotBody2D>::List active_list;
SelfList<GodotBody2D>::List mass_properties_update_list;
SelfList<GodotBody2D>::List state_query_list;
@@ -96,13 +96,13 @@ private:
GodotArea2D *area = nullptr;
- int solver_iterations = 16;
+ int solver_iterations = 0;
- real_t contact_recycle_radius = 1.0;
- real_t contact_max_separation = 1.5;
- real_t contact_max_allowed_penetration = 0.3;
- real_t contact_bias = 0.8;
- real_t constraint_bias = 0.2;
+ real_t contact_recycle_radius = 0.0;
+ real_t contact_max_separation = 0.0;
+ real_t contact_max_allowed_penetration = 0.0;
+ real_t contact_bias = 0.0;
+ real_t constraint_bias = 0.0;
enum {
INTERSECTION_QUERY_MAX = 2048