1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-22 07:53:52 +00:00

fixed item sinking

This commit is contained in:
greye 2012-07-24 22:08:23 +04:00
parent 6a3a728a56
commit e1c7d1f529
3 changed files with 24 additions and 17 deletions

View file

@ -349,29 +349,30 @@ namespace MWWorld
throw std::logic_error ("can't find player"); 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 addObject(
//Ogre::Vector3 objPos = node->getPosition(); node->getName(),
model,
node->getOrientation(),
node->getScale().x,
node->getPosition());
}
addObject (node->getName(), model, node->getOrientation(), void PhysicsSystem::insertActorPhysics(const MWWorld::Ptr& ptr, const std::string model){
node->getScale().x, node->getPosition()); Ogre::SceneNode* node = ptr.getRefData().getBaseNode();
} addActor (node->getName(), model, node->getPosition());
}
void PhysicsSystem::insertActorPhysics(const MWWorld::Ptr& ptr, const std::string model){ float PhysicsSystem::getObjectHeight(const MWWorld::Ptr &ptr)
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) {
std::string model = MWWorld::Class::get(ptr).getModel(ptr); std::string model = MWWorld::Class::get(ptr).getModel(ptr);
if (model.empty()) { if (model.empty()) {
return 0.0; return 0.0;
} }
float scale = ptr.getRefData().getBaseNode()->getScale().x; float scale = ptr.getRefData().getBaseNode()->getScale().x;
return mEngine->getObjectHeight(model, scale); return mEngine->getObjectHeight(model, scale);
} }
} }

View file

@ -335,6 +335,12 @@ namespace MWWorld
void Scene::addObjectToScene (const Ptr& ptr) void Scene::addObjectToScene (const Ptr& ptr)
{ {
mRendering.addObject (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); MWWorld::Class::get (ptr).insertObject (ptr, *mPhysics);
} }

View file

@ -1024,8 +1024,6 @@ namespace MWWorld
MWWorld::Ptr dropped = cell->insertObject(object, pos); MWWorld::Ptr dropped = cell->insertObject(object, pos);
mWorldScene->addObjectToScene(dropped); mWorldScene->addObjectToScene(dropped);
/// \todo retrieve the bounds of the object and translate it accordingly
return true; return true;
} }
@ -1047,6 +1045,8 @@ namespace MWWorld
ESM::Position &pos = ESM::Position &pos =
getPlayer().getPlayer().getRefData().getPosition(); getPlayer().getPlayer().getRefData().getPosition();
/// \todo fix item dropping at player object center position
MWWorld::Ptr dropped = cell->insertObject(object, pos); MWWorld::Ptr dropped = cell->insertObject(object, pos);
mWorldScene->addObjectToScene(dropped); mWorldScene->addObjectToScene(dropped);