btWorld.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _BTWORLD_H_
  23. #define _BTWORLD_H_
  24. #ifndef _T3D_PHYSICS_PHYSICSWORLD_H_
  25. #include "T3D/physics/physicsWorld.h"
  26. #endif
  27. #ifndef _T3D_PHYSICS_BTDEBUGDRAW_H_
  28. #include "T3D/physics/bullet/btDebugDraw.h"
  29. #endif
  30. #ifndef _BULLET_H_
  31. #include "T3D/physics/bullet/bt.h"
  32. #endif
  33. #ifndef _TVECTOR_H_
  34. #include "core/util/tVector.h"
  35. #endif
  36. class ProcessList;
  37. class PhysicsBody;
  38. class BtWorld : public PhysicsWorld
  39. {
  40. protected:
  41. BtDebugDraw mDebugDraw;
  42. F32 mEditorTimeScale;
  43. btDynamicsWorld *mDynamicsWorld;
  44. btBroadphaseInterface *mBroadphase;
  45. btCollisionDispatcher *mDispatcher;
  46. btConstraintSolver *mSolver;
  47. btDefaultCollisionConfiguration *mCollisionConfiguration;
  48. bool mErrorReport;
  49. bool mIsEnabled;
  50. bool mIsSimulating;
  51. U32 mTickCount;
  52. ProcessList *mProcessList;
  53. void _destroy();
  54. public:
  55. BtWorld();
  56. virtual ~BtWorld();
  57. // PhysicWorld
  58. virtual bool initWorld( bool isServer, ProcessList *processList );
  59. virtual void destroyWorld();
  60. virtual bool castRay( const Point3F &startPnt, const Point3F &endPnt, RayInfo *ri, const Point3F &impulse );
  61. virtual PhysicsBody* castRay( const Point3F &start, const Point3F &end, U32 bodyTypes );
  62. virtual void explosion( const Point3F &pos, F32 radius, F32 forceMagnitude );
  63. virtual void onDebugDraw( const SceneRenderState *state );
  64. virtual void reset();
  65. virtual bool isEnabled() const { return mIsEnabled; }
  66. btDynamicsWorld* getDynamicsWorld() const { return mDynamicsWorld; }
  67. void tickPhysics( U32 elapsedMs );
  68. void getPhysicsResults();
  69. bool isWritable() const { return !mIsSimulating; }
  70. void setEnabled( bool enabled );
  71. bool getEnabled() const { return mIsEnabled; }
  72. void setEditorTimeScale( F32 timeScale ) { mEditorTimeScale = timeScale; }
  73. const F32 getEditorTimeScale() const { return mEditorTimeScale; }
  74. };
  75. #endif // _BTWORLD_H_