Add a max penetration correction integration parameter
This commit is contained in:
committed by
Sébastien Crozet
parent
34b0d51455
commit
1535db87c7
@@ -1,3 +1,12 @@
|
|||||||
|
- `RigidBody::set_linvel` and `RigidBody::set_angvel` no longer modify the velocity of static bodies.
|
||||||
|
- `RigidBody::set_body_type` will reset the velocity of a rigid-body to zero if it is static.
|
||||||
|
- `RigidBodyMassPropsFlags` has been renamed to `LockedAxes`.
|
||||||
|
- Don’t automatically clear forces at the end of a timestep.
|
||||||
|
- Don’t reset the velocity of kinematic bodies to zero at the end of the timestep.
|
||||||
|
- `RigidsBody::apply_force`, `::apply_torque`, `::apply_force_at_point` have been renamed to `::add_force`,
|
||||||
|
`::add_torque`, and `::add_force_at_point` to better reflect the fact that they are not cleared at the end
|
||||||
|
of the timestep.
|
||||||
|
|
||||||
## v0.12.0-alpha.0 (2 Jan. 2022)
|
## v0.12.0-alpha.0 (2 Jan. 2022)
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fixed `RigidBody::restrict_rotations` to properly take into account the axes to lock.
|
- Fixed `RigidBody::restrict_rotations` to properly take into account the axes to lock.
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ pub struct IntegrationParameters {
|
|||||||
|
|
||||||
/// Amount of penetration the engine wont attempt to correct (default: `0.001m`).
|
/// Amount of penetration the engine wont attempt to correct (default: `0.001m`).
|
||||||
pub allowed_linear_error: Real,
|
pub allowed_linear_error: Real,
|
||||||
|
/// Maximum amount of penetration the solver will attempt to resolve in one timestep.
|
||||||
|
pub max_penetration_correction: Real,
|
||||||
/// The maximal distance separating two objects that will generate predictive contacts (default: `0.002`).
|
/// The maximal distance separating two objects that will generate predictive contacts (default: `0.002`).
|
||||||
pub prediction_distance: Real,
|
pub prediction_distance: Real,
|
||||||
/// Maximum number of iterations performed to solve non-penetration and joint constraints (default: `4`).
|
/// Maximum number of iterations performed to solve non-penetration and joint constraints (default: `4`).
|
||||||
@@ -150,6 +152,7 @@ impl Default for IntegrationParameters {
|
|||||||
joint_erp: 1.0,
|
joint_erp: 1.0,
|
||||||
joint_damping_ratio: 1.0,
|
joint_damping_ratio: 1.0,
|
||||||
allowed_linear_error: 0.001, // 0.005
|
allowed_linear_error: 0.001, // 0.005
|
||||||
|
max_penetration_correction: Real::MAX,
|
||||||
prediction_distance: 0.002,
|
prediction_distance: 0.002,
|
||||||
max_velocity_iterations: 4,
|
max_velocity_iterations: 4,
|
||||||
max_velocity_friction_iterations: 8,
|
max_velocity_friction_iterations: 8,
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ impl GenericVelocityConstraint {
|
|||||||
rhs_wo_bias += manifold_point.dist.max(0.0) * inv_dt;
|
rhs_wo_bias += manifold_point.dist.max(0.0) * inv_dt;
|
||||||
rhs_wo_bias *= is_bouncy + is_resting;
|
rhs_wo_bias *= is_bouncy + is_resting;
|
||||||
let rhs_bias =
|
let rhs_bias =
|
||||||
/* is_resting * */ erp_inv_dt * manifold_point.dist.min(0.0);
|
/* is_resting * */ erp_inv_dt * manifold_point.dist.clamp(-params.max_penetration_correction, 0.0);
|
||||||
|
|
||||||
constraint.elements[k].normal_part = VelocityConstraintNormalPart {
|
constraint.elements[k].normal_part = VelocityConstraintNormalPart {
|
||||||
gcross1,
|
gcross1,
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ impl GenericVelocityGroundConstraint {
|
|||||||
rhs_wo_bias += manifold_point.dist.max(0.0) * inv_dt;
|
rhs_wo_bias += manifold_point.dist.max(0.0) * inv_dt;
|
||||||
rhs_wo_bias *= is_bouncy + is_resting;
|
rhs_wo_bias *= is_bouncy + is_resting;
|
||||||
let rhs_bias =
|
let rhs_bias =
|
||||||
/* is_resting * */ erp_inv_dt * manifold_point.dist.min(0.0);
|
/* is_resting * */ erp_inv_dt * manifold_point.dist.clamp(-params.max_penetration_correction, 0.0);
|
||||||
|
|
||||||
constraint.elements[k].normal_part = VelocityGroundConstraintNormalPart {
|
constraint.elements[k].normal_part = VelocityGroundConstraintNormalPart {
|
||||||
gcross2: na::zero(), // Unused for generic constraints.
|
gcross2: na::zero(), // Unused for generic constraints.
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ impl VelocityConstraint {
|
|||||||
rhs_wo_bias *= is_bouncy + is_resting;
|
rhs_wo_bias *= is_bouncy + is_resting;
|
||||||
let rhs_bias = /* is_resting
|
let rhs_bias = /* is_resting
|
||||||
* */ erp_inv_dt
|
* */ erp_inv_dt
|
||||||
* (manifold_point.dist + params.allowed_linear_error).min(0.0);
|
* (manifold_point.dist + params.allowed_linear_error).clamp(-params.max_penetration_correction, 0.0);
|
||||||
constraint.elements[k].normal_part = VelocityConstraintNormalPart {
|
constraint.elements[k].normal_part = VelocityConstraintNormalPart {
|
||||||
gcross1,
|
gcross1,
|
||||||
gcross2,
|
gcross2,
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ impl WVelocityConstraint {
|
|||||||
let inv_dt = SimdReal::splat(params.inv_dt());
|
let inv_dt = SimdReal::splat(params.inv_dt());
|
||||||
let allowed_lin_err = SimdReal::splat(params.allowed_linear_error);
|
let allowed_lin_err = SimdReal::splat(params.allowed_linear_error);
|
||||||
let erp_inv_dt = SimdReal::splat(params.erp_inv_dt());
|
let erp_inv_dt = SimdReal::splat(params.erp_inv_dt());
|
||||||
|
let max_penetration_correction = SimdReal::splat(params.max_penetration_correction);
|
||||||
|
|
||||||
let handles1 = gather![|ii| manifolds[ii].data.rigid_body1.unwrap()];
|
let handles1 = gather![|ii| manifolds[ii].data.rigid_body1.unwrap()];
|
||||||
let handles2 = gather![|ii| manifolds[ii].data.rigid_body2.unwrap()];
|
let handles2 = gather![|ii| manifolds[ii].data.rigid_body2.unwrap()];
|
||||||
@@ -145,7 +146,8 @@ impl WVelocityConstraint {
|
|||||||
(SimdReal::splat(1.0) + is_bouncy * restitution) * projected_velocity;
|
(SimdReal::splat(1.0) + is_bouncy * restitution) * projected_velocity;
|
||||||
rhs_wo_bias += dist.simd_max(SimdReal::zero()) * inv_dt;
|
rhs_wo_bias += dist.simd_max(SimdReal::zero()) * inv_dt;
|
||||||
rhs_wo_bias *= is_bouncy + is_resting;
|
rhs_wo_bias *= is_bouncy + is_resting;
|
||||||
let rhs_bias = (dist + allowed_lin_err).simd_min(SimdReal::zero())
|
let rhs_bias = (dist + allowed_lin_err)
|
||||||
|
.simd_clamp(-max_penetration_correction, SimdReal::zero())
|
||||||
* (erp_inv_dt/* * is_resting */);
|
* (erp_inv_dt/* * is_resting */);
|
||||||
|
|
||||||
constraint.elements[k].normal_part = VelocityConstraintNormalPart {
|
constraint.elements[k].normal_part = VelocityConstraintNormalPart {
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ impl VelocityGroundConstraint {
|
|||||||
rhs_wo_bias *= is_bouncy + is_resting;
|
rhs_wo_bias *= is_bouncy + is_resting;
|
||||||
let rhs_bias = /* is_resting
|
let rhs_bias = /* is_resting
|
||||||
* */ erp_inv_dt
|
* */ erp_inv_dt
|
||||||
* (manifold_point.dist + params.allowed_linear_error).min(0.0);
|
* (manifold_point.dist + params.allowed_linear_error).clamp(-params.max_penetration_correction, 0.0);
|
||||||
|
|
||||||
constraint.elements[k].normal_part = VelocityGroundConstraintNormalPart {
|
constraint.elements[k].normal_part = VelocityGroundConstraintNormalPart {
|
||||||
gcross2,
|
gcross2,
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ impl WVelocityGroundConstraint {
|
|||||||
let inv_dt = SimdReal::splat(params.inv_dt());
|
let inv_dt = SimdReal::splat(params.inv_dt());
|
||||||
let allowed_lin_err = SimdReal::splat(params.allowed_linear_error);
|
let allowed_lin_err = SimdReal::splat(params.allowed_linear_error);
|
||||||
let erp_inv_dt = SimdReal::splat(params.erp_inv_dt());
|
let erp_inv_dt = SimdReal::splat(params.erp_inv_dt());
|
||||||
|
let max_penetration_correction = SimdReal::splat(params.max_penetration_correction);
|
||||||
|
|
||||||
let mut handles1 = gather![|ii| manifolds[ii].data.rigid_body1];
|
let mut handles1 = gather![|ii| manifolds[ii].data.rigid_body1];
|
||||||
let mut handles2 = gather![|ii| manifolds[ii].data.rigid_body2];
|
let mut handles2 = gather![|ii| manifolds[ii].data.rigid_body2];
|
||||||
@@ -150,7 +151,8 @@ impl WVelocityGroundConstraint {
|
|||||||
(SimdReal::splat(1.0) + is_bouncy * restitution) * projected_velocity;
|
(SimdReal::splat(1.0) + is_bouncy * restitution) * projected_velocity;
|
||||||
rhs_wo_bias += dist.simd_max(SimdReal::zero()) * inv_dt;
|
rhs_wo_bias += dist.simd_max(SimdReal::zero()) * inv_dt;
|
||||||
rhs_wo_bias *= is_bouncy + is_resting;
|
rhs_wo_bias *= is_bouncy + is_resting;
|
||||||
let rhs_bias = (dist + allowed_lin_err).simd_min(SimdReal::zero())
|
let rhs_bias = (dist + allowed_lin_err)
|
||||||
|
.simd_clamp(-max_penetration_correction, SimdReal::zero())
|
||||||
* (erp_inv_dt/* * is_resting */);
|
* (erp_inv_dt/* * is_resting */);
|
||||||
|
|
||||||
constraint.elements[k].normal_part = VelocityGroundConstraintNormalPart {
|
constraint.elements[k].normal_part = VelocityGroundConstraintNormalPart {
|
||||||
|
|||||||
Reference in New Issue
Block a user