Merge branch 'Joshua-Ashton:main' into main

This commit is contained in:
Bagellll 2022-09-08 21:25:13 -04:00 committed by GitHub
commit 3daee0b97f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 33 additions and 81 deletions

View File

@ -65,6 +65,8 @@ steps:
image: alpine/git
commands:
- cd game
- cp bin/linux64/vphysics.so bin/linux64/vphysics_client.so
- cp bin/linux64/vphysics.so.dbg bin/linux64/vphysics_client.so.dbg
- git add .
- git commit -m "Update binaries as of $DRONE_COMMIT" || true
- git pull --rebase

View File

@ -21,16 +21,3 @@ $Group "jolt"
"vphysics_jolt_sse2"
"vphysics_wrapper_external"
}
$Group "jolt_static"
{
"appframework"
"interfaces"
"tier0_static"
"tier1"
"tier2"
"mathlib"
"joltphysics"
"vphysics_jolt_static"
"vstdlib_static"
}

View File

@ -151,7 +151,7 @@ void JoltPhysicsConstraint::SetLinearMotor( float speed, float maxLinearImpulse
{
case CONSTRAINT_SLIDING:
{
JPH::SliderConstraint *pConstraint = static_cast<JPH::SliderConstraint *>( m_pConstraint );
JPH::SliderConstraint *pConstraint = static_cast<JPH::SliderConstraint *>( m_pConstraint.GetPtr() );
pConstraint->SetMotorState( speed ? JPH::EMotorState::Velocity : JPH::EMotorState::Off );
pConstraint->SetTargetVelocity( speed );
@ -184,7 +184,7 @@ void JoltPhysicsConstraint::SetAngularMotor( float rotSpeed, float maxAngularImp
// :/
VJoltAssert( m_pConstraint->GetSubType() == JPH::EConstraintSubType::SixDOF );
JPH::SixDOFConstraint *pConstraint = static_cast<JPH::SixDOFConstraint *>( m_pConstraint );
JPH::SixDOFConstraint *pConstraint = static_cast<JPH::SixDOFConstraint *>( m_pConstraint.GetPtr() );
pConstraint->SetTargetAngularVelocityCS( JPH::Vec3( rotSpeed, rotSpeed, rotSpeed ) );
pConstraint->SetMaxFriction( JPH::SixDOFConstraint::EAxis::RotationX, maxAngularImpulse );
pConstraint->SetMaxFriction( JPH::SixDOFConstraint::EAxis::RotationY, maxAngularImpulse );
@ -194,7 +194,7 @@ void JoltPhysicsConstraint::SetAngularMotor( float rotSpeed, float maxAngularImp
case CONSTRAINT_HINGE:
{
JPH::HingeConstraint *pConstraint = static_cast<JPH::HingeConstraint *>( m_pConstraint );
JPH::HingeConstraint *pConstraint = static_cast<JPH::HingeConstraint *>( m_pConstraint.GetPtr() );
pConstraint->SetMotorState( rotSpeed ? JPH::EMotorState::Velocity : JPH::EMotorState::Off );
pConstraint->SetTargetAngularVelocity( rotSpeed );
@ -285,12 +285,12 @@ static uint32 GetDegreesOfFreedom( const constraint_ragdollparams_t &ragdoll )
bool JoltPhysicsConstraint::InitialiseHingeFromRagdoll( IPhysicsConstraintGroup* pGroup, const constraint_ragdollparams_t& ragdoll )
{
const uint32 uDOFMask = GetDegreesOfFreedom( ragdoll );
const uint32 uDOFCount = popcnt( uDOFMask );
const uint32 uDOFCount = JPH::CountBits( uDOFMask );
if ( uDOFCount != 1 )
return false;
const uint32 uDOF = tzcnt( uDOFMask );
const uint32 uDOF = JPH::CountTrailingZeros( uDOFMask );
const Vector vecNextDOFAxis = DOFToAxis( NextDOF( uDOF ) );
matrix3x4_t refObjToWorld;
@ -494,7 +494,7 @@ void JoltPhysicsConstraint::InitialiseSliding( IPhysicsConstraintGroup *pGroup,
if ( sliding.velocity )
{
JPH::SliderConstraint *pConstraint = static_cast<JPH::SliderConstraint *>( m_pConstraint );
JPH::SliderConstraint *pConstraint = static_cast<JPH::SliderConstraint *>( m_pConstraint.GetPtr() );
pConstraint->SetMotorState( JPH::EMotorState::Velocity );
pConstraint->SetTargetVelocity( SourceToJolt::Distance( sliding.velocity ) );
}
@ -618,7 +618,6 @@ void JoltPhysicsConstraint::DestroyConstraint()
if ( m_pConstraint )
{
m_pPhysicsSystem->RemoveConstraint( m_pConstraint );
m_pConstraint->Release();
m_pConstraint = nullptr;
}
}

View File

@ -88,14 +88,14 @@ private:
void DestroyConstraint();
JoltPhysicsObject *m_pObjReference = nullptr;
JoltPhysicsObject *m_pObjAttached = nullptr;
JPH::Constraint *m_pConstraint = nullptr;
constraintType_t m_ConstraintType = CONSTRAINT_UNKNOWN;
JoltPhysicsObject *m_pObjReference = nullptr;
JoltPhysicsObject *m_pObjAttached = nullptr;
JPH::Ref< JPH::Constraint > m_pConstraint;
constraintType_t m_ConstraintType = CONSTRAINT_UNKNOWN;
JoltPhysicsConstraintGroup *m_pGroup = nullptr;
JoltPhysicsConstraintGroup *m_pGroup = nullptr;
void *m_pGameData = nullptr;
JoltPhysicsEnvironment *m_pPhysicsEnvironment = nullptr;
JPH::PhysicsSystem *m_pPhysicsSystem = nullptr;
void *m_pGameData = nullptr;
JoltPhysicsEnvironment *m_pPhysicsEnvironment = nullptr;
JPH::PhysicsSystem *m_pPhysicsSystem = nullptr;
};

View File

@ -182,6 +182,8 @@ JoltBPLayerInterfaceImpl JoltPhysicsEnvironment::s_BPLayerInterface;
JoltPhysicsEnvironment::JoltPhysicsEnvironment()
: m_ContactListener( m_PhysicsSystem )
{
m_PerformanceParams.Defaults();
m_PhysicsSystem.Init(
kMaxBodies, kNumBodyMutexes, kMaxBodyPairs, kMaxContactConstraints,
s_BPLayerInterface, JoltBroadPhaseCanCollide, JoltObjectCanCollide );
@ -1176,12 +1178,20 @@ void JoltPhysicsEnvironment::SweepCollideable( const CPhysCollide *pCollide, con
void JoltPhysicsEnvironment::GetPerformanceSettings( physics_performanceparams_t *pOutput ) const
{
Log_Stub( LOG_VJolt );
if ( pOutput )
*pOutput = m_PerformanceParams;
}
void JoltPhysicsEnvironment::SetPerformanceSettings( const physics_performanceparams_t *pSettings )
{
Log_Stub( LOG_VJolt );
if ( pSettings )
{
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 );
}
}
//-------------------------------------------------------------------------------------------------

View File

@ -225,4 +225,6 @@ private:
bool m_EnableConstraintNotify = false;
mutable bool m_bActiveObjectCountFirst = true;
physics_performanceparams_t m_PerformanceParams;
};

View File

@ -552,7 +552,7 @@ private:
{
for ( uint32 thread = m_Mask; thread; thread &= thread - 1 )
{
const uint32 i = tzcnt( thread );
const uint32 i = JPH::CountTrailingZeros( thread );
for ( auto &event : m_Events[ i ] )
func( event );

View File

@ -68,6 +68,8 @@ JoltPhysicsObject::~JoltPhysicsObject()
for ( int i = m_destroyedListeners.Count() - 1; i >= 0; i-- )
m_destroyedListeners[ i ]->OnJoltPhysicsObjectDestroyed( this );
m_pEnvironment->RemoveDirtyStaticBody( GetBodyID() );
JPH::BodyInterface& bodyInterface = m_pPhysicsSystem->GetBodyInterfaceNoLock();
bodyInterface.DestroyBody( GetBodyID() );
}

View File

@ -312,56 +312,6 @@ void ActOnSubShapes( const JPH::Shape *pShape, Func ShapeFunc )
ShapeFunc( static_cast< const ShapeType * >( UndecorateShape( pShape ) ), JPH::Mat44::sIdentity() );
}
inline uint32 popcntStep( uint32 n, uint32 mask, uint32 shift )
{
return ( n & mask ) + ( ( n & ~mask ) >> shift );
}
inline uint32 popcnt( uint32 n )
{
n = popcntStep(n, 0x55555555, 1);
n = popcntStep(n, 0x33333333, 2);
n = popcntStep(n, 0x0F0F0F0F, 4);
n = popcntStep(n, 0x00FF00FF, 8);
n = popcntStep(n, 0x0000FFFF, 16);
return n;
}
inline uint32 tzcnt( uint32 n )
{
#if defined(_MSC_VER) && !defined(__clang__)
return _tzcnt_u32( n );
#elif defined(__BMI__)
return __tzcnt_u32( n );
#elif defined(__GNUC__) || defined(__clang__)
// tzcnt is encoded as rep bsf, so we can use it on all
// processors, but the behaviour of zero inputs differs:
// - bsf: zf = 1, cf = ?, result = ?
// - tzcnt: zf = 0, cf = 1, result = 32
// We'll have to handle this case manually.
uint32 res;
uint32 tmp;
asm (
"tzcnt %2, %0;"
"mov $32, %1;"
"test %2, %2;"
"cmovz %1, %0;"
: "=&r" (res), "=&r" (tmp)
: "r" (n)
: "cc");
return res;
#else
uint32 r = 31;
n &= -n;
r -= ( n & 0x0000FFFF ) ? 16 : 0;
r -= ( n & 0x00FF00FF ) ? 8 : 0;
r -= ( n & 0x0F0F0F0F ) ? 4 : 0;
r -= ( n & 0x33333333 ) ? 2 : 0;
r -= ( n & 0x55555555 ) ? 1 : 0;
return n != 0 ? r : 32;
#endif
}
template< typename T, typename Value >
constexpr void Erase( T &c, const Value &value )
{