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");
}
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);
}
}
}

View file

@ -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);
}

View file

@ -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);