PhysicsObject.h 962 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Copyright (C) 2009-2016, 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. {
  9. /// @addtogroup physics
  10. /// @{
  11. /// Base of all physics objects.
  12. class PhysicsObject
  13. {
  14. public:
  15. /// Type of the physics object.
  16. enum class Type : U8
  17. {
  18. COLLISION_SHAPE,
  19. BODY,
  20. JOINT,
  21. PLAYER_CONTROLLER,
  22. COUNT
  23. };
  24. PhysicsObject(Type type, PhysicsWorld* world)
  25. : m_world(world)
  26. , m_type(type)
  27. , m_refcount(0)
  28. {
  29. ANKI_ASSERT(m_world);
  30. }
  31. virtual ~PhysicsObject()
  32. {
  33. }
  34. Type getType() const
  35. {
  36. return m_type;
  37. }
  38. PhysicsWorld& getWorld()
  39. {
  40. return *m_world;
  41. }
  42. const PhysicsWorld& getWorld() const
  43. {
  44. return *m_world;
  45. }
  46. Atomic<I32>& getRefcount()
  47. {
  48. return m_refcount;
  49. }
  50. protected:
  51. PhysicsWorld* m_world = nullptr;
  52. private:
  53. Type m_type;
  54. Atomic<I32> m_refcount;
  55. };
  56. /// @}
  57. } // end namespace anki