1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-09 21:42:13 +00:00

Fix collision debug drawer (tcg)

This commit is contained in:
scrawl 2013-02-19 04:03:24 +01:00
parent 627b866744
commit 5d403ebdd3
4 changed files with 22 additions and 7 deletions

View File

@ -186,6 +186,8 @@ namespace MWWorld
mRendering = new MWRender::RenderingManager(renderer, resDir, cacheDir, mPhysEngine);
mPhysEngine->setSceneManager(renderer.getScene());
mWeatherManager = new MWWorld::WeatherManager(mRendering);
int idx = 0;
@ -892,6 +894,8 @@ namespace MWWorld
Ogre::Vector3 vec = mPhysics->move(player->first, player->second, duration, !isSwimming(player->first));
moveObjectImp(player->first, vec.x, vec.y, vec.z);
}
// the only purpose this has currently is to update the debug drawer
mPhysEngine->stepSimulation (duration);
}
bool World::toggleCollisionMode()

View File

@ -207,7 +207,7 @@ public:
mLineDrawer->setMaterial("BtOgre/DebugLines");
mLineDrawer->setVisibilityFlags (1024);
//mLineDrawer->setVisibilityFlags (1024);
}
~DebugDrawer()

View File

@ -191,10 +191,7 @@ namespace Physic
{
if(!isDebugCreated)
{
Ogre::SceneManagerEnumerator::SceneManagerIterator iter = Ogre::Root::getSingleton().getSceneManagerIterator();
iter.begin();
Ogre::SceneManager* scn = iter.getNext();
Ogre::SceneNode* node = scn->getRootSceneNode()->createChildSceneNode();
Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
node->pitch(Ogre::Degree(-90));
mDebugDrawer = new BtOgre::DebugDrawer(node, dynamicsWorld);
dynamicsWorld->setDebugDrawer(mDebugDrawer);
@ -219,6 +216,11 @@ namespace Physic
return mDebugActive;
}
void PhysicEngine::setSceneManager(Ogre::SceneManager* sceneMgr)
{
mSceneMgr = sceneMgr;
}
PhysicEngine::~PhysicEngine()
{
HeightFieldContainer::iterator hf_it = mHeightFieldMap.begin();
@ -471,7 +473,8 @@ namespace Physic
void PhysicEngine::stepSimulation(double deltaT)
{
dynamicsWorld->stepSimulation(deltaT,10, 1/60.0);
// This isn't needed as there are no dynamic objects at this point
//dynamicsWorld->stepSimulation(deltaT,10, 1/60.0);
if(isDebugCreated)
{
mDebugDrawer->step();
@ -494,7 +497,6 @@ namespace Physic
void PhysicEngine::removeCharacter(const std::string &name)
{
//std::cout << "remove";
PhysicActorContainer::iterator it = PhysicActorMap.find(name);
if (it != PhysicActorMap.end() )
{

View File

@ -24,6 +24,11 @@ namespace BtOgre
class DebugDrawer;
}
namespace Ogre
{
class SceneManager;
}
namespace MWWorld
{
class World;
@ -269,6 +274,8 @@ namespace Physic
void getObjectAABB(const std::string &mesh, float scale, btVector3 &min, btVector3 &max);
void setSceneManager(Ogre::SceneManager* sceneMgr);
/**
* Return the closest object hit by a ray. If there are no objects, it will return ("",-1).
*/
@ -305,6 +312,8 @@ namespace Physic
typedef std::map<std::string, PhysicActor*> PhysicActorContainer;
PhysicActorContainer PhysicActorMap;
Ogre::SceneManager* mSceneMgr;
//debug rendering
BtOgre::DebugDrawer* mDebugDrawer;
bool isDebugCreated;