mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-19 22:53:53 +00:00
Revert "Remove physics dependency on basenode"
This reverts commit 165c731492
.
This commit is contained in:
parent
165af1c365
commit
7b727e4d70
46 changed files with 155 additions and 68 deletions
|
@ -38,10 +38,10 @@ namespace MWClass
|
|||
}
|
||||
}
|
||||
|
||||
void Activator::insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const
|
||||
void Activator::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
if(!model.empty())
|
||||
physics.addObject(ptr, model, rotation);
|
||||
physics.addObject(ptr, model);
|
||||
}
|
||||
|
||||
std::string Activator::getModel(const MWWorld::ConstPtr &ptr) const
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace MWClass
|
|||
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const override;
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override;
|
||||
|
||||
std::string getName (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
|
|
@ -17,12 +17,16 @@
|
|||
|
||||
namespace MWClass
|
||||
{
|
||||
Actor::Actor() {}
|
||||
|
||||
Actor::~Actor() {}
|
||||
|
||||
void Actor::adjustPosition(const MWWorld::Ptr& ptr, bool force) const
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->adjustPosition(ptr, force);
|
||||
}
|
||||
|
||||
void Actor::insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const
|
||||
void Actor::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
if (!model.empty())
|
||||
{
|
||||
|
|
|
@ -15,16 +15,16 @@ namespace MWClass
|
|||
{
|
||||
protected:
|
||||
|
||||
Actor() = default;
|
||||
Actor();
|
||||
|
||||
public:
|
||||
~Actor() override = default;
|
||||
virtual ~Actor();
|
||||
|
||||
void adjustPosition(const MWWorld::Ptr& ptr, bool force) const override;
|
||||
///< Adjust position to stand on ground. Must be called post model load
|
||||
/// @param force do this even if the ptr is flying
|
||||
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const override;
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override;
|
||||
|
||||
bool useAnim() const override;
|
||||
|
||||
|
@ -46,8 +46,8 @@ namespace MWClass
|
|||
float getCurrentSpeed(const MWWorld::Ptr& ptr) const override;
|
||||
|
||||
// not implemented
|
||||
Actor(const Actor&) = delete;
|
||||
Actor& operator= (const Actor&) = delete;
|
||||
Actor(const Actor&);
|
||||
Actor& operator= (const Actor&);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,11 @@ namespace MWClass
|
|||
}
|
||||
}
|
||||
|
||||
void Apparatus::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
// TODO: add option somewhere to enable collision for placeable objects
|
||||
}
|
||||
|
||||
std::string Apparatus::getModel(const MWWorld::ConstPtr &ptr) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Apparatus> *ref = ptr.get<ESM::Apparatus>();
|
||||
|
|
|
@ -17,6 +17,8 @@ namespace MWClass
|
|||
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override;
|
||||
|
||||
std::string getName (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
|
|
|
@ -34,6 +34,11 @@ namespace MWClass
|
|||
}
|
||||
}
|
||||
|
||||
void Armor::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
// TODO: add option somewhere to enable collision for placeable objects
|
||||
}
|
||||
|
||||
std::string Armor::getModel(const MWWorld::ConstPtr &ptr) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>();
|
||||
|
|
|
@ -16,6 +16,8 @@ namespace MWClass
|
|||
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override;
|
||||
|
||||
std::string getName (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
|
|
|
@ -22,6 +22,10 @@ namespace MWClass
|
|||
}
|
||||
}
|
||||
|
||||
void BodyPart::insertObject(const MWWorld::Ptr &ptr, const std::string &model, MWPhysics::PhysicsSystem &physics) const
|
||||
{
|
||||
}
|
||||
|
||||
std::string BodyPart::getName(const MWWorld::ConstPtr &ptr) const
|
||||
{
|
||||
return std::string();
|
||||
|
|
|
@ -15,6 +15,8 @@ namespace MWClass
|
|||
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override;
|
||||
|
||||
std::string getName (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
|
|
|
@ -31,6 +31,11 @@ namespace MWClass
|
|||
}
|
||||
}
|
||||
|
||||
void Book::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
// TODO: add option somewhere to enable collision for placeable objects
|
||||
}
|
||||
|
||||
std::string Book::getModel(const MWWorld::ConstPtr &ptr) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Book> *ref = ptr.get<ESM::Book>();
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace MWClass
|
|||
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override;
|
||||
|
||||
std::string getName (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
|
|
|
@ -29,6 +29,11 @@ namespace MWClass
|
|||
}
|
||||
}
|
||||
|
||||
void Clothing::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
// TODO: add option somewhere to enable collision for placeable objects
|
||||
}
|
||||
|
||||
std::string Clothing::getModel(const MWWorld::ConstPtr &ptr) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>();
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace MWClass
|
|||
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override;
|
||||
|
||||
std::string getName (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
|
|
|
@ -111,10 +111,10 @@ namespace MWClass
|
|||
}
|
||||
}
|
||||
|
||||
void Container::insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const
|
||||
void Container::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
if(!model.empty())
|
||||
physics.addObject(ptr, model, rotation);
|
||||
physics.addObject(ptr, model);
|
||||
}
|
||||
|
||||
std::string Container::getModel(const MWWorld::ConstPtr &ptr) const
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace MWClass
|
|||
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const override;
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override;
|
||||
|
||||
std::string getName (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
|
|
@ -62,10 +62,10 @@ namespace MWClass
|
|||
}
|
||||
}
|
||||
|
||||
void Door::insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const
|
||||
void Door::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
if(!model.empty())
|
||||
physics.addObject(ptr, model, rotation, MWPhysics::CollisionType_Door);
|
||||
physics.addObject(ptr, model, MWPhysics::CollisionType_Door);
|
||||
|
||||
// Resume the door's opening/closing animation if it wasn't finished
|
||||
if (ptr.getRefData().getCustomData())
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace MWClass
|
|||
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const override;
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override;
|
||||
|
||||
bool isDoor() const override;
|
||||
|
||||
|
|
|
@ -28,6 +28,11 @@ namespace MWClass
|
|||
}
|
||||
}
|
||||
|
||||
void Ingredient::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
// TODO: add option somewhere to enable collision for placeable objects
|
||||
}
|
||||
|
||||
std::string Ingredient::getModel(const MWWorld::ConstPtr &ptr) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Ingredient> *ref = ptr.get<ESM::Ingredient>();
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace MWClass
|
|||
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override;
|
||||
|
||||
std::string getName (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace MWClass
|
|||
renderingInterface.getObjects().insertModel(ptr, model, true, !(ref->mBase->mData.mFlags & ESM::Light::OffDefault));
|
||||
}
|
||||
|
||||
void Light::insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const
|
||||
void Light::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
MWWorld::LiveCellRef<ESM::Light> *ref =
|
||||
ptr.get<ESM::Light>();
|
||||
|
@ -41,7 +41,7 @@ namespace MWClass
|
|||
|
||||
// TODO: add option somewhere to enable collision for placeable objects
|
||||
if (!model.empty() && (ref->mBase->mData.mFlags & ESM::Light::Carry) == 0)
|
||||
physics.addObject(ptr, model, rotation);
|
||||
physics.addObject(ptr, model);
|
||||
|
||||
if (!ref->mBase->mSound.empty() && !(ref->mBase->mData.mFlags & ESM::Light::OffDefault))
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->mBase->mSound, 1.0, 1.0,
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace MWClass
|
|||
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const override;
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override;
|
||||
|
||||
bool useAnim() const override;
|
||||
|
||||
|
|
|
@ -28,6 +28,11 @@ namespace MWClass
|
|||
}
|
||||
}
|
||||
|
||||
void Lockpick::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
// TODO: add option somewhere to enable collision for placeable objects
|
||||
}
|
||||
|
||||
std::string Lockpick::getModel(const MWWorld::ConstPtr &ptr) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Lockpick> *ref = ptr.get<ESM::Lockpick>();
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace MWClass
|
|||
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override;
|
||||
|
||||
std::string getName (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
|
|
|
@ -37,6 +37,11 @@ namespace MWClass
|
|||
}
|
||||
}
|
||||
|
||||
void Miscellaneous::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
// TODO: add option somewhere to enable collision for placeable objects
|
||||
}
|
||||
|
||||
std::string Miscellaneous::getModel(const MWWorld::ConstPtr &ptr) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>();
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace MWClass
|
|||
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override;
|
||||
|
||||
std::string getName (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
|
|
|
@ -30,6 +30,11 @@ namespace MWClass
|
|||
}
|
||||
}
|
||||
|
||||
void Potion::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
// TODO: add option somewhere to enable collision for placeable objects
|
||||
}
|
||||
|
||||
std::string Potion::getModel(const MWWorld::ConstPtr &ptr) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Potion> *ref = ptr.get<ESM::Potion>();
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace MWClass
|
|||
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override;
|
||||
|
||||
std::string getName (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
|
|
|
@ -28,6 +28,11 @@ namespace MWClass
|
|||
}
|
||||
}
|
||||
|
||||
void Probe::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
// TODO: add option somewhere to enable collision for placeable objects
|
||||
}
|
||||
|
||||
std::string Probe::getModel(const MWWorld::ConstPtr &ptr) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Probe> *ref = ptr.get<ESM::Probe>();
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace MWClass
|
|||
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override;
|
||||
|
||||
std::string getName (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
|
|
|
@ -25,6 +25,11 @@ namespace MWClass
|
|||
}
|
||||
}
|
||||
|
||||
void Repair::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
// TODO: add option somewhere to enable collision for placeable objects
|
||||
}
|
||||
|
||||
std::string Repair::getModel(const MWWorld::ConstPtr &ptr) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Repair> *ref = ptr.get<ESM::Repair>();
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace MWClass
|
|||
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override;
|
||||
|
||||
std::string getName (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
|
|
|
@ -23,10 +23,10 @@ namespace MWClass
|
|||
}
|
||||
}
|
||||
|
||||
void Static::insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const
|
||||
void Static::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
if(!model.empty())
|
||||
physics.addObject(ptr, model, rotation);
|
||||
physics.addObject(ptr, model);
|
||||
}
|
||||
|
||||
std::string Static::getModel(const MWWorld::ConstPtr &ptr) const
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace MWClass
|
|||
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const override;
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override;
|
||||
|
||||
std::string getName (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
|
|
@ -34,6 +34,11 @@ namespace MWClass
|
|||
}
|
||||
}
|
||||
|
||||
void Weapon::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
// TODO: add option somewhere to enable collision for placeable objects
|
||||
}
|
||||
|
||||
std::string Weapon::getModel(const MWWorld::ConstPtr &ptr) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>();
|
||||
|
|
|
@ -15,6 +15,8 @@ namespace MWClass
|
|||
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override;
|
||||
|
||||
std::string getName (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ Actor::Actor(const MWWorld::Ptr& ptr, const Resource::BulletShape* shape, Physic
|
|||
updateScale();
|
||||
|
||||
if(!mRotationallyInvariant)
|
||||
setRotation(mPtr.getRefData().getBaseNode()->getAttitude());
|
||||
updateRotation();
|
||||
|
||||
updatePosition();
|
||||
addCollisionMask(getCollisionMask());
|
||||
|
@ -197,10 +197,10 @@ osg::Vec3f Actor::getPreviousPosition() const
|
|||
return mPreviousPosition;
|
||||
}
|
||||
|
||||
void Actor::setRotation(osg::Quat quat)
|
||||
void Actor::updateRotation ()
|
||||
{
|
||||
std::scoped_lock lock(mPositionMutex);
|
||||
mRotation = quat;
|
||||
mRotation = mPtr.getRefData().getBaseNode()->getAttitude();
|
||||
}
|
||||
|
||||
bool Actor::isRotationallyInvariant() const
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace MWPhysics
|
|||
void enableCollisionBody(bool collision);
|
||||
|
||||
void updateScale();
|
||||
void setRotation(osg::Quat quat);
|
||||
void updateRotation();
|
||||
|
||||
/**
|
||||
* Return true if the collision shape looks the same no matter how its Z rotated.
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
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, int collisionType, PhysicsTaskScheduler* scheduler)
|
||||
: mShapeInstance(shapeInstance)
|
||||
, mSolid(true)
|
||||
, mTaskScheduler(scheduler)
|
||||
|
@ -27,7 +27,7 @@ namespace MWPhysics
|
|||
mCollisionObject->setUserPointer(this);
|
||||
|
||||
setScale(ptr.getCellRef().getScale());
|
||||
setRotation(rotation);
|
||||
setRotation(Misc::Convert::toBullet(ptr.getRefData().getBaseNode()->getAttitude()));
|
||||
setOrigin(Misc::Convert::toBullet(ptr.getRefData().getPosition().asVec3()));
|
||||
commitPositionChange();
|
||||
|
||||
|
@ -51,10 +51,10 @@ namespace MWPhysics
|
|||
mScaleUpdatePending = true;
|
||||
}
|
||||
|
||||
void Object::setRotation(osg::Quat quat)
|
||||
void Object::setRotation(const btQuaternion& quat)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mPositionMutex);
|
||||
mLocalTransform.setRotation(Misc::Convert::toBullet(quat));
|
||||
mLocalTransform.setRotation(quat);
|
||||
mTransformUpdatePending = true;
|
||||
}
|
||||
|
||||
|
@ -116,9 +116,6 @@ namespace MWPhysics
|
|||
if (mShapeInstance->mAnimatedShapes.empty())
|
||||
return false;
|
||||
|
||||
if (mPtr.getRefData().getBaseNode() == nullptr)
|
||||
return true;
|
||||
|
||||
assert (mShapeInstance->getCollisionShape()->isCompound());
|
||||
|
||||
btCompoundShape* compound = static_cast<btCompoundShape*>(mShapeInstance->getCollisionShape());
|
||||
|
|
|
@ -26,12 +26,12 @@ namespace MWPhysics
|
|||
class Object final : public PtrHolder
|
||||
{
|
||||
public:
|
||||
Object(const MWWorld::Ptr& ptr, osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance, osg::Quat rotation, int collisionType, PhysicsTaskScheduler* scheduler);
|
||||
Object(const MWWorld::Ptr& ptr, osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance, int collisionType, PhysicsTaskScheduler* scheduler);
|
||||
~Object() override;
|
||||
|
||||
const Resource::BulletShapeInstance* getShapeInstance() const;
|
||||
void setScale(float scale);
|
||||
void setRotation(osg::Quat quat);
|
||||
void setRotation(const btQuaternion& quat);
|
||||
void setOrigin(const btVector3& vec);
|
||||
void commitPositionChange();
|
||||
btCollisionObject* getCollisionObject();
|
||||
|
|
|
@ -456,13 +456,13 @@ namespace MWPhysics
|
|||
return heightField->second.get();
|
||||
}
|
||||
|
||||
void PhysicsSystem::addObject (const MWWorld::Ptr& ptr, const std::string& mesh, osg::Quat rotation, int collisionType)
|
||||
void PhysicsSystem::addObject (const MWWorld::Ptr& ptr, const std::string& mesh, int collisionType)
|
||||
{
|
||||
osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance = mShapeManager->getInstance(mesh);
|
||||
if (!shapeInstance || !shapeInstance->getCollisionShape())
|
||||
return;
|
||||
|
||||
auto obj = std::make_shared<Object>(ptr, shapeInstance, rotation, collisionType, mTaskScheduler.get());
|
||||
auto obj = std::make_shared<Object>(ptr, shapeInstance, collisionType, mTaskScheduler.get());
|
||||
mObjects.emplace(ptr, obj);
|
||||
|
||||
if (obj->isAnimated())
|
||||
|
@ -621,12 +621,12 @@ namespace MWPhysics
|
|||
mTaskScheduler->updateSingleAabb(foundProjectile->second);
|
||||
}
|
||||
|
||||
void PhysicsSystem::updateRotation(const MWWorld::Ptr &ptr, osg::Quat rotate)
|
||||
void PhysicsSystem::updateRotation(const MWWorld::Ptr &ptr)
|
||||
{
|
||||
ObjectMap::iterator found = mObjects.find(ptr);
|
||||
if (found != mObjects.end())
|
||||
{
|
||||
found->second->setRotation(rotate);
|
||||
found->second->setRotation(Misc::Convert::toBullet(ptr.getRefData().getBaseNode()->getAttitude()));
|
||||
mTaskScheduler->updateSingleAabb(found->second);
|
||||
return;
|
||||
}
|
||||
|
@ -635,7 +635,7 @@ namespace MWPhysics
|
|||
{
|
||||
if (!foundActor->second->isRotationallyInvariant())
|
||||
{
|
||||
foundActor->second->setRotation(rotate);
|
||||
foundActor->second->updateRotation();
|
||||
mTaskScheduler->updateSingleAabb(foundActor->second);
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -121,7 +121,7 @@ namespace MWPhysics
|
|||
void setWaterHeight(float height);
|
||||
void disableWater();
|
||||
|
||||
void addObject (const MWWorld::Ptr& ptr, const std::string& mesh, osg::Quat rotation, int collisionType = CollisionType_World);
|
||||
void addObject (const MWWorld::Ptr& ptr, const std::string& mesh, int collisionType = CollisionType_World);
|
||||
void addActor (const MWWorld::Ptr& ptr, const std::string& mesh);
|
||||
|
||||
int addProjectile(const MWWorld::Ptr& caster, const osg::Vec3f& position, float radius, bool canTraverseWater);
|
||||
|
@ -141,7 +141,7 @@ namespace MWPhysics
|
|||
void remove (const MWWorld::Ptr& ptr);
|
||||
|
||||
void updateScale (const MWWorld::Ptr& ptr);
|
||||
void updateRotation (const MWWorld::Ptr& ptr, osg::Quat rotate);
|
||||
void updateRotation (const MWWorld::Ptr& ptr);
|
||||
void updatePosition (const MWWorld::Ptr& ptr);
|
||||
|
||||
void addHeightField (const float* heights, int x, int y, float triSize, float sqrtVerts, float minH, float maxH, const osg::Object* holdObject);
|
||||
|
|
|
@ -25,12 +25,16 @@ namespace MWWorld
|
|||
{
|
||||
std::map<std::string, std::shared_ptr<Class> > Class::sClasses;
|
||||
|
||||
Class::Class() {}
|
||||
|
||||
Class::~Class() {}
|
||||
|
||||
void Class::insertObjectRendering (const Ptr& ptr, const std::string& mesh, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Class::insertObject(const Ptr& ptr, const std::string& mesh, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const
|
||||
void Class::insertObject(const Ptr& ptr, const std::string& mesh, MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <osg/Quat>
|
||||
#include <osg/Vec4f>
|
||||
|
||||
#include "ptr.hpp"
|
||||
|
@ -58,9 +57,13 @@ namespace MWWorld
|
|||
|
||||
std::string mTypeName;
|
||||
|
||||
// not implemented
|
||||
Class (const Class&);
|
||||
Class& operator= (const Class&);
|
||||
|
||||
protected:
|
||||
|
||||
Class() = default;
|
||||
Class();
|
||||
|
||||
std::shared_ptr<Action> defaultItemActivate(const Ptr &ptr, const Ptr &actor) const;
|
||||
///< Generate default action for activating inventory items
|
||||
|
@ -69,16 +72,14 @@ namespace MWWorld
|
|||
|
||||
public:
|
||||
|
||||
virtual ~Class() = default;
|
||||
Class (const Class&) = delete;
|
||||
Class& operator= (const Class&) = delete;
|
||||
virtual ~Class();
|
||||
|
||||
const std::string& getTypeName() const {
|
||||
return mTypeName;
|
||||
}
|
||||
|
||||
virtual void insertObjectRendering (const Ptr& ptr, const std::string& mesh, MWRender::RenderingInterface& renderingInterface) const;
|
||||
virtual void insertObject(const Ptr& ptr, const std::string& mesh, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const;
|
||||
virtual void insertObject(const Ptr& ptr, const std::string& mesh, MWPhysics::PhysicsSystem& physics) const;
|
||||
///< Add reference into a cell for rendering (default implementation: don't render anything).
|
||||
|
||||
virtual std::string getName (const ConstPtr& ptr) const = 0;
|
||||
|
|
|
@ -75,20 +75,18 @@ namespace
|
|||
* osg::Quat(xr, osg::Vec3(-1, 0, 0));
|
||||
}
|
||||
|
||||
osg::Quat makeNodeRotation(const MWWorld::Ptr& ptr, RotationOrder order)
|
||||
void setNodeRotation(const MWWorld::Ptr& ptr, MWRender::RenderingManager& rendering, RotationOrder order)
|
||||
{
|
||||
const auto pos = ptr.getRefData().getPosition();
|
||||
if (!ptr.getRefData().getBaseNode())
|
||||
return;
|
||||
|
||||
const auto rot = ptr.getClass().isActor() ? makeActorOsgQuat(pos)
|
||||
: (order == RotationOrder::inverse ? makeInversedOrderObjectOsgQuat(pos) : makeObjectOsgQuat(pos));
|
||||
|
||||
return rot;
|
||||
}
|
||||
|
||||
void setNodeRotation(const MWWorld::Ptr& ptr, MWRender::RenderingManager& rendering, osg::Quat rotation)
|
||||
{
|
||||
if (ptr.getRefData().getBaseNode())
|
||||
rendering.rotateObject(ptr, rotation);
|
||||
rendering.rotateObject(ptr,
|
||||
ptr.getClass().isActor()
|
||||
? makeActorOsgQuat(ptr.getRefData().getPosition())
|
||||
: (order == RotationOrder::inverse
|
||||
? makeInversedOrderObjectOsgQuat(ptr.getRefData().getPosition())
|
||||
: makeObjectOsgQuat(ptr.getRefData().getPosition()))
|
||||
);
|
||||
}
|
||||
|
||||
std::string getModel(const MWWorld::Ptr &ptr, const VFS::Manager *vfs)
|
||||
|
@ -119,10 +117,11 @@ namespace
|
|||
const ESM::RefNum& refnum = ptr.getCellRef().getRefNum();
|
||||
if (!refnum.hasContentFile() || pagedRefs.find(refnum) == pagedRefs.end())
|
||||
ptr.getClass().insertObjectRendering(ptr, model, rendering);
|
||||
else
|
||||
ptr.getRefData().setBaseNode(new SceneUtil::PositionAttitudeTransform); // FIXME remove this when physics code is fixed not to depend on basenode
|
||||
setNodeRotation(ptr, rendering, RotationOrder::direct);
|
||||
|
||||
const auto rotation = makeNodeRotation(ptr, RotationOrder::direct);
|
||||
setNodeRotation(ptr, rendering, rotation);
|
||||
ptr.getClass().insertObject (ptr, model, rotation, physics);
|
||||
ptr.getClass().insertObject (ptr, model, physics);
|
||||
|
||||
if (useAnim)
|
||||
MWBase::Environment::get().getMechanicsManager()->add(ptr);
|
||||
|
@ -277,7 +276,7 @@ namespace MWWorld
|
|||
{
|
||||
if (!ptr.getRefData().getBaseNode()) return;
|
||||
ptr.getClass().insertObjectRendering(ptr, getModel(ptr, mRendering.getResourceSystem()->getVFS()), mRendering);
|
||||
setNodeRotation(ptr, mRendering, makeNodeRotation(ptr, RotationOrder::direct));
|
||||
setNodeRotation(ptr, mRendering, RotationOrder::direct);
|
||||
reloadTerrain();
|
||||
}
|
||||
}
|
||||
|
@ -293,9 +292,8 @@ namespace MWWorld
|
|||
|
||||
void Scene::updateObjectRotation(const Ptr &ptr, RotationOrder order)
|
||||
{
|
||||
const auto rot = makeNodeRotation(ptr, order);
|
||||
setNodeRotation(ptr, mRendering, rot);
|
||||
mPhysics->updateRotation(ptr, rot);
|
||||
setNodeRotation(ptr, mRendering, order);
|
||||
mPhysics->updateRotation(ptr);
|
||||
}
|
||||
|
||||
void Scene::updateObjectScale(const Ptr &ptr)
|
||||
|
|
|
@ -1420,7 +1420,7 @@ namespace MWWorld
|
|||
mWorldScene->removeFromPagedRefs(ptr);
|
||||
|
||||
mRendering->rotateObject(ptr, rotate);
|
||||
mPhysics->updateRotation(ptr, rotate);
|
||||
mPhysics->updateRotation(ptr);
|
||||
|
||||
if (const auto object = mPhysics->getObject(ptr))
|
||||
updateNavigatorObject(object);
|
||||
|
|
Loading…
Reference in a new issue