diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 2e223c918..f78e400d2 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -36,7 +36,7 @@ namespace MWClass MWRender::Rendering rendering (cellRender, ref->ref, ref->mData); cellRender.insertMesh("meshes\\" + model); cellRender.insertActorPhysics(); - ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); + } } diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index e8e9799a2..32f2311b3 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -30,15 +30,14 @@ namespace MWClass } } - void Lockpick::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const + void Lockpick::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const { ESMS::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); - std::string handle = ptr.getRefData().getHandle(); - if(!handle.empty()){ - physics.insertObjectPhysics(handle); + if(ptr.getRefData().getBaseNode()){ + physics.insertObjectPhysics(ptr); } } diff --git a/apps/openmw/mwclass/lockpick.hpp b/apps/openmw/mwclass/lockpick.hpp index 979a3b5ac..074a07c93 100644 --- a/apps/openmw/mwclass/lockpick.hpp +++ b/apps/openmw/mwclass/lockpick.hpp @@ -12,7 +12,7 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index c21ce8a43..39c1bca7a 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -85,10 +85,10 @@ MWRender::Player& RenderingManager::getPlayer(){ void RenderingManager::removeCell (MWWorld::Ptr::CellStore *store){ } -void RenderingManager::addObject (const MWWorld::Ptr& ptr, MWWorld::Ptr::CellStore *store){ +void RenderingManager::addObject (const MWWorld::Ptr& ptr){ } -void RenderingManager::removeObject (const MWWorld::Ptr& ptr, MWWorld::Ptr::CellStore *store){ +void RenderingManager::removeObject (const MWWorld::Ptr& ptr){ } void RenderingManager::moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& position){ diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 16e8e5af4..0508fa54d 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -57,12 +57,14 @@ class RenderingManager: private RenderingInterface { void removeCell (MWWorld::Ptr::CellStore *store); // TODO do we want this? - void addObject (const MWWorld::Ptr& ptr, MWWorld::Ptr::CellStore *store); - void removeObject (const MWWorld::Ptr& ptr, MWWorld::Ptr::CellStore *store); + void addObject (const MWWorld::Ptr& ptr); + void removeObject (const MWWorld::Ptr& ptr); void moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& position); void scaleObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& scale); void rotateObject (const MWWorld::Ptr& ptr, const::Ogre::Quaternion& orientation); + + /// \param store Cell the object was in previously (\a ptr has already been updated to the new cell). void moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::Ptr::CellStore *store); void setPhysicsDebugRendering (bool); diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index a80405e13..b4f93576a 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -25,7 +25,7 @@ namespace MWWorld { } - void Class::insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics) const{ + void Class::insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const{ } diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index 1a2a4f776..706b11aaa 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -64,7 +64,7 @@ namespace MWWorld virtual void insertObjectRendering (const Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; - virtual void insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics) const; + virtual void insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; ///< Add reference into a cell for rendering (default implementation: don't render anything). virtual void enable (const Ptr& ptr, MWWorld::Environment& environment) const; diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 8ef0ca968..6ba4805aa 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -183,15 +183,15 @@ namespace MWWorld throw std::logic_error ("can't find player"); } - void PhysicsSystem::insertObjectPhysics(const std::string& handle){ - Ogre::SceneNode* node = mRender.getScene()->getSceneNode(handle); - addObject (handle, handle, node->getOrientation(), + void PhysicsSystem::insertObjectPhysics(const MWWorld::Ptr& ptr){ + Ogre::SceneNode* node = ptr.getRefData().getBaseNode(); + addObject (node->getName(), node->getName(), node->getOrientation(), node->getScale().x, node->getPosition()); } - void PhysicsSystem::insertActorPhysics(const std::string& handle){ - Ogre::SceneNode* node = mRender.getScene()->getSceneNode(handle); - addActor (handle, handle, node->getPosition()); + void PhysicsSystem::insertActorPhysics(const MWWorld::Ptr& ptr){ + Ogre::SceneNode* node = ptr.getRefData().getBaseNode(); + addActor (node->getName(), node->getName(), node->getPosition()); } } diff --git a/apps/openmw/mwworld/physicssystem.hpp b/apps/openmw/mwworld/physicssystem.hpp index 72f834f6e..8fbcd0521 100644 --- a/apps/openmw/mwworld/physicssystem.hpp +++ b/apps/openmw/mwworld/physicssystem.hpp @@ -34,9 +34,9 @@ namespace MWWorld bool toggleCollisionMode(); std::pair getFacedHandle (MWWorld::World& world); - void insertObjectPhysics(const std::string& handle); + void insertObjectPhysics(const MWWorld::Ptr& ptr); - void insertActorPhysics(const std::string& handle); + void insertActorPhysics(const MWWorld::Ptr& ptr); private: OEngine::Render::OgreRenderer &mRender; diff --git a/apps/openmw/mwworld/refdata.hpp b/apps/openmw/mwworld/refdata.hpp index 062c5942e..6cef9da19 100644 --- a/apps/openmw/mwworld/refdata.hpp +++ b/apps/openmw/mwworld/refdata.hpp @@ -55,6 +55,9 @@ namespace MWWorld { return mBaseNode->getName(); } + Ogre::SceneNode* getBaseNode(){ + return mBaseNode; + } void setBaseNode(Ogre::SceneNode* base){ mBaseNode = base; }