mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 08:53:52 +00:00
Do not store a btTransform into Actor class: reduce its size by 128 bytes
This commit is contained in:
parent
d30f0f11b4
commit
62ef708910
2 changed files with 11 additions and 10 deletions
|
@ -147,18 +147,20 @@ void Actor::updateCollisionObjectPosition()
|
|||
{
|
||||
std::scoped_lock lock(mPositionMutex);
|
||||
mShape->setLocalScaling(Misc::Convert::toBullet(mScale));
|
||||
osg::Vec3f scaledTranslation = mRotation * osg::componentMultiply(mMeshTranslation, mScale);
|
||||
osg::Vec3f newPosition = scaledTranslation + mPosition;
|
||||
mLocalTransform.setOrigin(Misc::Convert::toBullet(newPosition));
|
||||
mLocalTransform.setRotation(Misc::Convert::toBullet(mRotation));
|
||||
mCollisionObject->setWorldTransform(mLocalTransform);
|
||||
osg::Vec3f newPosition = getScaledMeshTranslation() + mPosition;
|
||||
|
||||
auto& trans = mCollisionObject->getWorldTransform();
|
||||
trans.setOrigin(Misc::Convert::toBullet(newPosition));
|
||||
trans.setRotation(Misc::Convert::toBullet(mRotation));
|
||||
mCollisionObject->setWorldTransform(trans);
|
||||
|
||||
mWorldPositionChanged = false;
|
||||
}
|
||||
|
||||
osg::Vec3f Actor::getCollisionObjectPosition() const
|
||||
{
|
||||
std::scoped_lock lock(mPositionMutex);
|
||||
return Misc::Convert::toOsg(mLocalTransform.getOrigin());
|
||||
return getScaledMeshTranslation() + mPosition;
|
||||
}
|
||||
|
||||
bool Actor::setPosition(const osg::Vec3f& position)
|
||||
|
|
|
@ -74,9 +74,6 @@ namespace MWPhysics
|
|||
*/
|
||||
osg::Vec3f getOriginalHalfExtents() const;
|
||||
|
||||
/// Returns the mesh translation, scaled and rotated as necessary
|
||||
osg::Vec3f getScaledMeshTranslation() const;
|
||||
|
||||
/**
|
||||
* Returns the position of the collision body
|
||||
* @note The collision shape's origin is in its center, so the position returned can be described as center of the actor collision box in world space.
|
||||
|
@ -181,6 +178,9 @@ namespace MWPhysics
|
|||
void addCollisionMask(int collisionMask);
|
||||
int getCollisionMask() const;
|
||||
|
||||
/// Returns the mesh translation, scaled and rotated as necessary
|
||||
osg::Vec3f getScaledMeshTranslation() const;
|
||||
|
||||
bool mCanWaterWalk;
|
||||
std::atomic<bool> mWalkingOnWater;
|
||||
|
||||
|
@ -205,7 +205,6 @@ namespace MWPhysics
|
|||
bool mWorldPositionChanged;
|
||||
bool mSkipCollisions;
|
||||
bool mSkipSimulation;
|
||||
btTransform mLocalTransform;
|
||||
mutable std::mutex mPositionMutex;
|
||||
|
||||
unsigned int mStuckFrames;
|
||||
|
|
Loading…
Reference in a new issue