mirror of
https://github.com/godotengine/godot.git
synced 2025-02-01 14:45:22 +00:00
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
This commit is contained in:
parent
4bce5e302e
commit
8682adcb87
@ -11,6 +11,7 @@
|
||||
<members>
|
||||
<member name="bias" type="float" setter="set_bias" getter="get_bias" default="0.0">
|
||||
When [member node_a] and [member node_b] move in different directions the [code]bias[/code] controls how fast the joint pulls them back to their original position. The lower the [code]bias[/code] the more the two bodies can pull on the joint.
|
||||
When set to [code]0[/code], the default value from [member ProjectSettings.physics/2d/solver/default_constraint_bias] is used.
|
||||
</member>
|
||||
<member name="disable_collision" type="bool" setter="set_exclude_nodes_from_collision" getter="get_exclude_nodes_from_collision" default="true">
|
||||
If [code]true[/code], [member node_a] and [member node_b] can not collide.
|
||||
|
@ -789,7 +789,7 @@
|
||||
Constant to set/get the maximum distance a pair of bodies has to move before their collision status has to be recalculated.
|
||||
</constant>
|
||||
<constant name="SPACE_PARAM_CONTACT_MAX_SEPARATION" value="1" enum="SpaceParameter">
|
||||
Constant to set/get the maximum distance a shape can be from another before they are considered separated.
|
||||
Constant to set/get the maximum distance a shape can be from another before they are considered separated and the contact is discarded.
|
||||
</constant>
|
||||
<constant name="SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION" value="2" enum="SpaceParameter">
|
||||
Constant to set/get the maximum distance a shape can penetrate another shape before it is considered a collision.
|
||||
|
@ -1333,7 +1333,7 @@
|
||||
Constant to set/get the maximum distance a pair of bodies has to move before their collision status has to be recalculated.
|
||||
</constant>
|
||||
<constant name="SPACE_PARAM_CONTACT_MAX_SEPARATION" value="1" enum="SpaceParameter">
|
||||
Constant to set/get the maximum distance a shape can be from another before they are considered separated.
|
||||
Constant to set/get the maximum distance a shape can be from another before they are considered separated and the contact is discarded.
|
||||
</constant>
|
||||
<constant name="SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION" value="2" enum="SpaceParameter">
|
||||
Constant to set/get the maximum distance a shape can penetrate another shape before it is considered a collision.
|
||||
@ -1350,12 +1350,7 @@
|
||||
<constant name="SPACE_PARAM_BODY_TIME_TO_SLEEP" value="6" enum="SpaceParameter">
|
||||
Constant to set/get the maximum time of activity. A body marked as potentially inactive for both linear and angular velocity will be put to sleep after this time.
|
||||
</constant>
|
||||
<constant name="SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO" value="7" enum="SpaceParameter">
|
||||
</constant>
|
||||
<constant name="SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS" value="8" enum="SpaceParameter">
|
||||
Constant to set/get the default solver bias for all physics constraints. A solver bias is a factor controlling how much two objects "rebound", after violating a constraint, to avoid leaving them in that state because of numerical imprecision.
|
||||
</constant>
|
||||
<constant name="SPACE_PARAM_SOLVER_ITERATIONS" value="9" enum="SpaceParameter">
|
||||
<constant name="SPACE_PARAM_SOLVER_ITERATIONS" value="7" enum="SpaceParameter">
|
||||
Constant to set/get the number of solver iterations for contacts and constraints. The greater the amount of iterations, the more accurate the collisions and constraints will be. However, a greater amount of iterations requires more CPU power, which can decrease performance.
|
||||
</constant>
|
||||
<constant name="BODY_AXIS_LINEAR_X" value="1" enum="BodyAxis">
|
||||
|
@ -1420,6 +1420,26 @@
|
||||
<member name="physics/2d/sleep_threshold_linear" type="float" setter="" getter="" default="2.0">
|
||||
Threshold linear velocity under which a 2D physics body will be considered inactive. See [constant PhysicsServer2D.SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD].
|
||||
</member>
|
||||
<member name="physics/2d/solver/contact_max_allowed_penetration" type="float" setter="" getter="" default="0.3">
|
||||
Maximum distance a shape can penetrate another shape before it is considered a collision. See [constant PhysicsServer2D.SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION].
|
||||
</member>
|
||||
<member name="physics/2d/solver/contact_max_separation" type="float" setter="" getter="" default="1.5">
|
||||
Maximum distance a shape can be from another before they are considered separated and the contact is discarded. See [constant PhysicsServer2D.SPACE_PARAM_CONTACT_MAX_SEPARATION].
|
||||
</member>
|
||||
<member name="physics/2d/solver/contact_recycle_radius" type="float" setter="" getter="" default="1.0">
|
||||
Maximum distance a pair of bodies has to move before their collision status has to be recalculated. See [constant PhysicsServer2D.SPACE_PARAM_CONTACT_RECYCLE_RADIUS].
|
||||
</member>
|
||||
<member name="physics/2d/solver/default_constraint_bias" type="float" setter="" getter="" default="0.2">
|
||||
Default solver bias for all physics constraints. Defines how much bodies react to enforce constraints. See [constant PhysicsServer2D.SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS].
|
||||
Individual constraints can have a specific bias value (see [member Joint2D.bias]).
|
||||
</member>
|
||||
<member name="physics/2d/solver/default_contact_bias" type="float" setter="" getter="" default="0.8">
|
||||
Default solver bias for all physics contacts. Defines how much bodies react to enforce contact separation. See [constant PhysicsServer2D.SPACE_PARAM_CONTACT_DEFAULT_BIAS].
|
||||
Individual shapes can have a specific bias value (see [member Shape2D.custom_solver_bias]).
|
||||
</member>
|
||||
<member name="physics/2d/solver/solver_iterations" type="int" setter="" getter="" default="16">
|
||||
Number of solver iterations for all contacts and constraints. The greater the amount of iterations, the more accurate the collisions will be. However, a greater amount of iterations requires more CPU power, which can decrease performance. See [constant PhysicsServer2D.SPACE_PARAM_SOLVER_ITERATIONS].
|
||||
</member>
|
||||
<member name="physics/2d/time_before_sleep" type="float" setter="" getter="" default="0.5">
|
||||
Time (in seconds) of inactivity before which a 2D physics body will put to sleep. See [constant PhysicsServer2D.SPACE_PARAM_BODY_TIME_TO_SLEEP].
|
||||
</member>
|
||||
@ -1467,10 +1487,29 @@
|
||||
Sets whether 3D physics is run on the main thread or a separate one. Running the server on a thread increases performance, but restricts API access to only physics process.
|
||||
</member>
|
||||
<member name="physics/3d/sleep_threshold_angular" type="float" setter="" getter="" default="0.139626">
|
||||
Threshold angular velocity under which a 3D physics body will be considered inactive. See [constant PhysicsServer3D.SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD].
|
||||
</member>
|
||||
<member name="physics/3d/sleep_threshold_linear" type="float" setter="" getter="" default="0.1">
|
||||
Threshold linear velocity under which a 3D physics body will be considered inactive. See [constant PhysicsServer3D.SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD].
|
||||
</member>
|
||||
<member name="physics/3d/solver/contact_max_allowed_penetration" type="float" setter="" getter="" default="0.01">
|
||||
Maximum distance a shape can penetrate another shape before it is considered a collision. See [constant PhysicsServer3D.SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION].
|
||||
</member>
|
||||
<member name="physics/3d/solver/contact_max_separation" type="float" setter="" getter="" default="0.05">
|
||||
Maximum distance a shape can be from another before they are considered separated and the contact is discarded. See [constant PhysicsServer3D.SPACE_PARAM_CONTACT_MAX_SEPARATION].
|
||||
</member>
|
||||
<member name="physics/3d/solver/contact_recycle_radius" type="float" setter="" getter="" default="0.01">
|
||||
Maximum distance a pair of bodies has to move before their collision status has to be recalculated. See [constant PhysicsServer3D.SPACE_PARAM_CONTACT_RECYCLE_RADIUS].
|
||||
</member>
|
||||
<member name="physics/3d/solver/default_contact_bias" type="float" setter="" getter="" default="0.8">
|
||||
Default solver bias for all physics contacts. Defines how much bodies react to enforce contact separation. See [constant PhysicsServer3D.SPACE_PARAM_CONTACT_DEFAULT_BIAS].
|
||||
Individual shapes can have a specific bias value (see [member Shape3D.custom_solver_bias]).
|
||||
</member>
|
||||
<member name="physics/3d/solver/solver_iterations" type="int" setter="" getter="" default="16">
|
||||
Number of solver iterations for all contacts and constraints. The greater the amount of iterations, the more accurate the collisions will be. However, a greater amount of iterations requires more CPU power, which can decrease performance. See [constant PhysicsServer3D.SPACE_PARAM_SOLVER_ITERATIONS].
|
||||
</member>
|
||||
<member name="physics/3d/time_before_sleep" type="float" setter="" getter="" default="0.5">
|
||||
Time (in seconds) of inactivity before which a 3D physics body will put to sleep. See [constant PhysicsServer3D.SPACE_PARAM_BODY_TIME_TO_SLEEP].
|
||||
</member>
|
||||
<member name="physics/common/enable_object_picking" type="bool" setter="" getter="" default="true">
|
||||
Enables [member Viewport.physics_object_picking] on the root viewport.
|
||||
|
@ -65,7 +65,8 @@
|
||||
</methods>
|
||||
<members>
|
||||
<member name="custom_solver_bias" type="float" setter="set_custom_solver_bias" getter="get_custom_solver_bias" default="0.0">
|
||||
The shape's custom solver bias.
|
||||
The shape's custom solver bias. Defines how much bodies react to enforce contact separation when this shape is involved.
|
||||
When set to [code]0[/code], the default value from [member ProjectSettings.physics/2d/solver/default_contact_bias] is used.
|
||||
</member>
|
||||
</members>
|
||||
</class>
|
||||
|
@ -18,6 +18,10 @@
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="custom_solver_bias" type="float" setter="set_custom_solver_bias" getter="get_custom_solver_bias" default="0.0">
|
||||
The shape's custom solver bias. Defines how much bodies react to enforce contact separation when this shape is involved.
|
||||
When set to [code]0[/code], the default value from [member ProjectSettings.physics/3d/solver/default_contact_bias] is used.
|
||||
</member>
|
||||
<member name="margin" type="float" setter="set_margin" getter="get_margin" default="0.04">
|
||||
The collision margin for the shape. Used in Bullet Physics only.
|
||||
Collision margins allow collision detection to be more efficient by adding an extra shell around shapes. Collision algorithms are more expensive when objects overlap by more than their margin, so a higher value for margins is better for performance, at the cost of accuracy around edges as it makes them less sharp.
|
||||
|
@ -426,8 +426,6 @@ void SpaceBullet::set_param(PhysicsServer3D::SpaceParameter p_param, real_t p_va
|
||||
case PhysicsServer3D::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD:
|
||||
case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD:
|
||||
case PhysicsServer3D::SPACE_PARAM_BODY_TIME_TO_SLEEP:
|
||||
case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO:
|
||||
case PhysicsServer3D::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS:
|
||||
default:
|
||||
WARN_PRINT("This set parameter (" + itos(p_param) + ") is ignored, the SpaceBullet doesn't support it.");
|
||||
break;
|
||||
@ -442,8 +440,6 @@ real_t SpaceBullet::get_param(PhysicsServer3D::SpaceParameter p_param) {
|
||||
case PhysicsServer3D::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD:
|
||||
case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD:
|
||||
case PhysicsServer3D::SPACE_PARAM_BODY_TIME_TO_SLEEP:
|
||||
case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO:
|
||||
case PhysicsServer3D::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS:
|
||||
default:
|
||||
WARN_PRINT("The SpaceBullet doesn't support this get parameter (" + itos(p_param) + "), 0 is returned.");
|
||||
return 0.f;
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -1188,12 +1188,6 @@ void GodotSpace3D::set_param(PhysicsServer3D::SpaceParameter p_param, real_t p_v
|
||||
case PhysicsServer3D::SPACE_PARAM_BODY_TIME_TO_SLEEP:
|
||||
body_time_to_sleep = p_value;
|
||||
break;
|
||||
case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO:
|
||||
body_angular_velocity_damp_ratio = p_value;
|
||||
break;
|
||||
case PhysicsServer3D::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS:
|
||||
constraint_bias = p_value;
|
||||
break;
|
||||
case PhysicsServer3D::SPACE_PARAM_SOLVER_ITERATIONS:
|
||||
solver_iterations = p_value;
|
||||
break;
|
||||
@ -1216,10 +1210,6 @@ real_t GodotSpace3D::get_param(PhysicsServer3D::SpaceParameter p_param) const {
|
||||
return body_angular_velocity_sleep_threshold;
|
||||
case PhysicsServer3D::SPACE_PARAM_BODY_TIME_TO_SLEEP:
|
||||
return body_time_to_sleep;
|
||||
case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO:
|
||||
return body_angular_velocity_damp_ratio;
|
||||
case PhysicsServer3D::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS:
|
||||
return constraint_bias;
|
||||
case PhysicsServer3D::SPACE_PARAM_SOLVER_ITERATIONS:
|
||||
return solver_iterations;
|
||||
}
|
||||
@ -1247,7 +1237,21 @@ GodotSpace3D::GodotSpace3D() {
|
||||
body_angular_velocity_sleep_threshold = GLOBAL_DEF("physics/3d/sleep_threshold_angular", Math::deg2rad(8.0));
|
||||
body_time_to_sleep = GLOBAL_DEF("physics/3d/time_before_sleep", 0.5);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("physics/3d/time_before_sleep", PropertyInfo(Variant::FLOAT, "physics/3d/time_before_sleep", PROPERTY_HINT_RANGE, "0,5,0.01,or_greater"));
|
||||
body_angular_velocity_damp_ratio = 10;
|
||||
|
||||
solver_iterations = GLOBAL_DEF("physics/3d/solver/solver_iterations", 16);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("physics/3d/solver/solver_iterations", PropertyInfo(Variant::INT, "physics/3d/solver/solver_iterations", PROPERTY_HINT_RANGE, "1,32,1,or_greater"));
|
||||
|
||||
contact_recycle_radius = GLOBAL_DEF("physics/3d/solver/contact_recycle_radius", 0.01);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("physics/3d/solver/contact_recycle_radius", PropertyInfo(Variant::FLOAT, "physics/3d/solver/contact_max_separation", PROPERTY_HINT_RANGE, "0,0.1,0.01,or_greater"));
|
||||
|
||||
contact_max_separation = GLOBAL_DEF("physics/3d/solver/contact_max_separation", 0.05);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("physics/3d/solver/contact_max_separation", PropertyInfo(Variant::FLOAT, "physics/3d/solver/contact_max_separation", PROPERTY_HINT_RANGE, "0,0.1,0.01,or_greater"));
|
||||
|
||||
contact_max_allowed_penetration = GLOBAL_DEF("physics/3d/solver/contact_max_allowed_penetration", 0.01);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("physics/3d/solver/contact_max_allowed_penetration", PropertyInfo(Variant::FLOAT, "physics/3d/solver/contact_max_allowed_penetration", PROPERTY_HINT_RANGE, "0,0.1,0.01,or_greater"));
|
||||
|
||||
contact_bias = GLOBAL_DEF("physics/3d/solver/default_contact_bias", 0.8);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("physics/3d/solver/default_contact_bias", PropertyInfo(Variant::FLOAT, "physics/3d/solver/default_contact_bias", PROPERTY_HINT_RANGE, "0,1,0.01"));
|
||||
|
||||
broadphase = GodotBroadPhase3D::create_func();
|
||||
broadphase->set_pair_callback(_broadphase_pair, this);
|
||||
|
@ -75,10 +75,10 @@ public:
|
||||
private:
|
||||
uint64_t elapsed_time[ELAPSED_TIME_MAX] = {};
|
||||
|
||||
GodotPhysicsDirectSpaceState3D *direct_access;
|
||||
GodotPhysicsDirectSpaceState3D *direct_access = nullptr;
|
||||
RID self;
|
||||
|
||||
GodotBroadPhase3D *broadphase;
|
||||
GodotBroadPhase3D *broadphase = nullptr;
|
||||
SelfList<GodotBody3D>::List active_list;
|
||||
SelfList<GodotBody3D>::List mass_properties_update_list;
|
||||
SelfList<GodotBody3D>::List state_query_list;
|
||||
@ -93,13 +93,12 @@ private:
|
||||
|
||||
GodotArea3D *area = nullptr;
|
||||
|
||||
int solver_iterations = 16;
|
||||
int solver_iterations = 0;
|
||||
|
||||
real_t contact_recycle_radius = 0.01;
|
||||
real_t contact_max_separation = 0.05;
|
||||
real_t contact_max_allowed_penetration = 0.01;
|
||||
real_t contact_bias = 0.8;
|
||||
real_t constraint_bias = 0.01;
|
||||
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;
|
||||
|
||||
enum {
|
||||
INTERSECTION_QUERY_MAX = 2048
|
||||
@ -108,10 +107,9 @@ private:
|
||||
GodotCollisionObject3D *intersection_query_results[INTERSECTION_QUERY_MAX];
|
||||
int intersection_query_subindex_results[INTERSECTION_QUERY_MAX];
|
||||
|
||||
real_t body_linear_velocity_sleep_threshold;
|
||||
real_t body_angular_velocity_sleep_threshold;
|
||||
real_t body_time_to_sleep;
|
||||
real_t body_angular_velocity_damp_ratio;
|
||||
real_t body_linear_velocity_sleep_threshold = 0.0;
|
||||
real_t body_angular_velocity_sleep_threshold = 0.0;
|
||||
real_t body_time_to_sleep = 0.0;
|
||||
|
||||
bool locked = false;
|
||||
|
||||
@ -167,11 +165,9 @@ public:
|
||||
_FORCE_INLINE_ real_t get_contact_max_separation() const { return contact_max_separation; }
|
||||
_FORCE_INLINE_ real_t get_contact_max_allowed_penetration() const { return contact_max_allowed_penetration; }
|
||||
_FORCE_INLINE_ real_t get_contact_bias() const { return contact_bias; }
|
||||
_FORCE_INLINE_ real_t get_constraint_bias() const { return constraint_bias; }
|
||||
_FORCE_INLINE_ real_t get_body_linear_velocity_sleep_threshold() const { return body_linear_velocity_sleep_threshold; }
|
||||
_FORCE_INLINE_ real_t get_body_angular_velocity_sleep_threshold() const { return body_angular_velocity_sleep_threshold; }
|
||||
_FORCE_INLINE_ real_t get_body_time_to_sleep() const { return body_time_to_sleep; }
|
||||
_FORCE_INLINE_ real_t get_body_angular_velocity_damp_ratio() const { return body_angular_velocity_damp_ratio; }
|
||||
|
||||
void update();
|
||||
void setup();
|
||||
|
@ -966,8 +966,6 @@ void PhysicsServer3D::_bind_methods() {
|
||||
BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD);
|
||||
BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD);
|
||||
BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_TIME_TO_SLEEP);
|
||||
BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO);
|
||||
BIND_ENUM_CONSTANT(SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS);
|
||||
BIND_ENUM_CONSTANT(SPACE_PARAM_SOLVER_ITERATIONS);
|
||||
|
||||
BIND_ENUM_CONSTANT(BODY_AXIS_LINEAR_X);
|
||||
|
@ -268,8 +268,6 @@ public:
|
||||
SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD,
|
||||
SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD,
|
||||
SPACE_PARAM_BODY_TIME_TO_SLEEP,
|
||||
SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO,
|
||||
SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS,
|
||||
SPACE_PARAM_SOLVER_ITERATIONS,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user