diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index d0f09e80e..9b0082efc 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -96,7 +96,7 @@ namespace MWClass } MWWorld::Ptr - Activator::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const + Activator::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const { MWWorld::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/activator.hpp b/apps/openmw/mwclass/activator.hpp index 26aafb717..4165fbc08 100644 --- a/apps/openmw/mwclass/activator.hpp +++ b/apps/openmw/mwclass/activator.hpp @@ -9,7 +9,7 @@ namespace MWClass { virtual MWWorld::Ptr - moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; + copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; public: diff --git a/apps/openmw/mwclass/apparatus.cpp b/apps/openmw/mwclass/apparatus.cpp index 6322c963e..9814b140c 100644 --- a/apps/openmw/mwclass/apparatus.cpp +++ b/apps/openmw/mwclass/apparatus.cpp @@ -151,7 +151,7 @@ namespace MWClass } MWWorld::Ptr - Apparatus::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const + Apparatus::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const { MWWorld::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/apparatus.hpp b/apps/openmw/mwclass/apparatus.hpp index 9352e0617..7045f62d6 100644 --- a/apps/openmw/mwclass/apparatus.hpp +++ b/apps/openmw/mwclass/apparatus.hpp @@ -9,7 +9,7 @@ namespace MWClass { virtual MWWorld::Ptr - moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; + copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; public: diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index aeefcd42b..4624b94d9 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -278,7 +278,7 @@ namespace MWClass } MWWorld::Ptr - Armor::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const + Armor::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const { MWWorld::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/armor.hpp b/apps/openmw/mwclass/armor.hpp index 960b6dad5..51c0ea21c 100644 --- a/apps/openmw/mwclass/armor.hpp +++ b/apps/openmw/mwclass/armor.hpp @@ -8,7 +8,7 @@ namespace MWClass class Armor : public MWWorld::Class { virtual MWWorld::Ptr - moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; + copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; public: diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index 1517f090a..d8166347e 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -158,7 +158,7 @@ namespace MWClass } MWWorld::Ptr - Book::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const + Book::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const { MWWorld::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/book.hpp b/apps/openmw/mwclass/book.hpp index adbf2d64b..acb1aac06 100644 --- a/apps/openmw/mwclass/book.hpp +++ b/apps/openmw/mwclass/book.hpp @@ -8,7 +8,7 @@ namespace MWClass class Book : public MWWorld::Class { virtual MWWorld::Ptr - moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; + copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; public: diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index 86c031db0..f55d6ed88 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -229,7 +229,7 @@ namespace MWClass } MWWorld::Ptr - Clothing::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const + Clothing::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const { MWWorld::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/clothing.hpp b/apps/openmw/mwclass/clothing.hpp index 2c0d0b8a5..f7801848f 100644 --- a/apps/openmw/mwclass/clothing.hpp +++ b/apps/openmw/mwclass/clothing.hpp @@ -8,7 +8,7 @@ namespace MWClass class Clothing : public MWWorld::Class { virtual MWWorld::Ptr - moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; + copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; public: diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 2543f6acd..c6d22b3a5 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -209,7 +209,7 @@ namespace MWClass } MWWorld::Ptr - Container::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const + Container::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const { MWWorld::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/container.hpp b/apps/openmw/mwclass/container.hpp index 2f15d03d8..006e4bd22 100644 --- a/apps/openmw/mwclass/container.hpp +++ b/apps/openmw/mwclass/container.hpp @@ -11,7 +11,7 @@ namespace MWClass virtual MWWorld::Ptr - moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; + copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; public: diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 8f885bf62..0f3141f5c 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -197,7 +197,7 @@ namespace MWClass } MWWorld::Ptr - Creature::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const + Creature::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const { MWWorld::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/creature.hpp b/apps/openmw/mwclass/creature.hpp index 38be98533..f7a5e5874 100644 --- a/apps/openmw/mwclass/creature.hpp +++ b/apps/openmw/mwclass/creature.hpp @@ -12,7 +12,7 @@ namespace MWClass void ensureCustomData (const MWWorld::Ptr& ptr) const; virtual MWWorld::Ptr - moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; + copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; public: diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 8eef54725..359e50ffb 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -211,7 +211,7 @@ namespace MWClass } MWWorld::Ptr - Door::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const + Door::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const { MWWorld::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/door.hpp b/apps/openmw/mwclass/door.hpp index b89858556..b0f86f12d 100644 --- a/apps/openmw/mwclass/door.hpp +++ b/apps/openmw/mwclass/door.hpp @@ -8,7 +8,7 @@ namespace MWClass class Door : public MWWorld::Class { virtual MWWorld::Ptr - moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; + copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; public: diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index 02e77fa25..d8c8b4b3b 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -158,7 +158,7 @@ namespace MWClass } MWWorld::Ptr - Ingredient::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const + Ingredient::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const { MWWorld::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/ingredient.hpp b/apps/openmw/mwclass/ingredient.hpp index 44ee0ccd0..1365c4a71 100644 --- a/apps/openmw/mwclass/ingredient.hpp +++ b/apps/openmw/mwclass/ingredient.hpp @@ -8,7 +8,7 @@ namespace MWClass class Ingredient : public MWWorld::Class { virtual MWWorld::Ptr - moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; + copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; public: diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index e7b3af2b9..f09d3ce36 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -198,7 +198,7 @@ namespace MWClass } MWWorld::Ptr - Light::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const + Light::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const { MWWorld::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/light.hpp b/apps/openmw/mwclass/light.hpp index 953078a35..640e1705b 100644 --- a/apps/openmw/mwclass/light.hpp +++ b/apps/openmw/mwclass/light.hpp @@ -8,7 +8,7 @@ namespace MWClass class Light : public MWWorld::Class { virtual MWWorld::Ptr - moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; + copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; public: diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index e72e96822..20441b520 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -167,7 +167,7 @@ namespace MWClass } MWWorld::Ptr - Lockpick::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const + Lockpick::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const { MWWorld::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/lockpick.hpp b/apps/openmw/mwclass/lockpick.hpp index 216dc10c9..0961b55b2 100644 --- a/apps/openmw/mwclass/lockpick.hpp +++ b/apps/openmw/mwclass/lockpick.hpp @@ -8,7 +8,7 @@ namespace MWClass class Lockpick : public MWWorld::Class { virtual MWWorld::Ptr - moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; + copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; public: diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index 37f608ed2..cb6d40c43 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -186,7 +186,7 @@ namespace MWClass } MWWorld::Ptr - Miscellaneous::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const + Miscellaneous::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const { MWWorld::Ptr newPtr; diff --git a/apps/openmw/mwclass/misc.hpp b/apps/openmw/mwclass/misc.hpp index 2a314758f..a5a79a8f6 100644 --- a/apps/openmw/mwclass/misc.hpp +++ b/apps/openmw/mwclass/misc.hpp @@ -8,7 +8,7 @@ namespace MWClass class Miscellaneous : public MWWorld::Class { virtual MWWorld::Ptr - moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; + copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; public: diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index c81397753..81c0c85f5 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -382,7 +382,7 @@ namespace MWClass } MWWorld::Ptr - Npc::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const + Npc::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const { MWWorld::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/npc.hpp b/apps/openmw/mwclass/npc.hpp index 46fdc9b04..e494fbaa7 100644 --- a/apps/openmw/mwclass/npc.hpp +++ b/apps/openmw/mwclass/npc.hpp @@ -10,7 +10,7 @@ namespace MWClass void ensureCustomData (const MWWorld::Ptr& ptr) const; virtual MWWorld::Ptr - moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; + copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; public: diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index e0f9008c4..993dac6f6 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -162,7 +162,7 @@ namespace MWClass } MWWorld::Ptr - Potion::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const + Potion::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const { MWWorld::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/potion.hpp b/apps/openmw/mwclass/potion.hpp index 0cb40ead0..d595f7e69 100644 --- a/apps/openmw/mwclass/potion.hpp +++ b/apps/openmw/mwclass/potion.hpp @@ -8,7 +8,7 @@ namespace MWClass class Potion : public MWWorld::Class { virtual MWWorld::Ptr - moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; + copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; public: diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index 8e5fcfd19..450016209 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -166,7 +166,7 @@ namespace MWClass } MWWorld::Ptr - Probe::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const + Probe::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const { MWWorld::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/probe.hpp b/apps/openmw/mwclass/probe.hpp index 67831d766..d9f90baf6 100644 --- a/apps/openmw/mwclass/probe.hpp +++ b/apps/openmw/mwclass/probe.hpp @@ -8,7 +8,7 @@ namespace MWClass class Probe : public MWWorld::Class { virtual MWWorld::Ptr - moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; + copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; public: diff --git a/apps/openmw/mwclass/repair.cpp b/apps/openmw/mwclass/repair.cpp index 84d6e3b9e..829fe311a 100644 --- a/apps/openmw/mwclass/repair.cpp +++ b/apps/openmw/mwclass/repair.cpp @@ -148,7 +148,7 @@ namespace MWClass } MWWorld::Ptr - Repair::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const + Repair::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const { MWWorld::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/repair.hpp b/apps/openmw/mwclass/repair.hpp index 74d1d7378..c58e38f96 100644 --- a/apps/openmw/mwclass/repair.hpp +++ b/apps/openmw/mwclass/repair.hpp @@ -8,7 +8,7 @@ namespace MWClass class Repair : public MWWorld::Class { virtual MWWorld::Ptr - moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; + copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; public: diff --git a/apps/openmw/mwclass/static.cpp b/apps/openmw/mwclass/static.cpp index ee8bcfe81..e317b740c 100644 --- a/apps/openmw/mwclass/static.cpp +++ b/apps/openmw/mwclass/static.cpp @@ -55,7 +55,7 @@ namespace MWClass } MWWorld::Ptr - Static::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const + Static::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const { MWWorld::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/static.hpp b/apps/openmw/mwclass/static.hpp index 52b87abcd..e36b3d142 100644 --- a/apps/openmw/mwclass/static.hpp +++ b/apps/openmw/mwclass/static.hpp @@ -8,7 +8,7 @@ namespace MWClass class Static : public MWWorld::Class { virtual MWWorld::Ptr - moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; + copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; public: diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index ccc5ff6ea..b45953130 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -367,7 +367,7 @@ namespace MWClass } MWWorld::Ptr - Weapon::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const + Weapon::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const { MWWorld::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/weapon.hpp b/apps/openmw/mwclass/weapon.hpp index b18405488..06cf88c5f 100644 --- a/apps/openmw/mwclass/weapon.hpp +++ b/apps/openmw/mwclass/weapon.hpp @@ -8,7 +8,7 @@ namespace MWClass class Weapon : public MWWorld::Class { virtual MWWorld::Ptr - moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; + copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const; public: diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index 6f2306fbe..6676ce1cf 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -222,27 +222,26 @@ namespace MWWorld } MWWorld::Ptr - Class::moveToCellImpl(const Ptr &ptr, CellStore &cell) const + Class::copyToCellImpl(const Ptr &ptr, CellStore &cell) const { throw std::runtime_error("unable to move class to cell"); } MWWorld::Ptr - Class::moveToCell(const Ptr &ptr, CellStore &cell) const + Class::copyToCell(const Ptr &ptr, CellStore &cell) const { - Ptr newPtr = moveToCellImpl(ptr, cell); + Ptr newPtr = copyToCellImpl(ptr, cell); newPtr.getRefData().setCount(ptr.getRefData().getCount()); - ptr.getRefData().setCount(0); newPtr.getRefData().enable(); return newPtr; } MWWorld::Ptr - Class::moveToCell(const Ptr &ptr, CellStore &cell, const ESM::Position &pos) const + Class::copyToCell(const Ptr &ptr, CellStore &cell, const ESM::Position &pos) const { - Ptr newPtr = moveToCell(ptr, cell); + Ptr newPtr = copyToCell(ptr, cell); newPtr.getRefData().getPosition() = pos; return newPtr; diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index 509433433..1bc592798 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -57,7 +57,7 @@ namespace MWWorld Class(); - virtual Ptr moveToCellImpl(const Ptr &ptr, CellStore &cell) const; + virtual Ptr copyToCellImpl(const Ptr &ptr, CellStore &cell) const; public: @@ -216,10 +216,10 @@ namespace MWWorld virtual std::string getModel(const MWWorld::Ptr &ptr) const; virtual Ptr - moveToCell(const Ptr &ptr, CellStore &cell) const; + copyToCell(const Ptr &ptr, CellStore &cell) const; virtual Ptr - moveToCell(const Ptr &ptr, CellStore &cell, const ESM::Position &pos) const; + copyToCell(const Ptr &ptr, CellStore &cell, const ESM::Position &pos) const; }; } diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 27d48fa39..45cfdd123 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -382,14 +382,23 @@ namespace MWWorld addActor (node->getName(), model, node->getPosition()); } - bool PhysicsSystem::getObjectAABB(const MWWorld::Ptr &ptr, float *min, float *max) + bool PhysicsSystem::getObjectAABB(const MWWorld::Ptr &ptr, Ogre::Vector3 &min, Ogre::Vector3 &max) { std::string model = MWWorld::Class::get(ptr).getModel(ptr); if (model.empty()) { return false; } - float scale = ptr.getRefData().getBaseNode()->getScale().x; - mEngine->getObjectAABB(model, scale, min, max); + btVector3 btMin, btMax; + float scale = ptr.getCellRef().scale; + mEngine->getObjectAABB(model, scale, btMin, btMax); + + min.x = btMin.x(); + min.y = btMin.y(); + min.z = btMin.z(); + + max.x = btMax.x(); + max.y = btMax.y(); + max.z = btMax.z(); return true; } diff --git a/apps/openmw/mwworld/physicssystem.hpp b/apps/openmw/mwworld/physicssystem.hpp index 375a7c9de..e42fa536b 100644 --- a/apps/openmw/mwworld/physicssystem.hpp +++ b/apps/openmw/mwworld/physicssystem.hpp @@ -68,7 +68,7 @@ namespace MWWorld void setCurrentWater(bool hasWater, int waterHeight); - bool getObjectAABB(const MWWorld::Ptr &ptr, float *min, float *max); + bool getObjectAABB(const MWWorld::Ptr &ptr, Ogre::Vector3 &min, Ogre::Vector3 &max); private: OEngine::Render::OgreRenderer &mRender; diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index ce0acfe47..13e5ecb85 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -334,21 +334,10 @@ namespace MWWorld void Scene::addObjectToScene (const Ptr& ptr) { - mRendering.addObject (ptr); - - float *pos = ptr.getRefData().getPosition().pos; - float min[3], max[3]; - if (mPhysics->getObjectAABB(ptr, min, max)) { - pos[0] -= (min[0] + max[0]) / 2; - pos[1] -= (min[1] + max[1]) / 2; - pos[2] -= min[2]; - } - - ptr.getRefData().getBaseNode()->setPosition(pos[0], pos[1], pos[2]); - - MWWorld::Class::get (ptr).insertObject (ptr, *mPhysics); + mRendering.addObject(ptr); + MWWorld::Class::get(ptr).insertObject(ptr, *mPhysics); } - + void Scene::removeObjectFromScene (const Ptr& ptr) { MWBase::Environment::get().getMechanicsManager()->removeActor (ptr); @@ -356,4 +345,19 @@ namespace MWWorld mPhysics->removeObject (ptr.getRefData().getHandle()); mRendering.removeObject (ptr); } + + bool Scene::isCellActive(const CellStore &cell) + { + CellStoreCollection::iterator active = mActiveCells.begin(); + while (active != mActiveCells.end()) { + if ((*active)->cell->name == cell.cell->name && + (*active)->cell->data.gridX == cell.cell->data.gridX && + (*active)->cell->data.gridY == cell.cell->data.gridY) + { + return true; + } + ++active; + } + return false; + } } diff --git a/apps/openmw/mwworld/scene.hpp b/apps/openmw/mwworld/scene.hpp index f5f4b640b..59e13dafe 100644 --- a/apps/openmw/mwworld/scene.hpp +++ b/apps/openmw/mwworld/scene.hpp @@ -95,6 +95,8 @@ namespace MWWorld void removeObjectFromScene (const Ptr& ptr); ///< Remove an object from the scene, but not from the world model. + + bool isCellActive(const CellStore &cell); }; } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index b9ab6ade2..59f6d7e86 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1022,6 +1022,7 @@ namespace MWWorld pos.pos[2] = result.second[1]; placeObject(object, *cell, pos); + object.getRefData().setCount(0); return true; } @@ -1040,16 +1041,25 @@ namespace MWWorld void World::placeObject(const Ptr &object, CellStore &cell, const ESM::Position &pos) { - mLocalScripts.remove(object); - + /// \todo add searching correct cell for position specified MWWorld::Ptr dropped = - MWWorld::Class::get(object).moveToCell(object, cell, pos); + MWWorld::Class::get(object).copyToCell(object, cell, pos); + + Ogre::Vector3 min, max; + if (mPhysics->getObjectAABB(object, min, max)) { + float *pos = dropped.getRefData().getPosition().pos; + pos[0] -= (min.x + max.x) / 2; + pos[1] -= (min.y + max.y) / 2; + pos[2] -= min.z; + } - mWorldScene->addObjectToScene(dropped); + if (mWorldScene->isCellActive(cell)) { + mWorldScene->addObjectToScene(dropped); - std::string script = MWWorld::Class::get(dropped).getScript(dropped); - if (!script.empty()) { - mLocalScripts.add(script, dropped); + std::string script = MWWorld::Class::get(dropped).getScript(dropped); + if (!script.empty()) { + mLocalScripts.add(script, dropped); + } } } @@ -1071,8 +1081,8 @@ namespace MWWorld mPhysics->castRay(orig, dir, len); pos.pos[2] = hit.second.z; - /// \todo fix item dropping at player object center position placeObject(object, *cell, pos); + object.getRefData().setCount(0); } void World::processChangedSettings(const Settings::CategorySettingVector& settings) diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index d4b63676d..089825a9d 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -569,7 +569,7 @@ namespace Physic return results2; } - void PhysicEngine::getObjectAABB(const std::string &mesh, float scale, float *min, float *max) + void PhysicEngine::getObjectAABB(const std::string &mesh, float scale, btVector3 &min, btVector3 &max) { char uniqueID[8]; sprintf( uniqueID, "%07.3f", scale ); @@ -582,17 +582,8 @@ namespace Physic BulletShapeManager::getSingleton().getByName(outputstring, "General"); btTransform trans; - btVector3 btmin, btmax; - trans.setIdentity(); - shape->Shape->getAabb(trans, btmin, btmax); - - min[0] = btmin.x(); - min[1] = btmin.y(); - min[2] = btmin.z(); - max[0] = btmax.x(); - max[1] = btmax.y(); - max[2] = btmax.z(); + shape->Shape->getAabb(trans, min, max); } }}; diff --git a/libs/openengine/bullet/physic.hpp b/libs/openengine/bullet/physic.hpp index 8701adc84..9ae8e7607 100644 --- a/libs/openengine/bullet/physic.hpp +++ b/libs/openengine/bullet/physic.hpp @@ -221,7 +221,7 @@ namespace Physic bool toggleDebugRendering(); - void getObjectAABB(const std::string &mesh, float scale, float *min, float *max); + void getObjectAABB(const std::string &mesh, float scale, btVector3 &min, btVector3 &max); /** * Return the closest object hit by a ray. If there are no objects, it will return ("",-1).