From fe439e53fffc53e951cfafa690e22e7c536e114d Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 27 May 2015 22:32:11 +0200 Subject: [PATCH] Bullet include cleanup --- apps/openmw/mwphysics/actor.cpp | 8 +++++--- apps/openmw/mwphysics/physicssystem.cpp | 11 +++++++++++ apps/openmw/mwphysics/physicssystem.hpp | 7 +++++-- apps/openmw/mwphysics/trace.cpp | 5 +++-- apps/openmw/mwrender/bulletdebugdraw.cpp | 2 ++ apps/openmw/mwrender/bulletdebugdraw.hpp | 6 ++++-- components/nifbullet/bulletnifloader.cpp | 20 ++++++++++++++++++++ components/nifbullet/bulletnifloader.hpp | 24 ++++-------------------- 8 files changed, 54 insertions(+), 29 deletions(-) diff --git a/apps/openmw/mwphysics/actor.cpp b/apps/openmw/mwphysics/actor.cpp index 7084af862..c47ecd17c 100644 --- a/apps/openmw/mwphysics/actor.cpp +++ b/apps/openmw/mwphysics/actor.cpp @@ -2,12 +2,14 @@ #include -#include - -#include "../mwworld/class.hpp" +#include +#include +#include #include +#include "../mwworld/class.hpp" + #include "convert.hpp" #include "collisiontype.hpp" diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index 065be083d..b706912ed 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -6,6 +6,15 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -600,6 +609,8 @@ namespace MWPhysics mDispatcher = new btCollisionDispatcher(mCollisionConfiguration); mSolver = new btSequentialImpulseConstraintSolver; mBroadphase = new btDbvtBroadphase(); + + // Note we don't use any Dynamics at the moment - a btCollisionWorld might be sufficient? mDynamicsWorld = new btDiscreteDynamicsWorld(mDispatcher,mBroadphase,mSolver,mCollisionConfiguration); // Don't update AABBs of all objects every frame. Most objects in MW are static, so we don't need this. diff --git a/apps/openmw/mwphysics/physicssystem.hpp b/apps/openmw/mwphysics/physicssystem.hpp index 2ebe16e3b..75666acd7 100644 --- a/apps/openmw/mwphysics/physicssystem.hpp +++ b/apps/openmw/mwphysics/physicssystem.hpp @@ -5,8 +5,6 @@ #include -#include - #include #include "../mwworld/ptr.hpp" @@ -35,6 +33,11 @@ namespace Resource class btSequentialImpulseConstraintSolver; class btDiscreteDynamicsWorld; +class btBroadphaseInterface; +class btDefaultCollisionConfiguration; +class btCollisionDispatcher; +class btCollisionObject; +class btCollisionShape; namespace MWPhysics { diff --git a/apps/openmw/mwphysics/trace.cpp b/apps/openmw/mwphysics/trace.cpp index ddb984821..79d4de1a0 100644 --- a/apps/openmw/mwphysics/trace.cpp +++ b/apps/openmw/mwphysics/trace.cpp @@ -2,8 +2,9 @@ #include -#include -#include +#include +#include +#include #include "collisiontype.hpp" #include "actor.hpp" diff --git a/apps/openmw/mwrender/bulletdebugdraw.cpp b/apps/openmw/mwrender/bulletdebugdraw.cpp index 36fc24226..8ac8e3121 100644 --- a/apps/openmw/mwrender/bulletdebugdraw.cpp +++ b/apps/openmw/mwrender/bulletdebugdraw.cpp @@ -2,6 +2,8 @@ #include +#include + #include #include #include diff --git a/apps/openmw/mwrender/bulletdebugdraw.hpp b/apps/openmw/mwrender/bulletdebugdraw.hpp index d2a4163cf..66af2f565 100644 --- a/apps/openmw/mwrender/bulletdebugdraw.hpp +++ b/apps/openmw/mwrender/bulletdebugdraw.hpp @@ -1,12 +1,14 @@ #ifndef OPENMW_MWRENDER_BULLETDEBUGDRAW_H #define OPENMW_MWRENDER_BULLETDEBUGDRAW_H -#include "btBulletDynamicsCommon.h" - #include #include #include +#include + +class btDynamicsWorld; + namespace osg { class Group; diff --git a/components/nifbullet/bulletnifloader.cpp b/components/nifbullet/bulletnifloader.cpp index 89daf898a..33c8c449d 100644 --- a/components/nifbullet/bulletnifloader.cpp +++ b/components/nifbullet/bulletnifloader.cpp @@ -6,6 +6,11 @@ #include #include +#include +#include +#include +#include + #include #include "../nif/niffile.hpp" @@ -36,6 +41,21 @@ btVector3 getbtVector(const osg::Vec3f &v) namespace NifBullet { +// Subclass btBhvTriangleMeshShape to auto-delete the meshInterface +struct TriangleMeshShape : public btBvhTriangleMeshShape +{ + TriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression) + : btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression) + { + } + + virtual ~TriangleMeshShape() + { + delete getTriangleInfoMap(); + delete m_meshInterface; + } +}; + BulletNifLoader::BulletNifLoader() : mCompoundShape(NULL) , mStaticMesh(NULL) diff --git a/components/nifbullet/bulletnifloader.hpp b/components/nifbullet/bulletnifloader.hpp index ae4279f40..0865b134a 100644 --- a/components/nifbullet/bulletnifloader.hpp +++ b/components/nifbullet/bulletnifloader.hpp @@ -6,10 +6,6 @@ #include #include #include -#include -#include -#include -#include #include #include @@ -18,6 +14,10 @@ #include +class btTriangleMesh; +class btCompoundShape; +class btCollisionShape; + namespace Nif { class Node; @@ -70,22 +70,6 @@ private: osg::ref_ptr mSource; }; -// Subclass btBhvTriangleMeshShape to auto-delete the meshInterface -struct TriangleMeshShape : public btBvhTriangleMeshShape -{ - TriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression) - : btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression) - { - } - - virtual ~TriangleMeshShape() - { - delete getTriangleInfoMap(); - delete m_meshInterface; - } -}; - - /** *Load bulletShape from NIF files. */