btPlayer.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 _BTPLAYER_H
  23. #define _BTPLAYER_H
  24. #ifndef _T3D_PHYSICS_PHYSICSPLAYER_H_
  25. #include "T3D/physics/physicsPlayer.h"
  26. #endif
  27. class BtWorld;
  28. //class btKinematicCharacterController;
  29. class btPairCachingGhostObject;
  30. class btConvexShape;
  31. class btVector3;
  32. class BtPlayer : public PhysicsPlayer
  33. {
  34. protected:
  35. //F32 mSkinWidth;
  36. BtWorld *mWorld;
  37. SceneObject *mObject;
  38. ///
  39. //btKinematicCharacterController *mController;
  40. ///
  41. btPairCachingGhostObject *mGhostObject;
  42. ///
  43. btConvexShape *mColShape;
  44. ///
  45. F32 mOriginOffset;
  46. ///
  47. F32 mSlopeAngle;
  48. ///
  49. ///
  50. F32 mStepHeight;
  51. ///
  52. void _releaseController();
  53. ///
  54. bool _recoverFromPenetration();
  55. ///
  56. bool _sweep( btVector3 *inOutCurrPos, const btVector3 &disp, CollisionList *outCol );
  57. ///
  58. void _stepForward( btVector3 *inOutCurrPos, const btVector3 &displacement, CollisionList *outCol );
  59. public:
  60. BtPlayer();
  61. virtual ~BtPlayer();
  62. // PhysicsObject
  63. virtual PhysicsWorld* getWorld();
  64. virtual void setTransform( const MatrixF &transform );
  65. virtual MatrixF& getTransform( MatrixF *outMatrix );
  66. virtual void setScale( const Point3F &scale );
  67. virtual Box3F getWorldBounds() { return Box3F::Invalid; }
  68. virtual void setSimulationEnabled( bool enabled ) {}
  69. virtual bool isSimulationEnabled() { return true; }
  70. // PhysicsPlayer
  71. virtual void init( const char *type,
  72. const Point3F &size,
  73. F32 runSurfaceCos,
  74. F32 stepHeight,
  75. SceneObject *obj,
  76. PhysicsWorld *world );
  77. virtual Point3F move( const VectorF &displacement, CollisionList &outCol );
  78. virtual void findContact( SceneObject **contactObject, VectorF *contactNormal, Vector<SceneObject*> *outOverlapObjects ) const;
  79. virtual bool testSpacials( const Point3F &nPos, const Point3F &nSize ) const { return true; }
  80. virtual void setSpacials( const Point3F &nPos, const Point3F &nSize ) {}
  81. virtual void enableCollision();
  82. virtual void disableCollision();
  83. };
  84. #endif // _BTPLAYER_H