mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-06 00:55:50 +00:00
Do not store a btTransform into Projectile class: reduce its size by 112 bytes
This commit is contained in:
parent
f02d01ef0c
commit
44f822da56
@ -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…
Reference in New Issue
Block a user