mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 06:53:53 +00:00
Fix deleting physics object when scene node is cleared.
This commit is contained in:
parent
3796240b19
commit
85ef683319
5 changed files with 32 additions and 5 deletions
|
@ -34,7 +34,7 @@ void CSVRender::Object::clearSceneNode (Ogre::SceneNode *node)
|
|||
void CSVRender::Object::clear()
|
||||
{
|
||||
if(!mObject.isNull())
|
||||
mPhysics->removeObject(mBase->getName());
|
||||
mPhysics->removePhysicsObject(mBase->getName());
|
||||
|
||||
mObject.setNull();
|
||||
|
||||
|
@ -156,6 +156,8 @@ CSVRender::Object::~Object()
|
|||
{
|
||||
clear();
|
||||
|
||||
mPhysics->removeObject(mBase->getName());
|
||||
|
||||
if (mBase)
|
||||
mBase->getCreator()->destroySceneNode (mBase);
|
||||
}
|
||||
|
|
|
@ -353,7 +353,10 @@ void CSVRender::WorldspaceWidget::mouseMoveEvent (QMouseEvent *event)
|
|||
|
||||
void CSVRender::WorldspaceWidget::mousePressEvent (QMouseEvent *event)
|
||||
{
|
||||
mMouse->mousePressEvent(event);
|
||||
if(event->buttons() & Qt::RightButton)
|
||||
{
|
||||
mMouse->mousePressEvent(event);
|
||||
}
|
||||
//SceneWidget::mousePressEvent(event);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,8 +32,6 @@ namespace CSVRender
|
|||
{
|
||||
class WorldspaceWidget : public SceneWidget
|
||||
{
|
||||
friend class MouseState;
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
CSVRender::Navigation1st m1st;
|
||||
|
@ -154,6 +152,8 @@ namespace CSVRender
|
|||
void closeRequest();
|
||||
|
||||
void dataDropped(const std::vector<CSMWorld::UniversalId>& data);
|
||||
|
||||
friend class MouseState;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,9 @@ namespace CSVWorld
|
|||
}
|
||||
}
|
||||
|
||||
// normal delete (e.g closing a scene subview)
|
||||
// normal delete (e.g closing a scene subview or ~Object())
|
||||
// the scene node is destroyed so the mappings should be removed
|
||||
//
|
||||
// TODO: should think about using some kind of reference counting within RigidBody
|
||||
void PhysicsSystem::removeObject(const std::string &sceneNodeName)
|
||||
{
|
||||
|
@ -114,6 +116,25 @@ namespace CSVWorld
|
|||
}
|
||||
}
|
||||
|
||||
// Object::clear() is called when reference data is changed. It clears all
|
||||
// contents of the SceneNode and removes the physics object
|
||||
//
|
||||
// A new physics object will be created and assigned to this sceneNodeName by
|
||||
// Object::update()
|
||||
void PhysicsSystem::removePhysicsObject(const std::string &sceneNodeName)
|
||||
{
|
||||
std::string referenceId = mSceneNodeToRefId[sceneNodeName];
|
||||
|
||||
if(referenceId != "")
|
||||
{
|
||||
if(mRefIdToSceneNode.find(referenceId) == mRefIdToSceneNode.end())
|
||||
{
|
||||
mEngine->removeRigidBody(referenceId);
|
||||
mEngine->deleteRigidBody(referenceId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsSystem::replaceObject(const std::string &sceneNodeName, float scale,
|
||||
const Ogre::Vector3 &position, const Ogre::Quaternion &rotation, bool placeable)
|
||||
{
|
||||
|
|
|
@ -51,6 +51,7 @@ namespace CSVWorld
|
|||
bool placeable=false);
|
||||
|
||||
void removeObject(const std::string &sceneNodeName);
|
||||
void removePhysicsObject(const std::string &sceneNodeName);
|
||||
|
||||
void replaceObject(const std::string &sceneNodeName,
|
||||
float scale, const Ogre::Vector3 &position,
|
||||
|
|
Loading…
Reference in a new issue