mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-01 11:39:42 +00:00
Initialize PtrHolder::mPtr and positions by its constructor
This commit is contained in:
parent
cd8b20439e
commit
bd98404890
5 changed files with 15 additions and 8 deletions
|
@ -22,7 +22,8 @@ namespace MWPhysics
|
|||
|
||||
Actor::Actor(const MWWorld::Ptr& ptr, const Resource::BulletShape* shape, PhysicsTaskScheduler* scheduler,
|
||||
bool canWaterWalk, DetourNavigator::CollisionShapeType collisionShapeType)
|
||||
: mStandingOnPtr(nullptr), mCanWaterWalk(canWaterWalk), mWalkingOnWater(false)
|
||||
: PtrHolder(ptr, ptr.getRefData().getPosition().asVec3())
|
||||
, mStandingOnPtr(nullptr), mCanWaterWalk(canWaterWalk), mWalkingOnWater(false)
|
||||
, mMeshTranslation(shape->mCollisionBox.mCenter), mOriginalHalfExtents(shape->mCollisionBox.mExtents)
|
||||
, mStuckFrames(0), mLastStuckPosition{0, 0, 0}
|
||||
, mForce(0.f, 0.f, 0.f), mOnGround(true), mOnSlope(false)
|
||||
|
@ -31,8 +32,6 @@ Actor::Actor(const MWWorld::Ptr& ptr, const Resource::BulletShape* shape, Physic
|
|||
, mActive(false)
|
||||
, mTaskScheduler(scheduler)
|
||||
{
|
||||
mPtr = ptr;
|
||||
|
||||
// We can not create actor without collisions - he will fall through the ground.
|
||||
// In this case we should autogenerate collision box based on mesh shape
|
||||
// (NPCs have bodyparts and use a different approach)
|
||||
|
@ -99,7 +98,6 @@ Actor::Actor(const MWWorld::Ptr& ptr, const Resource::BulletShape* shape, Physic
|
|||
if(!mRotationallyInvariant)
|
||||
setRotation(mPtr.getRefData().getBaseNode()->getAttitude());
|
||||
|
||||
updatePosition();
|
||||
addCollisionMask(getCollisionMask());
|
||||
updateCollisionObjectPosition();
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ namespace MWPhysics
|
|||
osg::Vec3f mScale;
|
||||
osg::Vec3f mPositionOffset;
|
||||
bool mWorldPositionChanged;
|
||||
bool mSkipSimulation;
|
||||
bool mSkipSimulation = true;
|
||||
mutable std::mutex mPositionMutex;
|
||||
|
||||
unsigned int mStuckFrames;
|
||||
|
|
|
@ -15,14 +15,14 @@
|
|||
namespace MWPhysics
|
||||
{
|
||||
Object::Object(const MWWorld::Ptr& ptr, osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance, osg::Quat rotation, int collisionType, PhysicsTaskScheduler* scheduler)
|
||||
: mShapeInstance(std::move(shapeInstance))
|
||||
: PtrHolder(ptr, osg::Vec3f())
|
||||
, mShapeInstance(std::move(shapeInstance))
|
||||
, mSolid(true)
|
||||
, mScale(ptr.getCellRef().getScale(), ptr.getCellRef().getScale(), ptr.getCellRef().getScale())
|
||||
, mPosition(ptr.getRefData().getPosition().asVec3())
|
||||
, mRotation(rotation)
|
||||
, mTaskScheduler(scheduler)
|
||||
{
|
||||
mPtr = ptr;
|
||||
mCollisionObject = BulletHelpers::makeCollisionObject(mShapeInstance->mCollisionShape.get(),
|
||||
Misc::Convert::toBullet(mPosition), Misc::Convert::toBullet(rotation));
|
||||
mCollisionObject->setUserPointer(this);
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
namespace MWPhysics
|
||||
{
|
||||
Projectile::Projectile(const MWWorld::Ptr& caster, const osg::Vec3f& position, float radius, PhysicsTaskScheduler* scheduler, PhysicsSystem* physicssystem)
|
||||
: mHitWater(false)
|
||||
: PtrHolder(MWWorld::Ptr(), position)
|
||||
, mHitWater(false)
|
||||
, mActive(true)
|
||||
, mHitTarget(nullptr)
|
||||
, mPhysics(physicssystem)
|
||||
|
|
|
@ -16,6 +16,14 @@ namespace MWPhysics
|
|||
class PtrHolder
|
||||
{
|
||||
public:
|
||||
explicit PtrHolder(const MWWorld::Ptr& ptr, const osg::Vec3f& position)
|
||||
: mPtr(ptr)
|
||||
, mSimulationPosition(position)
|
||||
, mPosition(position)
|
||||
, mPreviousPosition(position)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~PtrHolder() = default;
|
||||
|
||||
void updatePtr(const MWWorld::Ptr& updated)
|
||||
|
|
Loading…
Reference in a new issue