feat: modules moved and engine moved to submodule

This commit is contained in:
Jan van der Weide 2025-04-12 18:40:44 +02:00
parent dfb5e645cd
commit c33d2130cc
5136 changed files with 225275 additions and 64485 deletions

View file

@ -57,7 +57,7 @@ constexpr double DEFAULT_CONTACT_MAX_SEPARATION = 0.05;
constexpr double DEFAULT_CONTACT_MAX_ALLOWED_PENETRATION = 0.01;
constexpr double DEFAULT_CONTACT_DEFAULT_BIAS = 0.8;
constexpr double DEFAULT_SLEEP_THRESHOLD_LINEAR = 0.1;
constexpr double DEFAULT_SLEEP_THRESHOLD_ANGULAR = 8.0 * Math_PI / 180;
constexpr double DEFAULT_SLEEP_THRESHOLD_ANGULAR = 8.0 * Math::PI / 180;
constexpr double DEFAULT_SOLVER_ITERATIONS = 8;
} // namespace
@ -98,23 +98,23 @@ JoltSpace3D::JoltSpace3D(JPH::JobSystem *p_job_system) :
layers(new JoltLayers()),
contact_listener(new JoltContactListener3D(this)),
physics_system(new JPH::PhysicsSystem()) {
physics_system->Init((JPH::uint)JoltProjectSettings::get_max_bodies(), 0, (JPH::uint)JoltProjectSettings::get_max_pairs(), (JPH::uint)JoltProjectSettings::get_max_contact_constraints(), *layers, *layers, *layers);
physics_system->Init((JPH::uint)JoltProjectSettings::max_bodies, 0, (JPH::uint)JoltProjectSettings::max_body_pairs, (JPH::uint)JoltProjectSettings::max_contact_constraints, *layers, *layers, *layers);
JPH::PhysicsSettings settings;
settings.mBaumgarte = JoltProjectSettings::get_baumgarte_stabilization_factor();
settings.mSpeculativeContactDistance = JoltProjectSettings::get_speculative_contact_distance();
settings.mPenetrationSlop = JoltProjectSettings::get_penetration_slop();
settings.mLinearCastThreshold = JoltProjectSettings::get_ccd_movement_threshold();
settings.mLinearCastMaxPenetration = JoltProjectSettings::get_ccd_max_penetration();
settings.mBodyPairCacheMaxDeltaPositionSq = JoltProjectSettings::get_body_pair_cache_distance_sq();
settings.mBodyPairCacheCosMaxDeltaRotationDiv2 = JoltProjectSettings::get_body_pair_cache_angle_cos_div2();
settings.mNumVelocitySteps = (JPH::uint)JoltProjectSettings::get_simulation_velocity_steps();
settings.mNumPositionSteps = (JPH::uint)JoltProjectSettings::get_simulation_position_steps();
settings.mMinVelocityForRestitution = JoltProjectSettings::get_bounce_velocity_threshold();
settings.mTimeBeforeSleep = JoltProjectSettings::get_sleep_time_threshold();
settings.mPointVelocitySleepThreshold = JoltProjectSettings::get_sleep_velocity_threshold();
settings.mUseBodyPairContactCache = JoltProjectSettings::is_body_pair_contact_cache_enabled();
settings.mAllowSleeping = JoltProjectSettings::is_sleep_allowed();
settings.mBaumgarte = JoltProjectSettings::baumgarte_stabilization_factor;
settings.mSpeculativeContactDistance = JoltProjectSettings::speculative_contact_distance;
settings.mPenetrationSlop = JoltProjectSettings::penetration_slop;
settings.mLinearCastThreshold = JoltProjectSettings::ccd_movement_threshold;
settings.mLinearCastMaxPenetration = JoltProjectSettings::ccd_max_penetration;
settings.mBodyPairCacheMaxDeltaPositionSq = JoltProjectSettings::body_pair_cache_distance_sq;
settings.mBodyPairCacheCosMaxDeltaRotationDiv2 = JoltProjectSettings::body_pair_cache_angle_cos_div2;
settings.mNumVelocitySteps = (JPH::uint)JoltProjectSettings::simulation_velocity_steps;
settings.mNumPositionSteps = (JPH::uint)JoltProjectSettings::simulation_position_steps;
settings.mMinVelocityForRestitution = JoltProjectSettings::bounce_velocity_threshold;
settings.mTimeBeforeSleep = JoltProjectSettings::sleep_time_threshold;
settings.mPointVelocitySleepThreshold = JoltProjectSettings::sleep_velocity_threshold;
settings.mUseBodyPairContactCache = JoltProjectSettings::body_pair_contact_cache_enabled;
settings.mAllowSleeping = JoltProjectSettings::sleep_allowed;
physics_system->SetPhysicsSettings(settings);
physics_system->SetGravity(JPH::Vec3::sZero());
@ -122,7 +122,7 @@ JoltSpace3D::JoltSpace3D(JPH::JobSystem *p_job_system) :
physics_system->SetSoftBodyContactListener(contact_listener);
physics_system->SetCombineFriction([](const JPH::Body &p_body1, const JPH::SubShapeID &p_sub_shape_id1, const JPH::Body &p_body2, const JPH::SubShapeID &p_sub_shape_id2) {
return ABS(MIN(p_body1.GetFriction(), p_body2.GetFriction()));
return Math::abs(MIN(p_body1.GetFriction(), p_body2.GetFriction()));
});
physics_system->SetCombineRestitution([](const JPH::Body &p_body1, const JPH::SubShapeID &p_sub_shape_id1, const JPH::Body &p_body2, const JPH::SubShapeID &p_sub_shape_id2) {
@ -169,21 +169,21 @@ void JoltSpace3D::step(float p_step) {
WARN_PRINT_ONCE(vformat("Jolt Physics manifold cache exceeded capacity and contacts were ignored. "
"Consider increasing maximum number of contact constraints in project settings. "
"Maximum number of contact constraints is currently set to %d.",
JoltProjectSettings::get_max_contact_constraints()));
JoltProjectSettings::max_contact_constraints));
}
if ((update_error & JPH::EPhysicsUpdateError::BodyPairCacheFull) != JPH::EPhysicsUpdateError::None) {
WARN_PRINT_ONCE(vformat("Jolt Physics body pair cache exceeded capacity and contacts were ignored. "
"Consider increasing maximum number of body pairs in project settings. "
"Maximum number of body pairs is currently set to %d.",
JoltProjectSettings::get_max_pairs()));
JoltProjectSettings::max_body_pairs));
}
if ((update_error & JPH::EPhysicsUpdateError::ContactConstraintsFull) != JPH::EPhysicsUpdateError::None) {
WARN_PRINT_ONCE(vformat("Jolt Physics contact constraint buffer exceeded capacity and contacts were ignored. "
"Consider increasing maximum number of contact constraints in project settings. "
"Maximum number of contact constraints is currently set to %d.",
JoltProjectSettings::get_max_contact_constraints()));
JoltProjectSettings::max_contact_constraints));
}
_post_step(p_step);
@ -227,7 +227,7 @@ double JoltSpace3D::get_param(PhysicsServer3D::SpaceParameter p_param) const {
return DEFAULT_SLEEP_THRESHOLD_ANGULAR;
}
case PhysicsServer3D::SPACE_PARAM_BODY_TIME_TO_SLEEP: {
return JoltProjectSettings::get_sleep_time_threshold();
return JoltProjectSettings::sleep_time_threshold;
}
case PhysicsServer3D::SPACE_PARAM_SOLVER_ITERATIONS: {
return DEFAULT_SOLVER_ITERATIONS;
@ -353,7 +353,7 @@ JPH::BodyID JoltSpace3D::add_rigid_body(const JoltObject3D &p_object, const JPH:
ERR_PRINT_ONCE(vformat("Failed to create underlying Jolt Physics body for '%s'. "
"Consider increasing maximum number of bodies in project settings. "
"Maximum number of bodies is currently set to %d.",
p_object.to_string(), JoltProjectSettings::get_max_bodies()));
p_object.to_string(), JoltProjectSettings::max_bodies));
return JPH::BodyID();
}
@ -370,7 +370,7 @@ JPH::BodyID JoltSpace3D::add_soft_body(const JoltObject3D &p_object, const JPH::
ERR_PRINT_ONCE(vformat("Failed to create underlying Jolt Physics body for '%s'. "
"Consider increasing maximum number of bodies in project settings. "
"Maximum number of bodies is currently set to %d.",
p_object.to_string(), JoltProjectSettings::get_max_bodies()));
p_object.to_string(), JoltProjectSettings::max_bodies));
return JPH::BodyID();
}