From e1c7d1f52936988f2093db7a9800093c1cfac927 Mon Sep 17 00:00:00 2001 From: greye Date: Tue, 24 Jul 2012 22:08:23 +0400 Subject: [PATCH] fixed item sinking --- apps/openmw/mwworld/physicssystem.cpp | 31 ++++++++++++++------------- apps/openmw/mwworld/scene.cpp | 6 ++++++ apps/openmw/mwworld/worldimp.cpp | 4 ++-- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 1eba439a8f..2b3d4b0f44 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -349,29 +349,30 @@ namespace MWWorld throw std::logic_error ("can't find player"); } - void PhysicsSystem::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string model){ + void PhysicsSystem::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string model){ - Ogre::SceneNode* node = ptr.getRefData().getBaseNode(); + Ogre::SceneNode* node = ptr.getRefData().getBaseNode(); - // unused - //Ogre::Vector3 objPos = node->getPosition(); + addObject( + node->getName(), + model, + node->getOrientation(), + node->getScale().x, + node->getPosition()); + } - addObject (node->getName(), model, node->getOrientation(), - node->getScale().x, node->getPosition()); - } + void PhysicsSystem::insertActorPhysics(const MWWorld::Ptr& ptr, const std::string model){ + Ogre::SceneNode* node = ptr.getRefData().getBaseNode(); + addActor (node->getName(), model, node->getPosition()); + } - void PhysicsSystem::insertActorPhysics(const MWWorld::Ptr& ptr, const std::string model){ - Ogre::SceneNode* node = ptr.getRefData().getBaseNode(); - // std::cout << "Adding node with name" << node->getName(); - addActor (node->getName(), model, node->getPosition()); - } - - float PhysicsSystem::getObjectHeight(const MWWorld::Ptr &ptr) { + float PhysicsSystem::getObjectHeight(const MWWorld::Ptr &ptr) + { std::string model = MWWorld::Class::get(ptr).getModel(ptr); if (model.empty()) { return 0.0; } float scale = ptr.getRefData().getBaseNode()->getScale().x; return mEngine->getObjectHeight(model, scale); - } + } } diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 9786c24d90..b78669ef5b 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -335,6 +335,12 @@ namespace MWWorld void Scene::addObjectToScene (const Ptr& ptr) { mRendering.addObject (ptr); + + float *pos = ptr.getRefData().getPosition().pos; + pos[2] += mPhysics->getObjectHeight(ptr) / 2; + + ptr.getRefData().getBaseNode()->setPosition(pos[0], pos[1], pos[2]); + MWWorld::Class::get (ptr).insertObject (ptr, *mPhysics); } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index efb17a7099..3d409570b0 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1024,8 +1024,6 @@ namespace MWWorld MWWorld::Ptr dropped = cell->insertObject(object, pos); mWorldScene->addObjectToScene(dropped); - /// \todo retrieve the bounds of the object and translate it accordingly - return true; } @@ -1047,6 +1045,8 @@ namespace MWWorld ESM::Position &pos = getPlayer().getPlayer().getRefData().getPosition(); + /// \todo fix item dropping at player object center position + MWWorld::Ptr dropped = cell->insertObject(object, pos); mWorldScene->addObjectToScene(dropped);