mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 16:49:54 +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()
|
void CSVRender::Object::clear()
|
||||||
{
|
{
|
||||||
if(!mObject.isNull())
|
if(!mObject.isNull())
|
||||||
mPhysics->removeObject(mBase->getName());
|
mPhysics->removePhysicsObject(mBase->getName());
|
||||||
|
|
||||||
mObject.setNull();
|
mObject.setNull();
|
||||||
|
|
||||||
|
@ -156,6 +156,8 @@ CSVRender::Object::~Object()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
|
mPhysics->removeObject(mBase->getName());
|
||||||
|
|
||||||
if (mBase)
|
if (mBase)
|
||||||
mBase->getCreator()->destroySceneNode (mBase);
|
mBase->getCreator()->destroySceneNode (mBase);
|
||||||
}
|
}
|
||||||
|
|
|
@ -353,7 +353,10 @@ void CSVRender::WorldspaceWidget::mouseMoveEvent (QMouseEvent *event)
|
||||||
|
|
||||||
void CSVRender::WorldspaceWidget::mousePressEvent (QMouseEvent *event)
|
void CSVRender::WorldspaceWidget::mousePressEvent (QMouseEvent *event)
|
||||||
{
|
{
|
||||||
mMouse->mousePressEvent(event);
|
if(event->buttons() & Qt::RightButton)
|
||||||
|
{
|
||||||
|
mMouse->mousePressEvent(event);
|
||||||
|
}
|
||||||
//SceneWidget::mousePressEvent(event);
|
//SceneWidget::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,6 @@ namespace CSVRender
|
||||||
{
|
{
|
||||||
class WorldspaceWidget : public SceneWidget
|
class WorldspaceWidget : public SceneWidget
|
||||||
{
|
{
|
||||||
friend class MouseState;
|
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
CSVRender::Navigation1st m1st;
|
CSVRender::Navigation1st m1st;
|
||||||
|
@ -154,6 +152,8 @@ namespace CSVRender
|
||||||
void closeRequest();
|
void closeRequest();
|
||||||
|
|
||||||
void dataDropped(const std::vector<CSMWorld::UniversalId>& data);
|
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
|
// TODO: should think about using some kind of reference counting within RigidBody
|
||||||
void PhysicsSystem::removeObject(const std::string &sceneNodeName)
|
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,
|
void PhysicsSystem::replaceObject(const std::string &sceneNodeName, float scale,
|
||||||
const Ogre::Vector3 &position, const Ogre::Quaternion &rotation, bool placeable)
|
const Ogre::Vector3 &position, const Ogre::Quaternion &rotation, bool placeable)
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,6 +51,7 @@ namespace CSVWorld
|
||||||
bool placeable=false);
|
bool placeable=false);
|
||||||
|
|
||||||
void removeObject(const std::string &sceneNodeName);
|
void removeObject(const std::string &sceneNodeName);
|
||||||
|
void removePhysicsObject(const std::string &sceneNodeName);
|
||||||
|
|
||||||
void replaceObject(const std::string &sceneNodeName,
|
void replaceObject(const std::string &sceneNodeName,
|
||||||
float scale, const Ogre::Vector3 &position,
|
float scale, const Ogre::Vector3 &position,
|
||||||
|
|
Loading…
Reference in a new issue