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