mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 06:23:53 +00:00
Fix issue where objects were sometimes unresponsive after dragging.
This commit is contained in:
parent
e174428cc5
commit
7f54dab6ef
3 changed files with 34 additions and 8 deletions
|
@ -441,7 +441,7 @@ namespace CSVRender
|
|||
|
||||
// FIXME: adjustRigidBody() seems to lose objects, work around by deleting and recreating objects
|
||||
//mPhysics->moveObject(sceneNode, pos, xr*yr*zr);
|
||||
mPhysics->replaceObject(sceneNode, refId, cellref.mScale, pos, xr*yr*zr);
|
||||
mPhysics->replaceObject(sceneNode, cellref.mScale, pos, xr*yr*zr);
|
||||
|
||||
// update all SceneWidgets and their SceneManagers
|
||||
updateSceneWidgets();
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace CSVWorld
|
|||
|
||||
// normal delete (e.g closing a scene subview)
|
||||
// TODO: should think about using some kind of reference counting within RigidBody
|
||||
void PhysicsSystem::removeObject(const std::string &sceneNodeName, bool force)
|
||||
void PhysicsSystem::removeObject(const std::string &sceneNodeName)
|
||||
{
|
||||
std::string referenceId = mSceneNodeToRefId[sceneNodeName];
|
||||
|
||||
|
@ -137,7 +137,7 @@ namespace CSVWorld
|
|||
}
|
||||
|
||||
// check whether the physics model be deleted
|
||||
if(force || mRefIdToSceneNode.find(referenceId) == mRefIdToSceneNode.end())
|
||||
if(mRefIdToSceneNode.find(referenceId) == mRefIdToSceneNode.end())
|
||||
{
|
||||
mEngine->removeRigidBody(referenceId);
|
||||
mEngine->deleteRigidBody(referenceId);
|
||||
|
@ -146,12 +146,38 @@ namespace CSVWorld
|
|||
}
|
||||
|
||||
void PhysicsSystem::replaceObject(const std::string &sceneNodeName,
|
||||
const std::string &referenceId, float scale, const Ogre::Vector3 &position,
|
||||
float scale, const Ogre::Vector3 &position,
|
||||
const Ogre::Quaternion &rotation, bool placeable)
|
||||
{
|
||||
std::string referenceId = mSceneNodeToRefId[sceneNodeName];
|
||||
std::string mesh = mSceneNodeToMesh[sceneNodeName];
|
||||
removeObject(sceneNodeName, true); // force delete
|
||||
addObject(mesh, sceneNodeName, referenceId, scale, position, rotation, placeable);
|
||||
|
||||
if(referenceId != "")
|
||||
{
|
||||
// delete the physics object
|
||||
mEngine->removeRigidBody(referenceId);
|
||||
mEngine->deleteRigidBody(referenceId);
|
||||
|
||||
// create the physics object
|
||||
mEngine->createAndAdjustRigidBody(mesh,
|
||||
referenceId, scale, position, rotation,
|
||||
0, // scaledBoxTranslation
|
||||
0, // boxRotation
|
||||
true, // raycasting
|
||||
placeable);
|
||||
|
||||
// update other scene managers if they have the referenceId
|
||||
std::list<Ogre::SceneManager *>::const_iterator iter = mSceneManagers.begin();
|
||||
for(; iter != mSceneManagers.end(); ++iter)
|
||||
{
|
||||
std::string name = refIdToSceneNode(referenceId, *iter);
|
||||
if(name != sceneNodeName && (*iter)->hasSceneNode(name))
|
||||
{
|
||||
// FIXME: rotation or scale not updated
|
||||
(*iter)->getSceneNode(name)->setPosition(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsSystem::moveObject(const std::string &sceneNodeName,
|
||||
|
|
|
@ -52,10 +52,10 @@ namespace CSVWorld
|
|||
const Ogre::Vector3 &position, const Ogre::Quaternion &rotation,
|
||||
bool placeable=false);
|
||||
|
||||
void removeObject(const std::string &sceneNodeName, bool force = false);
|
||||
void removeObject(const std::string &sceneNodeName);
|
||||
|
||||
void replaceObject(const std::string &sceneNodeName,
|
||||
const std::string &referenceId, float scale, const Ogre::Vector3 &position,
|
||||
float scale, const Ogre::Vector3 &position,
|
||||
const Ogre::Quaternion &rotation, bool placeable=false);
|
||||
|
||||
void moveObject(const std::string &sceneNodeName,
|
||||
|
|
Loading…
Reference in a new issue