From a13b958600c70cc678acf1ee9f4c3ce642c80b26 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 9 Aug 2011 00:05:16 +0200 Subject: [PATCH] MWWorld::Scene::insertCell --- apps/openmw/mwworld/scene.cpp | 64 +++++++++++++++++++++++++++++++++++ apps/openmw/mwworld/scene.hpp | 2 ++ 2 files changed, 66 insertions(+) diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index a6d06a75c9..e929664700 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -11,11 +11,42 @@ #include "ptr.hpp" #include "environment.hpp" #include "player.hpp" +#include "class.hpp" #include "doingphysics.hpp" #include "cellfunctors.hpp" + +namespace { + +template +void insertCellRefList (T& cellRefList, ESMS::CellStore &cell) +{ + if (!cellRefList.list.empty()) + { + const MWWorld::Class& class_ = + MWWorld::Class::get (MWWorld::Ptr (&*cellRefList.list.begin(), &cell)); + + for (typename T::List::iterator it = cellRefList.list.begin(); + it != cellRefList.list.end(); it++) + { + if (it->mData.getCount() || it->mData.isEnabled()) + { + MWWorld::Ptr ptr (&*it, &cell); + /* TODO: call + * RenderingManager.insertObject + * class_.insertObjectPhysic + * class_.insertObjectMechanics + */ + } + } + } +} + +} + + namespace MWWorld { @@ -216,5 +247,38 @@ namespace MWWorld { mCellChanged = false; } + +/*#include +#include +#include + +#include "../mwworld/class.hpp" +#include "../mwworld/ptr.hpp"*/ + +void Scene::insertCell(ESMS::CellStore &cell) +{ + // Loop through all references in the cell + insertCellRefList (cell.activators, cell); + insertCellRefList (cell.potions, cell); + insertCellRefList (cell.appas, cell); + insertCellRefList (cell.armors, cell); + insertCellRefList (cell.books, cell); + insertCellRefList (cell.clothes, cell); + insertCellRefList (cell.containers, cell); + insertCellRefList (cell.creatures, cell); + insertCellRefList (cell.doors, cell); + insertCellRefList (cell.ingreds, cell); + insertCellRefList (cell.creatureLists, cell); + insertCellRefList (cell.itemLists, cell); + insertCellRefList (cell.lights, cell); + insertCellRefList (cell.lockpicks, cell); + insertCellRefList (cell.miscItems, cell); + insertCellRefList (cell.npcs, cell); + insertCellRefList (cell.probes, cell); + insertCellRefList (cell.repairs, cell); + insertCellRefList (cell.statics, cell); + insertCellRefList (cell.weapons, cell); +} + } diff --git a/apps/openmw/mwworld/scene.hpp b/apps/openmw/mwworld/scene.hpp index c6d9963649..b03b1fee43 100644 --- a/apps/openmw/mwworld/scene.hpp +++ b/apps/openmw/mwworld/scene.hpp @@ -98,6 +98,8 @@ namespace MWWorld void markCellAsUnchanged(); std::string getFacedHandle(); + + void insertCell(ESMS::CellStore &cell); }; }