@ -357,7 +357,6 @@ namespace MWPhysics
{
{
if ( ! mDeferAabbUpdate | | immediate )
if ( ! mDeferAabbUpdate | | immediate )
{
{
std : : unique_lock lock ( mCollisionWorldMutex ) ;
updatePtrAabb ( ptr ) ;
updatePtrAabb ( ptr ) ;
}
}
else
else
@ -410,7 +409,7 @@ namespace MWPhysics
void PhysicsTaskScheduler : : updateAabbs ( )
void PhysicsTaskScheduler : : updateAabbs ( )
{
{
std : : scoped_lock lock ( m CollisionWorldMutex, m UpdateAabbMutex) ;
std : : scoped_lock lock ( m UpdateAabbMutex) ;
std : : for_each ( mUpdateAabb . begin ( ) , mUpdateAabb . end ( ) ,
std : : for_each ( mUpdateAabb . begin ( ) , mUpdateAabb . end ( ) ,
[ this ] ( const std : : weak_ptr < PtrHolder > & ptr ) { updatePtrAabb ( ptr ) ; } ) ;
[ this ] ( const std : : weak_ptr < PtrHolder > & ptr ) { updatePtrAabb ( ptr ) ; } ) ;
mUpdateAabb . clear ( ) ;
mUpdateAabb . clear ( ) ;
@ -420,6 +419,7 @@ namespace MWPhysics
{
{
if ( const auto p = ptr . lock ( ) )
if ( const auto p = ptr . lock ( ) )
{
{
std : : scoped_lock lock ( mCollisionWorldMutex ) ;
if ( const auto actor = std : : dynamic_pointer_cast < Actor > ( p ) )
if ( const auto actor = std : : dynamic_pointer_cast < Actor > ( p ) )
{
{
actor - > updateCollisionObjectPosition ( ) ;
actor - > updateCollisionObjectPosition ( ) ;
@ -451,9 +451,11 @@ namespace MWPhysics
int job = 0 ;
int job = 0 ;
while ( mRemainingSteps & & ( job = mNextJob . fetch_add ( 1 , std : : memory_order_relaxed ) ) < mNumJobs )
while ( mRemainingSteps & & ( job = mNextJob . fetch_add ( 1 , std : : memory_order_relaxed ) ) < mNumJobs )
{
{
MaybeSharedLock lockColWorld ( mCollisionWorldMutex , mThreadSafeBullet ) ;
if ( const auto actor = mActorsFrameData [ job ] . mActor . lock ( ) )
if ( const auto actor = mActorsFrameData [ job ] . mActor . lock ( ) )
{
MaybeSharedLock lockColWorld ( mCollisionWorldMutex , mThreadSafeBullet ) ;
MovementSolver : : move ( mActorsFrameData [ job ] , mPhysicsDt , mCollisionWorld . get ( ) , * mWorldFrameData ) ;
MovementSolver : : move ( mActorsFrameData [ job ] , mPhysicsDt , mCollisionWorld . get ( ) , * mWorldFrameData ) ;
}
}
}
mPostStepBarrier - > wait ( ) ;
mPostStepBarrier - > wait ( ) ;
@ -478,13 +480,13 @@ namespace MWPhysics
void PhysicsTaskScheduler : : updateActorsPositions ( )
void PhysicsTaskScheduler : : updateActorsPositions ( )
{
{
std : : unique_lock lock ( mCollisionWorldMutex ) ;
for ( auto & actorData : mActorsFrameData )
for ( auto & actorData : mActorsFrameData )
{
{
if ( const auto actor = actorData . mActor . lock ( ) )
if ( const auto actor = actorData . mActor . lock ( ) )
{
{
if ( actor - > setPosition ( actorData . mPosition ) )
if ( actor - > setPosition ( actorData . mPosition ) )
{
{
std : : scoped_lock lock ( mCollisionWorldMutex ) ;
actor - > updateCollisionObjectPosition ( ) ;
actor - > updateCollisionObjectPosition ( ) ;
mCollisionWorld - > updateSingleAabb ( actor - > getCollisionObject ( ) ) ;
mCollisionWorld - > updateSingleAabb ( actor - > getCollisionObject ( ) ) ;
}
}