mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 17:59:56 +00:00
Do not lock mutex in MWPhysics::Actor constructor
This commit is contained in:
parent
bd98404890
commit
bceca33699
2 changed files with 18 additions and 4 deletions
|
@ -93,13 +93,13 @@ Actor::Actor(const MWWorld::Ptr& ptr, const Resource::BulletShape* shape, Physic
|
|||
mCollisionObject->setCollisionShape(mShape.get());
|
||||
mCollisionObject->setUserPointer(this);
|
||||
|
||||
updateScale();
|
||||
updateScaleUnsafe();
|
||||
|
||||
if(!mRotationallyInvariant)
|
||||
setRotation(mPtr.getRefData().getBaseNode()->getAttitude());
|
||||
mRotation = mPtr.getRefData().getBaseNode()->getAttitude();
|
||||
|
||||
addCollisionMask(getCollisionMask());
|
||||
updateCollisionObjectPosition();
|
||||
updateCollisionObjectPositionUnsafe();
|
||||
}
|
||||
|
||||
Actor::~Actor()
|
||||
|
@ -167,6 +167,11 @@ osg::Vec3f Actor::getScaledMeshTranslation() const
|
|||
void Actor::updateCollisionObjectPosition()
|
||||
{
|
||||
std::scoped_lock lock(mPositionMutex);
|
||||
updateCollisionObjectPositionUnsafe();
|
||||
}
|
||||
|
||||
void Actor::updateCollisionObjectPositionUnsafe()
|
||||
{
|
||||
mShape->setLocalScaling(Misc::Convert::toBullet(mScale));
|
||||
osg::Vec3f newPosition = getScaledMeshTranslation() + mPosition;
|
||||
|
||||
|
@ -228,6 +233,11 @@ bool Actor::isRotationallyInvariant() const
|
|||
void Actor::updateScale()
|
||||
{
|
||||
std::scoped_lock lock(mPositionMutex);
|
||||
updateScaleUnsafe();
|
||||
}
|
||||
|
||||
void Actor::updateScaleUnsafe()
|
||||
{
|
||||
float scale = mPtr.getCellRef().getScale();
|
||||
osg::Vec3f scaleVec(scale,scale,scale);
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ namespace MWPhysics
|
|||
|
||||
osg::Vec3f mScale;
|
||||
osg::Vec3f mPositionOffset;
|
||||
bool mWorldPositionChanged;
|
||||
bool mWorldPositionChanged = false;
|
||||
bool mSkipSimulation = true;
|
||||
mutable std::mutex mPositionMutex;
|
||||
|
||||
|
@ -207,6 +207,10 @@ namespace MWPhysics
|
|||
|
||||
Actor(const Actor&);
|
||||
Actor& operator=(const Actor&);
|
||||
|
||||
inline void updateScaleUnsafe();
|
||||
|
||||
inline void updateCollisionObjectPositionUnsafe();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue