From 1b835d6702bb6e302bf4ca50262acc7ca1e5ec4e Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sat, 24 Dec 2011 21:53:12 -0500 Subject: [PATCH] Cell changing fixes --- apps/openmw/mwclass/creature.cpp | 2 +- apps/openmw/mwclass/npc.cpp | 4 ++-- apps/openmw/mwrender/actors.cpp | 24 ++++++++++++++++++++---- apps/openmw/mwrender/actors.hpp | 2 +- apps/openmw/mwworld/scene.cpp | 10 +++++++--- 5 files changed, 31 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index e2f9ca6d8..5aa203a49 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -47,7 +47,7 @@ namespace MWClass const std::string &model = ref->base->model; assert (ref->base != NULL); if(!model.empty()){ - // physics.insertActorPhysics(ptr, "meshes\\" + model); + physics.insertActorPhysics(ptr, "meshes\\" + model); } } diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 16b3cff75..cedca5bca 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -38,7 +38,7 @@ namespace MWClass void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const { - /* + ESMS::LiveCellRef *ref = ptr.get(); @@ -47,7 +47,7 @@ namespace MWClass assert (ref->base != NULL); if(!model.empty()){ physics.insertActorPhysics(ptr, "meshes\\" + model); - }*/ + } } diff --git a/apps/openmw/mwrender/actors.cpp b/apps/openmw/mwrender/actors.cpp index 21403d3b2..7c5aaeec2 100644 --- a/apps/openmw/mwrender/actors.cpp +++ b/apps/openmw/mwrender/actors.cpp @@ -12,9 +12,13 @@ void Actors::setMwRoot(Ogre::SceneNode* root){ mMwRoot = root; } void Actors::insertNPC(const MWWorld::Ptr& ptr){ + insertBegin(ptr, true, true); - NpcAnimation* anim = new MWRender::NpcAnimation(ptr, mEnvironment, mRend); - mAllActors.push_back(anim); + NpcAnimation* anim = new MWRender::NpcAnimation(ptr, mEnvironment, mRend); + + // + + mAllActors[ptr] = anim; } @@ -57,17 +61,20 @@ void Actors::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){ } void Actors::insertCreature (const MWWorld::Ptr& ptr){ + insertBegin(ptr, true, true); CreatureAnimation* anim = new MWRender::CreatureAnimation(ptr, mEnvironment, mRend); //mAllActors.insert(std::pair(ptr,anim)); - mAllActors.push_back(anim); - //mAllActors.push_back(&anim); + mAllActors[ptr] = anim; + //mAllActors.push_back(&anim);*/ } bool Actors::deleteObject (const MWWorld::Ptr& ptr) { + mAllActors.erase(ptr); if (Ogre::SceneNode *base = ptr.getRefData().getBaseNode()) { + Ogre::SceneNode *parent = base->getParentSceneNode(); for (std::map::const_iterator iter ( @@ -91,6 +98,15 @@ void Actors::removeCell(MWWorld::Ptr::CellStore* store){ { Ogre::SceneNode* base = mCellSceneNodes[store]; base->removeAndDestroyAllChildren(); + + + + + + + + + mCellSceneNodes.erase(store); mRend.getScene()->destroySceneNode(base); base = 0; diff --git a/apps/openmw/mwrender/actors.hpp b/apps/openmw/mwrender/actors.hpp index 011180f19..5a26ed9bb 100644 --- a/apps/openmw/mwrender/actors.hpp +++ b/apps/openmw/mwrender/actors.hpp @@ -23,7 +23,7 @@ namespace MWRender{ std::map mCellSceneNodes; Ogre::SceneNode* mMwRoot; MWWorld::Environment& mEnvironment; - std::list mAllActors; + std::map mAllActors; diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 5f0632850..b2e4f3708 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -59,7 +59,9 @@ namespace MWWorld ListHandles functor; MWWorld::Ptr::CellStore* active = *iter; - mRendering.removeCell(active); + + + active->forEach(functor); @@ -73,11 +75,13 @@ namespace MWWorld mPhysics->removeObject (node->getName()); } } - //mPhysics->removeObject("Unnamed_43"); + mRendering.removeCell(active); + //mPhysics->removeObject("Unnamed_43"); mWorld->getLocalScripts().clearCell (active); mEnvironment.mMechanicsManager->dropActors (active); mEnvironment.mSoundManager->stopSound (active); - mActiveCells.erase (iter); + mActiveCells.erase(active); + } void Scene::loadCell (Ptr::CellStore *cell)