Merge f394a15406
into 559217d991
This commit is contained in:
commit
a263de67a4
|
@ -334,6 +334,8 @@ IPhysicsObject *JoltPhysicsEnvironment::CreatePolyObject( const CPhysCollide *pC
|
|||
settings.mMassPropertiesOverride.mMass = params.mass;
|
||||
//settings.mMassPropertiesOverride.mInertia = JPH::Mat44::sIdentity() * params.inertia;
|
||||
settings.mOverrideMassProperties = JPH::EOverrideMassProperties::CalculateInertia; // JPH::EOverrideMassProperties::MassAndInertiaProvided;
|
||||
settings.mMaxLinearVelocity = MaxVelocity();
|
||||
settings.mMaxAngularVelocity = MaxAngularVelocity();
|
||||
|
||||
if ( m_bUseLinearCast )
|
||||
settings.mMotionQuality = JPH::EMotionQuality::LinearCast;
|
||||
|
@ -382,6 +384,8 @@ IPhysicsObject *JoltPhysicsEnvironment::CreateSphereObject( float radius, int ma
|
|||
settings.mMassPropertiesOverride.mMass = params.mass;
|
||||
//settings.mMassPropertiesOverride.mInertia = JPH::Mat44::sIdentity() * params.inertia;
|
||||
settings.mOverrideMassProperties = JPH::EOverrideMassProperties::CalculateInertia;//JPH::EOverrideMassProperties::MassAndInertiaProvided;
|
||||
settings.mMaxLinearVelocity = MaxVelocity();
|
||||
settings.mMaxAngularVelocity = MaxAngularVelocity();
|
||||
}
|
||||
|
||||
JPH::BodyInterface &bodyInterface = m_PhysicsSystem.GetBodyInterfaceNoLock();
|
||||
|
@ -1203,16 +1207,74 @@ void JoltPhysicsEnvironment::GetPerformanceSettings( physics_performanceparams_t
|
|||
|
||||
void JoltPhysicsEnvironment::SetPerformanceSettings( const physics_performanceparams_t *pSettings )
|
||||
{
|
||||
if ( pSettings )
|
||||
{
|
||||
m_PerformanceParams = *pSettings;
|
||||
if ( !pSettings )
|
||||
return;
|
||||
|
||||
// Normalize these values to match VPhysics behaviour.
|
||||
m_PerformanceParams.minFrictionMass = Clamp( m_PerformanceParams.minFrictionMass, 1.0f, VPHYSICS_MAX_MASS );
|
||||
m_PerformanceParams.maxFrictionMass = Clamp( m_PerformanceParams.maxFrictionMass, 1.0f, VPHYSICS_MAX_MASS );
|
||||
m_PerformanceParams = *pSettings;
|
||||
|
||||
// Normalize these values to match VPhysics behaviour.
|
||||
m_PerformanceParams.minFrictionMass = Clamp( m_PerformanceParams.minFrictionMass, 1.0f, VPHYSICS_MAX_MASS );
|
||||
m_PerformanceParams.maxFrictionMass = Clamp( m_PerformanceParams.maxFrictionMass, 1.0f, VPHYSICS_MAX_MASS );
|
||||
|
||||
m_PhysicsSystem.GetBodies(m_CachedBodies);
|
||||
|
||||
for ( auto& id : m_CachedBodies )
|
||||
{
|
||||
JPH::Body* pBody = m_PhysicsSystem.GetBodyLockInterfaceNoLock().TryGetBody( id );
|
||||
|
||||
if ( pBody )
|
||||
{
|
||||
JPH::MotionProperties* pMotionProperties = pBody->GetMotionProperties();
|
||||
|
||||
if ( pMotionProperties )
|
||||
{
|
||||
pMotionProperties->SetMaxLinearVelocity( pSettings->maxVelocity );
|
||||
pMotionProperties->SetMaxAngularVelocity( pSettings->maxAngularVelocity * M_PI_F / 180 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline int JoltPhysicsEnvironment::MaxCollisionsPerObjectPerTimestep() const
|
||||
{
|
||||
return m_PerformanceParams.maxCollisionsPerObjectPerTimestep;
|
||||
}
|
||||
|
||||
inline int JoltPhysicsEnvironment::MaxCollisionChecksPerTimestep() const
|
||||
{
|
||||
return m_PerformanceParams.maxCollisionChecksPerTimestep;
|
||||
}
|
||||
|
||||
inline float JoltPhysicsEnvironment::MaxVelocity() const
|
||||
{
|
||||
return m_PerformanceParams.maxVelocity;
|
||||
}
|
||||
|
||||
inline float JoltPhysicsEnvironment::MaxAngularVelocity() const
|
||||
{
|
||||
return m_PerformanceParams.maxAngularVelocity;
|
||||
}
|
||||
|
||||
inline float JoltPhysicsEnvironment::LookAheadTimeObjectsVsWorld() const
|
||||
{
|
||||
return m_PerformanceParams.lookAheadTimeObjectsVsWorld;
|
||||
}
|
||||
|
||||
inline float JoltPhysicsEnvironment::LookAheadTimeObjectsVsObject() const
|
||||
{
|
||||
return m_PerformanceParams.lookAheadTimeObjectsVsObject;
|
||||
}
|
||||
|
||||
inline float JoltPhysicsEnvironment::MinFrictionMass() const
|
||||
{
|
||||
return m_PerformanceParams.minFrictionMass;
|
||||
}
|
||||
|
||||
inline float JoltPhysicsEnvironment::MaxFrictionMass() const
|
||||
{
|
||||
return m_PerformanceParams.maxFrictionMass;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
||||
void JoltPhysicsEnvironment::ReadStats( physics_stats_t *pOutput )
|
||||
|
|
|
@ -130,6 +130,17 @@ public:
|
|||
void GetPerformanceSettings( physics_performanceparams_t* pOutput ) const override;
|
||||
void SetPerformanceSettings( const physics_performanceparams_t* pSettings ) override;
|
||||
|
||||
// physics params related
|
||||
inline float MaxVelocity() const;
|
||||
inline float MaxAngularVelocity() const;
|
||||
// most likely will go unused
|
||||
inline int MaxCollisionsPerObjectPerTimestep() const;
|
||||
inline int MaxCollisionChecksPerTimestep() const;
|
||||
inline float LookAheadTimeObjectsVsWorld() const;
|
||||
inline float LookAheadTimeObjectsVsObject() const;
|
||||
inline float MinFrictionMass() const;
|
||||
inline float MaxFrictionMass() const;
|
||||
|
||||
void ReadStats( physics_stats_t* pOutput ) override;
|
||||
void ClearStats() override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue