Do not store a btTransform into Projectile class: reduce its size by 112 bytes

pull/593/head
fredzio 4 years ago
parent 20aefb5f5f
commit 744cfc6a51

@ -3,14 +3,11 @@
#include <BulletCollision/CollisionShapes/btSphereShape.h>
#include <BulletCollision/CollisionDispatch/btCollisionWorld.h>
#include <LinearMath/btVector3.h>
#include <components/misc/convert.hpp>
#include "../mwworld/class.hpp"
#include "collisiontype.hpp"
#include "memory"
#include "mtphysics.hpp"
#include "projectile.hpp"
@ -55,7 +52,9 @@ void Projectile::commitPositionChange()
std::scoped_lock lock(mMutex);
if (mTransformUpdatePending)
{
mCollisionObject->setWorldTransform(mLocalTransform);
auto& trans = mCollisionObject->getWorldTransform();
trans.setOrigin(Misc::Convert::toBullet(mPosition));
mCollisionObject->setWorldTransform(trans);
mTransformUpdatePending = false;
}
}
@ -63,14 +62,14 @@ void Projectile::commitPositionChange()
void Projectile::setPosition(const osg::Vec3f &position)
{
std::scoped_lock lock(mMutex);
mLocalTransform.setOrigin(Misc::Convert::toBullet(position));
mPosition = position;
mTransformUpdatePending = true;
}
osg::Vec3f Projectile::getPosition() const
{
std::scoped_lock lock(mMutex);
return Misc::Convert::toOsg(mLocalTransform.getOrigin());
return mPosition;
}
bool Projectile::canTraverseWater() const

@ -6,12 +6,13 @@
#include <mutex>
#include <optional>
#include <LinearMath/btVector3.h>
#include "ptrholder.hpp"
class btCollisionObject;
class btCollisionShape;
class btConvexShape;
class btVector3;
namespace osg
{
@ -76,7 +77,6 @@ namespace MWPhysics
btConvexShape* mConvexShape;
std::unique_ptr<btCollisionObject> mCollisionObject;
btTransform mLocalTransform;
bool mTransformUpdatePending;
bool mCanCrossWaterSurface;
bool mCrossedWaterSurface;
@ -84,6 +84,7 @@ namespace MWPhysics
MWWorld::Ptr mCaster;
MWWorld::Ptr mHitTarget;
std::optional<btVector3> mWaterHitPosition;
osg::Vec3f mPosition;
btVector3 mHitPosition;
btVector3 mHitNormal;

Loading…
Cancel
Save