Remove physics dependency on basenode

Necessary to be able to load physics objects from inactive cells.
pull/3044/head
fredzio 4 years ago
parent 49c828c138
commit 165c731492

@ -38,10 +38,10 @@ namespace MWClass
} }
} }
void Activator::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const void Activator::insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const
{ {
if(!model.empty()) if(!model.empty())
physics.addObject(ptr, model); physics.addObject(ptr, model, rotation);
} }
std::string Activator::getModel(const MWWorld::ConstPtr &ptr) const 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; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override; void insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const override;
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string getName (const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.

@ -17,16 +17,12 @@
namespace MWClass namespace MWClass
{ {
Actor::Actor() {}
Actor::~Actor() {}
void Actor::adjustPosition(const MWWorld::Ptr& ptr, bool force) const void Actor::adjustPosition(const MWWorld::Ptr& ptr, bool force) const
{ {
MWBase::Environment::get().getWorld()->adjustPosition(ptr, force); MWBase::Environment::get().getWorld()->adjustPosition(ptr, force);
} }
void Actor::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const void Actor::insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const
{ {
if (!model.empty()) if (!model.empty())
{ {

@ -15,16 +15,16 @@ namespace MWClass
{ {
protected: protected:
Actor(); Actor() = default;
public: public:
virtual ~Actor(); ~Actor() override = default;
void adjustPosition(const MWWorld::Ptr& ptr, bool force) const override; void adjustPosition(const MWWorld::Ptr& ptr, bool force) const override;
///< Adjust position to stand on ground. Must be called post model load ///< Adjust position to stand on ground. Must be called post model load
/// @param force do this even if the ptr is flying /// @param force do this even if the ptr is flying
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override; void insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const override;
bool useAnim() const override; bool useAnim() const override;
@ -46,8 +46,8 @@ namespace MWClass
float getCurrentSpeed(const MWWorld::Ptr& ptr) const override; float getCurrentSpeed(const MWWorld::Ptr& ptr) const override;
// not implemented // not implemented
Actor(const Actor&); Actor(const Actor&) = delete;
Actor& operator= (const Actor&); Actor& operator= (const Actor&) = delete;
}; };
} }

@ -26,11 +26,6 @@ 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 std::string Apparatus::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Apparatus> *ref = ptr.get<ESM::Apparatus>(); const MWWorld::LiveCellRef<ESM::Apparatus> *ref = ptr.get<ESM::Apparatus>();

@ -17,8 +17,6 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< 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; std::string getName (const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.

@ -34,11 +34,6 @@ 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 std::string Armor::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>(); const MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>();

@ -16,8 +16,6 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< 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; std::string getName (const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.

@ -22,10 +22,6 @@ 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 std::string BodyPart::getName(const MWWorld::ConstPtr &ptr) const
{ {
return std::string(); return std::string();

@ -15,8 +15,6 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< 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; std::string getName (const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.

@ -31,11 +31,6 @@ 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 std::string Book::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Book> *ref = ptr.get<ESM::Book>(); const MWWorld::LiveCellRef<ESM::Book> *ref = ptr.get<ESM::Book>();

@ -14,8 +14,6 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< 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; std::string getName (const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.

@ -29,11 +29,6 @@ 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 std::string Clothing::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>(); const MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>();

@ -14,8 +14,6 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< 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; std::string getName (const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \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, MWPhysics::PhysicsSystem& physics) const void Container::insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const
{ {
if(!model.empty()) if(!model.empty())
physics.addObject(ptr, model); physics.addObject(ptr, model, rotation);
} }
std::string Container::getModel(const MWWorld::ConstPtr &ptr) const 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; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override; void insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const override;
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string getName (const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \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, MWPhysics::PhysicsSystem& physics) const void Door::insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const
{ {
if(!model.empty()) if(!model.empty())
physics.addObject(ptr, model, MWPhysics::CollisionType_Door); physics.addObject(ptr, model, rotation, MWPhysics::CollisionType_Door);
// Resume the door's opening/closing animation if it wasn't finished // Resume the door's opening/closing animation if it wasn't finished
if (ptr.getRefData().getCustomData()) 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; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override; void insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const override;
bool isDoor() const override; bool isDoor() const override;

@ -28,11 +28,6 @@ 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 std::string Ingredient::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Ingredient> *ref = ptr.get<ESM::Ingredient>(); const MWWorld::LiveCellRef<ESM::Ingredient> *ref = ptr.get<ESM::Ingredient>();

@ -14,8 +14,6 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< 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; std::string getName (const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \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)); renderingInterface.getObjects().insertModel(ptr, model, true, !(ref->mBase->mData.mFlags & ESM::Light::OffDefault));
} }
void Light::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const void Light::insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const
{ {
MWWorld::LiveCellRef<ESM::Light> *ref = MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>(); ptr.get<ESM::Light>();
@ -41,7 +41,7 @@ namespace MWClass
// TODO: add option somewhere to enable collision for placeable objects // TODO: add option somewhere to enable collision for placeable objects
if (!model.empty() && (ref->mBase->mData.mFlags & ESM::Light::Carry) == 0) if (!model.empty() && (ref->mBase->mData.mFlags & ESM::Light::Carry) == 0)
physics.addObject(ptr, model); physics.addObject(ptr, model, rotation);
if (!ref->mBase->mSound.empty() && !(ref->mBase->mData.mFlags & ESM::Light::OffDefault)) 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, 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; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override; void insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const override;
bool useAnim() const override; bool useAnim() const override;

@ -28,11 +28,6 @@ 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 std::string Lockpick::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Lockpick> *ref = ptr.get<ESM::Lockpick>(); const MWWorld::LiveCellRef<ESM::Lockpick> *ref = ptr.get<ESM::Lockpick>();

@ -14,8 +14,6 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< 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; std::string getName (const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.

@ -37,11 +37,6 @@ 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 std::string Miscellaneous::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>(); const MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>();

@ -14,8 +14,6 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< 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; std::string getName (const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.

@ -30,11 +30,6 @@ 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 std::string Potion::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Potion> *ref = ptr.get<ESM::Potion>(); const MWWorld::LiveCellRef<ESM::Potion> *ref = ptr.get<ESM::Potion>();

@ -14,8 +14,6 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< 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; std::string getName (const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.

@ -28,11 +28,6 @@ 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 std::string Probe::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Probe> *ref = ptr.get<ESM::Probe>(); const MWWorld::LiveCellRef<ESM::Probe> *ref = ptr.get<ESM::Probe>();

@ -14,8 +14,6 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< 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; std::string getName (const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.

@ -25,11 +25,6 @@ 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 std::string Repair::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Repair> *ref = ptr.get<ESM::Repair>(); const MWWorld::LiveCellRef<ESM::Repair> *ref = ptr.get<ESM::Repair>();

@ -14,8 +14,6 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< 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; std::string getName (const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \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, MWPhysics::PhysicsSystem& physics) const void Static::insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const
{ {
if(!model.empty()) if(!model.empty())
physics.addObject(ptr, model); physics.addObject(ptr, model, rotation);
} }
std::string Static::getModel(const MWWorld::ConstPtr &ptr) const 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; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const override; void insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const override;
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string getName (const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.

@ -34,11 +34,6 @@ 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 std::string Weapon::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>(); const MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>();

@ -15,8 +15,6 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< 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; std::string getName (const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \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(); updateScale();
if(!mRotationallyInvariant) if(!mRotationallyInvariant)
updateRotation(); setRotation(mPtr.getRefData().getBaseNode()->getAttitude());
updatePosition(); updatePosition();
addCollisionMask(getCollisionMask()); addCollisionMask(getCollisionMask());
@ -197,10 +197,10 @@ osg::Vec3f Actor::getPreviousPosition() const
return mPreviousPosition; return mPreviousPosition;
} }
void Actor::updateRotation () void Actor::setRotation(osg::Quat quat)
{ {
std::scoped_lock lock(mPositionMutex); std::scoped_lock lock(mPositionMutex);
mRotation = mPtr.getRefData().getBaseNode()->getAttitude(); mRotation = quat;
} }
bool Actor::isRotationallyInvariant() const bool Actor::isRotationallyInvariant() const

@ -49,7 +49,7 @@ namespace MWPhysics
void enableCollisionBody(bool collision); void enableCollisionBody(bool collision);
void updateScale(); void updateScale();
void updateRotation(); void setRotation(osg::Quat quat);
/** /**
* Return true if the collision shape looks the same no matter how its Z rotated. * Return true if the collision shape looks the same no matter how its Z rotated.

@ -14,7 +14,7 @@
namespace MWPhysics namespace MWPhysics
{ {
Object::Object(const MWWorld::Ptr& ptr, osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance, int collisionType, PhysicsTaskScheduler* scheduler) Object::Object(const MWWorld::Ptr& ptr, osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance, osg::Quat rotation, int collisionType, PhysicsTaskScheduler* scheduler)
: mShapeInstance(shapeInstance) : mShapeInstance(shapeInstance)
, mSolid(true) , mSolid(true)
, mTaskScheduler(scheduler) , mTaskScheduler(scheduler)
@ -27,7 +27,7 @@ namespace MWPhysics
mCollisionObject->setUserPointer(this); mCollisionObject->setUserPointer(this);
setScale(ptr.getCellRef().getScale()); setScale(ptr.getCellRef().getScale());
setRotation(Misc::Convert::toBullet(ptr.getRefData().getBaseNode()->getAttitude())); setRotation(rotation);
setOrigin(Misc::Convert::toBullet(ptr.getRefData().getPosition().asVec3())); setOrigin(Misc::Convert::toBullet(ptr.getRefData().getPosition().asVec3()));
commitPositionChange(); commitPositionChange();
@ -51,10 +51,10 @@ namespace MWPhysics
mScaleUpdatePending = true; mScaleUpdatePending = true;
} }
void Object::setRotation(const btQuaternion& quat) void Object::setRotation(osg::Quat quat)
{ {
std::unique_lock<std::mutex> lock(mPositionMutex); std::unique_lock<std::mutex> lock(mPositionMutex);
mLocalTransform.setRotation(quat); mLocalTransform.setRotation(Misc::Convert::toBullet(quat));
mTransformUpdatePending = true; mTransformUpdatePending = true;
} }
@ -116,6 +116,9 @@ namespace MWPhysics
if (mShapeInstance->mAnimatedShapes.empty()) if (mShapeInstance->mAnimatedShapes.empty())
return false; return false;
if (mPtr.getRefData().getBaseNode() == nullptr)
return true;
assert (mShapeInstance->getCollisionShape()->isCompound()); assert (mShapeInstance->getCollisionShape()->isCompound());
btCompoundShape* compound = static_cast<btCompoundShape*>(mShapeInstance->getCollisionShape()); btCompoundShape* compound = static_cast<btCompoundShape*>(mShapeInstance->getCollisionShape());

@ -26,12 +26,12 @@ namespace MWPhysics
class Object final : public PtrHolder class Object final : public PtrHolder
{ {
public: public:
Object(const MWWorld::Ptr& ptr, osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance, int collisionType, PhysicsTaskScheduler* scheduler); Object(const MWWorld::Ptr& ptr, osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance, osg::Quat rotation, int collisionType, PhysicsTaskScheduler* scheduler);
~Object() override; ~Object() override;
const Resource::BulletShapeInstance* getShapeInstance() const; const Resource::BulletShapeInstance* getShapeInstance() const;
void setScale(float scale); void setScale(float scale);
void setRotation(const btQuaternion& quat); void setRotation(osg::Quat quat);
void setOrigin(const btVector3& vec); void setOrigin(const btVector3& vec);
void commitPositionChange(); void commitPositionChange();
btCollisionObject* getCollisionObject(); btCollisionObject* getCollisionObject();

@ -456,13 +456,13 @@ namespace MWPhysics
return heightField->second.get(); return heightField->second.get();
} }
void PhysicsSystem::addObject (const MWWorld::Ptr& ptr, const std::string& mesh, int collisionType) void PhysicsSystem::addObject (const MWWorld::Ptr& ptr, const std::string& mesh, osg::Quat rotation, int collisionType)
{ {
osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance = mShapeManager->getInstance(mesh); osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance = mShapeManager->getInstance(mesh);
if (!shapeInstance || !shapeInstance->getCollisionShape()) if (!shapeInstance || !shapeInstance->getCollisionShape())
return; return;
auto obj = std::make_shared<Object>(ptr, shapeInstance, collisionType, mTaskScheduler.get()); auto obj = std::make_shared<Object>(ptr, shapeInstance, rotation, collisionType, mTaskScheduler.get());
mObjects.emplace(ptr, obj); mObjects.emplace(ptr, obj);
if (obj->isAnimated()) if (obj->isAnimated())
@ -621,12 +621,12 @@ namespace MWPhysics
mTaskScheduler->updateSingleAabb(foundProjectile->second); mTaskScheduler->updateSingleAabb(foundProjectile->second);
} }
void PhysicsSystem::updateRotation(const MWWorld::Ptr &ptr) void PhysicsSystem::updateRotation(const MWWorld::Ptr &ptr, osg::Quat rotate)
{ {
ObjectMap::iterator found = mObjects.find(ptr); ObjectMap::iterator found = mObjects.find(ptr);
if (found != mObjects.end()) if (found != mObjects.end())
{ {
found->second->setRotation(Misc::Convert::toBullet(ptr.getRefData().getBaseNode()->getAttitude())); found->second->setRotation(rotate);
mTaskScheduler->updateSingleAabb(found->second); mTaskScheduler->updateSingleAabb(found->second);
return; return;
} }
@ -635,7 +635,7 @@ namespace MWPhysics
{ {
if (!foundActor->second->isRotationallyInvariant()) if (!foundActor->second->isRotationallyInvariant())
{ {
foundActor->second->updateRotation(); foundActor->second->setRotation(rotate);
mTaskScheduler->updateSingleAabb(foundActor->second); mTaskScheduler->updateSingleAabb(foundActor->second);
} }
return; return;

@ -121,7 +121,7 @@ namespace MWPhysics
void setWaterHeight(float height); void setWaterHeight(float height);
void disableWater(); void disableWater();
void addObject (const MWWorld::Ptr& ptr, const std::string& mesh, int collisionType = CollisionType_World); void addObject (const MWWorld::Ptr& ptr, const std::string& mesh, osg::Quat rotation, int collisionType = CollisionType_World);
void addActor (const MWWorld::Ptr& ptr, const std::string& mesh); void addActor (const MWWorld::Ptr& ptr, const std::string& mesh);
int addProjectile(const MWWorld::Ptr& caster, const osg::Vec3f& position, float radius, bool canTraverseWater); 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 remove (const MWWorld::Ptr& ptr);
void updateScale (const MWWorld::Ptr& ptr); void updateScale (const MWWorld::Ptr& ptr);
void updateRotation (const MWWorld::Ptr& ptr); void updateRotation (const MWWorld::Ptr& ptr, osg::Quat rotate);
void updatePosition (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); void addHeightField (const float* heights, int x, int y, float triSize, float sqrtVerts, float minH, float maxH, const osg::Object* holdObject);

@ -25,16 +25,12 @@ namespace MWWorld
{ {
std::map<std::string, std::shared_ptr<Class> > Class::sClasses; 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::insertObjectRendering (const Ptr& ptr, const std::string& mesh, MWRender::RenderingInterface& renderingInterface) const
{ {
} }
void Class::insertObject(const Ptr& ptr, const std::string& mesh, MWPhysics::PhysicsSystem& physics) const void Class::insertObject(const Ptr& ptr, const std::string& mesh, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const
{ {
} }

@ -6,6 +6,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <osg/Quat>
#include <osg/Vec4f> #include <osg/Vec4f>
#include "ptr.hpp" #include "ptr.hpp"
@ -57,13 +58,9 @@ namespace MWWorld
std::string mTypeName; std::string mTypeName;
// not implemented
Class (const Class&);
Class& operator= (const Class&);
protected: protected:
Class(); Class() = default;
std::shared_ptr<Action> defaultItemActivate(const Ptr &ptr, const Ptr &actor) const; std::shared_ptr<Action> defaultItemActivate(const Ptr &ptr, const Ptr &actor) const;
///< Generate default action for activating inventory items ///< Generate default action for activating inventory items
@ -72,14 +69,16 @@ namespace MWWorld
public: public:
virtual ~Class(); virtual ~Class() = default;
Class (const Class&) = delete;
Class& operator= (const Class&) = delete;
const std::string& getTypeName() const { const std::string& getTypeName() const {
return mTypeName; return mTypeName;
} }
virtual void insertObjectRendering (const Ptr& ptr, const std::string& mesh, MWRender::RenderingInterface& renderingInterface) const; virtual void insertObjectRendering (const Ptr& ptr, const std::string& mesh, MWRender::RenderingInterface& renderingInterface) const;
virtual void insertObject(const Ptr& ptr, const std::string& mesh, MWPhysics::PhysicsSystem& physics) const; virtual void insertObject(const Ptr& ptr, const std::string& mesh, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const;
///< Add reference into a cell for rendering (default implementation: don't render anything). ///< Add reference into a cell for rendering (default implementation: don't render anything).
virtual std::string getName (const ConstPtr& ptr) const = 0; virtual std::string getName (const ConstPtr& ptr) const = 0;

@ -75,18 +75,20 @@ namespace
* osg::Quat(xr, osg::Vec3(-1, 0, 0)); * osg::Quat(xr, osg::Vec3(-1, 0, 0));
} }
void setNodeRotation(const MWWorld::Ptr& ptr, MWRender::RenderingManager& rendering, RotationOrder order) osg::Quat makeNodeRotation(const MWWorld::Ptr& ptr, RotationOrder order)
{ {
if (!ptr.getRefData().getBaseNode()) const auto pos = ptr.getRefData().getPosition();
return;
const auto rot = ptr.getClass().isActor() ? makeActorOsgQuat(pos)
: (order == RotationOrder::inverse ? makeInversedOrderObjectOsgQuat(pos) : makeObjectOsgQuat(pos));
return rot;
}
rendering.rotateObject(ptr, void setNodeRotation(const MWWorld::Ptr& ptr, MWRender::RenderingManager& rendering, osg::Quat rotation)
ptr.getClass().isActor() {
? makeActorOsgQuat(ptr.getRefData().getPosition()) if (ptr.getRefData().getBaseNode())
: (order == RotationOrder::inverse rendering.rotateObject(ptr, rotation);
? makeInversedOrderObjectOsgQuat(ptr.getRefData().getPosition())
: makeObjectOsgQuat(ptr.getRefData().getPosition()))
);
} }
std::string getModel(const MWWorld::Ptr &ptr, const VFS::Manager *vfs) std::string getModel(const MWWorld::Ptr &ptr, const VFS::Manager *vfs)
@ -117,11 +119,10 @@ namespace
const ESM::RefNum& refnum = ptr.getCellRef().getRefNum(); const ESM::RefNum& refnum = ptr.getCellRef().getRefNum();
if (!refnum.hasContentFile() || pagedRefs.find(refnum) == pagedRefs.end()) if (!refnum.hasContentFile() || pagedRefs.find(refnum) == pagedRefs.end())
ptr.getClass().insertObjectRendering(ptr, model, rendering); 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);
ptr.getClass().insertObject (ptr, model, physics); const auto rotation = makeNodeRotation(ptr, RotationOrder::direct);
setNodeRotation(ptr, rendering, rotation);
ptr.getClass().insertObject (ptr, model, rotation, physics);
if (useAnim) if (useAnim)
MWBase::Environment::get().getMechanicsManager()->add(ptr); MWBase::Environment::get().getMechanicsManager()->add(ptr);
@ -276,7 +277,7 @@ namespace MWWorld
{ {
if (!ptr.getRefData().getBaseNode()) return; if (!ptr.getRefData().getBaseNode()) return;
ptr.getClass().insertObjectRendering(ptr, getModel(ptr, mRendering.getResourceSystem()->getVFS()), mRendering); ptr.getClass().insertObjectRendering(ptr, getModel(ptr, mRendering.getResourceSystem()->getVFS()), mRendering);
setNodeRotation(ptr, mRendering, RotationOrder::direct); setNodeRotation(ptr, mRendering, makeNodeRotation(ptr, RotationOrder::direct));
reloadTerrain(); reloadTerrain();
} }
} }
@ -292,8 +293,9 @@ namespace MWWorld
void Scene::updateObjectRotation(const Ptr &ptr, RotationOrder order) void Scene::updateObjectRotation(const Ptr &ptr, RotationOrder order)
{ {
setNodeRotation(ptr, mRendering, order); const auto rot = makeNodeRotation(ptr, order);
mPhysics->updateRotation(ptr); setNodeRotation(ptr, mRendering, rot);
mPhysics->updateRotation(ptr, rot);
} }
void Scene::updateObjectScale(const Ptr &ptr) void Scene::updateObjectScale(const Ptr &ptr)

@ -1407,7 +1407,7 @@ namespace MWWorld
mWorldScene->removeFromPagedRefs(ptr); mWorldScene->removeFromPagedRefs(ptr);
mRendering->rotateObject(ptr, rotate); mRendering->rotateObject(ptr, rotate);
mPhysics->updateRotation(ptr); mPhysics->updateRotation(ptr, rotate);
if (const auto object = mPhysics->getObject(ptr)) if (const auto object = mPhysics->getObject(ptr))
updateNavigatorObject(object); updateNavigatorObject(object);

Loading…
Cancel
Save