PhysicsObject.h 960 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright (C) 2009-2015, Panagiotis Christopoulos Charitos.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include "anki/physics/Common.h"
  7. namespace anki {
  8. /// @addtogroup physics
  9. /// @{
  10. /// Base of all physics objects.
  11. class PhysicsObject
  12. {
  13. public:
  14. /// Type of the physics object.
  15. enum class Type: U8
  16. {
  17. COLLISION_SHAPE,
  18. BODY,
  19. JOINT,
  20. PLAYER_CONTROLLER,
  21. COUNT
  22. };
  23. PhysicsObject(Type type, PhysicsWorld* world)
  24. : m_world(world)
  25. , m_type(type)
  26. , m_refcount(0)
  27. {
  28. ANKI_ASSERT(m_world);
  29. }
  30. virtual ~PhysicsObject()
  31. {}
  32. Type getType() const
  33. {
  34. return m_type;
  35. }
  36. PhysicsWorld& getWorld()
  37. {
  38. return *m_world;
  39. }
  40. const PhysicsWorld& getWorld() const
  41. {
  42. return *m_world;
  43. }
  44. Atomic<I32>& getRefcount()
  45. {
  46. return m_refcount;
  47. }
  48. protected:
  49. PhysicsWorld* m_world = nullptr;
  50. private:
  51. Type m_type;
  52. Atomic<I32> m_refcount;
  53. };
  54. /// @}
  55. } // end namespace anki