Experimental, compiles and runs but crashes in some exit scenarios.

loadfix
cc9cii 10 years ago
parent d48a2759f6
commit 0e70315f91

@ -68,7 +68,7 @@ opencs_units (view/world
opencs_units_noqt (view/world
subviews enumdelegate vartypedelegate recordstatusdelegate idtypedelegate datadisplaydelegate
scripthighlighter idvalidator dialoguecreator physicssystem physicsmanager
scripthighlighter idvalidator dialoguecreator physicssystem physicsmanager physicsengine
)
opencs_units (view/widget

@ -266,7 +266,9 @@ namespace CSVRender
void MouseState::mouseDoubleClickEvent (QMouseEvent *event)
{
event->ignore();
//event->ignore();
mPhysics->toggleDebugRendering(mSceneManager);
mParent->flagAsModified();
}
bool MouseState::wheelEvent (QWheelEvent *event)

@ -74,6 +74,9 @@ namespace CSVWorld
throw std::runtime_error("No physics system found for the given document.");
}
// deprecated by removeDocument() and may be deleted in future code updates
// however there may be some value in removing the deleted scene widgets from the
// list so that the list does not grow forever
void PhysicsManager::removeSceneWidget(CSVRender::WorldspaceWidget *widget)
{
CSVRender::SceneWidget *sceneWidget = static_cast<CSVRender::SceneWidget *>(widget);

@ -6,7 +6,7 @@
#include <OgreCamera.h>
#include <OgreSceneManager.h>
#include <openengine/bullet/physic.hpp>
#include "physicsengine.hpp"
#include <components/nifbullet/bulletnifloader.hpp>
#include "../../model/settings/usersettings.hpp"
#include "../render/elements.hpp"
@ -15,17 +15,12 @@ namespace CSVWorld
{
PhysicsSystem::PhysicsSystem()
{
// Create physics. shapeLoader is deleted by the physic engine
NifBullet::ManualBulletShapeLoader* shapeLoader = new NifBullet::ManualBulletShapeLoader();
mEngine = new OEngine::Physic::PhysicEngine(shapeLoader);
mEngine = new PhysicsEngine();
}
PhysicsSystem::~PhysicsSystem()
{
// FIXME: OEngine does not behave well when multiple instances are created
// and deleted, sometimes resulting in crashes. Skip the deletion until the physics
// code is moved out of OEngine.
//delete mEngine;
delete mEngine;
}
// looks up the scene manager based on the scene node name (inefficient)
@ -56,8 +51,6 @@ namespace CSVWorld
{
mEngine->createAndAdjustRigidBody(mesh,
referenceId, scale, position, rotation,
0, // scaledBoxTranslation
0, // boxRotation
true, // raycasting
placeable);
}
@ -146,7 +139,7 @@ namespace CSVWorld
// create a new physics object
mEngine->createAndAdjustRigidBody(mesh, referenceId, scale, position, rotation,
0, 0, true, placeable);
true, placeable);
// update other scene managers if they have the referenceId
// FIXME: rotation or scale not updated
@ -278,6 +271,8 @@ namespace CSVWorld
void PhysicsSystem::addSceneManager(Ogre::SceneManager *sceneMgr, CSVRender::SceneWidget *sceneWidget)
{
mSceneWidgets[sceneMgr] = sceneWidget;
mEngine->createDebugDraw(sceneMgr);
}
std::map<Ogre::SceneManager*, CSVRender::SceneWidget *> PhysicsSystem::sceneWidgets()
@ -287,6 +282,8 @@ namespace CSVWorld
void PhysicsSystem::removeSceneManager(Ogre::SceneManager *sceneMgr)
{
mEngine->removeDebugDraw(sceneMgr);
mSceneWidgets.erase(sceneMgr);
}
@ -310,8 +307,6 @@ namespace CSVWorld
if(!sceneMgr)
return;
mEngine->setSceneManager(sceneMgr);
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
if(!(userSettings.setting("debug/mouse-picking", QString("false")) == "true" ? true : false))
{
@ -319,7 +314,7 @@ namespace CSVWorld
return;
}
mEngine->toggleDebugRendering();
mEngine->stepSimulation(0.0167); // DebugDrawer::step() not directly accessible
mEngine->toggleDebugRendering(sceneMgr);
mEngine->stepDebug(sceneMgr);
}
}

@ -12,14 +12,6 @@ namespace Ogre
class Camera;
}
namespace OEngine
{
namespace Physic
{
class PhysicEngine;
}
}
namespace CSVRender
{
class SceneWidget;
@ -27,13 +19,15 @@ namespace CSVRender
namespace CSVWorld
{
class PhysicsEngine;
class PhysicsSystem
{
std::map<std::string, std::string> mSceneNodeToRefId;
std::map<std::string, std::map<Ogre::SceneManager *, std::string> > mRefIdToSceneNode;
std::map<std::string, std::string> mSceneNodeToMesh;
std::map<Ogre::SceneManager*, CSVRender::SceneWidget *> mSceneWidgets;
OEngine::Physic::PhysicEngine* mEngine;
PhysicsEngine* mEngine;
std::multimap<std::string, Ogre::SceneManager *> mTerrain;
public:

Loading…
Cancel
Save