From 042bceb54771260e81c532fa6ca90869b08d9cdc Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Wed, 9 Nov 2011 18:06:55 -0500 Subject: [PATCH] Changes to insertObjectRendering; Proposed insertObject --- apps/openmw/mwclass/lockpick.cpp | 18 +++++++++++++++++- apps/openmw/mwclass/lockpick.hpp | 2 ++ apps/openmw/mwworld/class.cpp | 3 +++ apps/openmw/mwworld/class.hpp | 2 ++ apps/openmw/mwworld/physicssystem.cpp | 11 +++++++++++ apps/openmw/mwworld/physicssystem.hpp | 4 ++++ 6 files changed, 39 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index 1296a4144..e8e9799a2 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -21,13 +21,29 @@ namespace MWClass assert (ref->base != NULL); const std::string &model = ref->base->model; - MWRender::Objects objects = renderingInterface.getObjects(); + if (!model.empty()) { + MWRender::Objects objects = renderingInterface.getObjects(); + objects.insertBegin(ptr, true, false); objects.insertMesh(ptr, "meshes\\" + model); } } + void Lockpick::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + std::string handle = ptr.getRefData().getHandle(); + if(!handle.empty()){ + physics.insertObjectPhysics(handle); + } + + } + + std::string Lockpick::getName (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/lockpick.hpp b/apps/openmw/mwclass/lockpick.hpp index 9b02dce7f..979a3b5ac 100644 --- a/apps/openmw/mwclass/lockpick.hpp +++ b/apps/openmw/mwclass/lockpick.hpp @@ -12,6 +12,8 @@ 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 std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index 396d92cac..a80405e13 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -24,6 +24,9 @@ namespace MWWorld void Class::insertObjectRendering (const Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { + } + void Class::insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics) const{ + } void Class::enable (const Ptr& ptr, MWWorld::Environment& environment) const diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index 470235bb0..1a2a4f776 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -10,6 +10,7 @@ #include "containerstore.hpp" #include "refdata.hpp" #include "../mwrender/renderinginterface.hpp" +#include "physicssystem.hpp" namespace Ogre { @@ -63,6 +64,7 @@ namespace MWWorld virtual void insertObjectRendering (const Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; + virtual void insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics) 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 067c42151..8ef0ca968 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -183,4 +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(), + node->getScale().x, node->getPosition()); + } + + void PhysicsSystem::insertActorPhysics(const std::string& handle){ + Ogre::SceneNode* node = mRender.getScene()->getSceneNode(handle); + addActor (handle, handle, node->getPosition()); + } + } diff --git a/apps/openmw/mwworld/physicssystem.hpp b/apps/openmw/mwworld/physicssystem.hpp index 17640c074..72f834f6e 100644 --- a/apps/openmw/mwworld/physicssystem.hpp +++ b/apps/openmw/mwworld/physicssystem.hpp @@ -34,6 +34,10 @@ namespace MWWorld bool toggleCollisionMode(); std::pair getFacedHandle (MWWorld::World& world); + void insertObjectPhysics(const std::string& handle); + + void insertActorPhysics(const std::string& handle); + private: OEngine::Render::OgreRenderer &mRender; OEngine::Physic::PhysicEngine* mEngine;