diff --git a/joltphysics/joltphysics_inc.vpc b/joltphysics/joltphysics_inc.vpc index f29b4c2..25d5575 100644 --- a/joltphysics/joltphysics_inc.vpc +++ b/joltphysics/joltphysics_inc.vpc @@ -173,7 +173,6 @@ $Project "$PROJNAME" $File "$JOLT_PHYSICS_ROOT/Math/Real.h" $File "$JOLT_PHYSICS_ROOT/Math/Swizzle.h" $File "$JOLT_PHYSICS_ROOT/Math/Trigonometry.h" - $File "$JOLT_PHYSICS_ROOT/Math/UVec4.cpp" $File "$JOLT_PHYSICS_ROOT/Math/UVec4.h" $File "$JOLT_PHYSICS_ROOT/Math/UVec4.inl" $File "$JOLT_PHYSICS_ROOT/Math/UVec8.h" @@ -385,6 +384,8 @@ $Project "$PROJNAME" $File "$JOLT_PHYSICS_ROOT/Physics/Constraints/SixDOFConstraint.h" $File "$JOLT_PHYSICS_ROOT/Physics/Constraints/SliderConstraint.cpp" $File "$JOLT_PHYSICS_ROOT/Physics/Constraints/SliderConstraint.h" + $File "$JOLT_PHYSICS_ROOT/Physics/Constraints/SpringSettings.cpp" + $File "$JOLT_PHYSICS_ROOT/Physics/Constraints/SpringSettings.h" $File "$JOLT_PHYSICS_ROOT/Physics/Constraints/SwingTwistConstraint.cpp" $File "$JOLT_PHYSICS_ROOT/Physics/Constraints/SwingTwistConstraint.h" $File "$JOLT_PHYSICS_ROOT/Physics/Constraints/TwoBodyConstraint.cpp" diff --git a/joltphysics/src b/joltphysics/src index 172a99c..9ece1b4 160000 --- a/joltphysics/src +++ b/joltphysics/src @@ -1 +1 @@ -Subproject commit 172a99c718bded5faa169ac440517286684fa2f0 +Subproject commit 9ece1b49279210061bf7097c3bebb9fac23d93de diff --git a/vphysics_jolt/vjolt_controller_vehicle.cpp b/vphysics_jolt/vjolt_controller_vehicle.cpp index 8fd524e..f0fe7c1 100644 --- a/vphysics_jolt/vjolt_controller_vehicle.cpp +++ b/vphysics_jolt/vjolt_controller_vehicle.cpp @@ -408,7 +408,10 @@ void JoltPhysicsVehicleController::CreateWheel( JPH::VehicleConstraintSettings & JPH::WheelSettingsWV *wheelSettings = new JPH::WheelSettingsWV; wheelSettings->mPosition = SourceToJolt::Distance( wheelPositionLocal ); - wheelSettings->mDirection = JPH::Vec3( 0, 0, -1 ); + wheelSettings->mSuspensionDirection = JPH::Vec3( 0, 0, -1 ); + wheelSettings->mSteeringAxis = JPH::Vec3( 0, 0, 1 ); + wheelSettings->mWheelUp = JPH::Vec3( 0, 0, 1 ); + wheelSettings->mWheelForward = JPH::Vec3( 0, 1, 0 ); wheelSettings->mAngularDamping = axle.wheels.rotdamping; // TODO(Josh): What about more than 4 wheels? wheelSettings->mMaxSteerAngle = axleIdx == 0 ? steeringAngle : 0.0f; @@ -417,17 +420,17 @@ void JoltPhysicsVehicleController::CreateWheel( JPH::VehicleConstraintSettings & wheelSettings->mInertia = 0.5f * axle.wheels.mass * ( wheelSettings->mRadius * wheelSettings->mRadius ); wheelSettings->mSuspensionMinLength = 0; wheelSettings->mSuspensionMaxLength = additionalLength; - wheelSettings->mSuspensionDamping = axle.suspension.springDamping; + wheelSettings->mSuspensionSpring.mMode = JPH::ESpringMode::FrequencyAndDamping; // Josh: // so to go from K (Spring Constant) -> freq we do // sqrtf( K / Mass ) / ( 2.0f * PI ) // but it seems like it already has mass divided in Source so... // sqrtf( K ) / ( 2.0f * PI ) - wheelSettings->mSuspensionFrequency = sqrtf( axle.suspension.springConstant ) / ( 2.0f * M_PI_F ); // Josh: I don't know why but it looks and feels really wrong without this: // TODO(Josh): Investigate more later, doesn't make much sense. // May be related to mass of wheel or something. - wheelSettings->mSuspensionFrequency *= M_PI_F; + wheelSettings->mSuspensionSpring.mFrequency = sqrtf( axle.suspension.springConstant ) / ( 2.0f * M_PI_F ) * M_PI_F; + wheelSettings->mSuspensionSpring.mDamping = axle.suspension.springDamping; if ( axle.wheels.frictionScale ) { wheelSettings->mLateralFriction.AddPoint( 1.0f, axle.wheels.frictionScale ); diff --git a/vphysics_jolt/vjolt_environment.cpp b/vphysics_jolt/vjolt_environment.cpp index 22aff05..cafdd78 100644 --- a/vphysics_jolt/vjolt_environment.cpp +++ b/vphysics_jolt/vjolt_environment.cpp @@ -53,7 +53,6 @@ static ConVar vjolt_linearcast( "vjolt_linearcast", "1", FCVAR_NONE, "Whether bo static ConVar vjolt_initial_simulation( "vjolt_initial_simulation", "0", FCVAR_NONE, "Whether to pre-settle physics objects on map load." ); static ConVar vjolt_substeps_collision( "vjolt_substeps_collision", "1", FCVAR_NONE, "Number of collision steps to perform.", true, 0.0f, true, 4.0f ); -static ConVar vjolt_substeps_integration( "vjolt_substeps_integration", "1", FCVAR_NONE, "Number of integration substeps to perform.", true, 0.0f, true, 4.0f ); static ConVar vjolt_baumgarte_factor( "vjolt_baumgarte_factor", "0.2", FCVAR_NONE, "Baumgarte stabilization factor (how much of the position error to 'fix' in 1 update). Changing this may help with constraint stability. Requires a map restart to change.", true, 0.0f, true, 1.0f ); @@ -479,9 +478,10 @@ JoltPhysicsSpring::JoltPhysicsSpring( JPH::PhysicsSystem *pPhysicsSystem, JoltPh settings.mMinDistance = m_OnlyStretch ? 0.0f : SourceToJolt::Distance( pParams->naturalLength ); settings.mMaxDistance = SourceToJolt::Distance( pParams->naturalLength ); - settings.mFrequency = GetSpringFrequency( pParams->constant, m_pObjectStart, m_pObjectEnd ); + settings.mLimitsSpringSettings.mMode = JPH::ESpringMode::FrequencyAndDamping; + settings.mLimitsSpringSettings.mFrequency = GetSpringFrequency( pParams->constant, m_pObjectStart, m_pObjectEnd ); // TODO(Josh): The damping values are normally fucking crazy like 5500 from Source... wtf is going on here. - settings.mDamping = 0.0f; + settings.mLimitsSpringSettings.mDamping = 0.0f; m_pConstraint = static_cast< JPH::DistanceConstraint * >( settings.Create( *refBody, *attBody ) ); m_pConstraint->SetEnabled( true ); @@ -522,7 +522,8 @@ void JoltPhysicsSpring::SetSpringConstant( float flSpringConstant ) m_pObjectStart->Wake(); m_pObjectEnd->Wake(); - m_pConstraint->SetFrequency( GetSpringFrequency( flSpringConstant, m_pObjectStart, m_pObjectEnd ) ); + JPH::SpringSettings& springSettings = m_pConstraint->GetLimitsSpringSettings(); + springSettings.mFrequency = GetSpringFrequency( flSpringConstant, m_pObjectStart, m_pObjectEnd ); } void JoltPhysicsSpring::SetSpringDamping( float flSpringDamping ) @@ -774,7 +775,6 @@ void JoltPhysicsEnvironment::Simulate( float deltaTime ) for ( IJoltPhysicsController *pController : m_pPhysicsControllers ) pController->OnPreSimulate( deltaTime ); - const int nIntegrationSubSteps = vjolt_substeps_integration.GetInt(); const int nCollisionSubSteps = vjolt_substeps_collision.GetInt(); // If we haven't already, optimize the broadphase, currently this can only happen once per-environment @@ -793,20 +793,20 @@ void JoltPhysicsEnvironment::Simulate( float deltaTime ) int nIterCount = 0; while ( m_PhysicsSystem.GetNumActiveBodies() && nIterCount < MaxInitialIterations ) { - m_PhysicsSystem.Update( InitialIterationTimescale, 1, InitialSubSteps, tempAllocator, jobSystem ); + m_PhysicsSystem.Update( InitialIterationTimescale, InitialSubSteps, tempAllocator, jobSystem ); nIterCount++; } } else { // Move things around! - m_PhysicsSystem.Update( deltaTime, nCollisionSubSteps, nIntegrationSubSteps, tempAllocator, jobSystem ); + m_PhysicsSystem.Update( deltaTime, nCollisionSubSteps, tempAllocator, jobSystem ); } } else { // Move things around! - m_PhysicsSystem.Update( deltaTime, nCollisionSubSteps, nIntegrationSubSteps, tempAllocator, jobSystem ); + m_PhysicsSystem.Update( deltaTime, nCollisionSubSteps, tempAllocator, jobSystem ); } m_ContactListener.FlushCallbacks(); diff --git a/vphysics_jolt/vjolt_object.cpp b/vphysics_jolt/vjolt_object.cpp index 92e57d1..784e1f0 100644 --- a/vphysics_jolt/vjolt_object.cpp +++ b/vphysics_jolt/vjolt_object.cpp @@ -280,7 +280,7 @@ void JoltPhysicsObject::SetMass( float mass ) JPH::MassProperties massProperties = m_pBody->GetShape()->GetMassProperties(); massProperties.ScaleToMass( mass ); massProperties.mInertia( 3, 3 ) = 1.0f; - pMotionProperties->SetMassProperties( massProperties ); + pMotionProperties->SetMassProperties( JPH::EAllowedDOFs::All, massProperties ); CalculateBuoyancy(); }