controller.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (c) 2012-2014 Daniele Bartolini and individual contributors.
  3. * License: https://github.com/taylor001/crown/blob/master/LICENSE
  4. */
  5. #pragma once
  6. #include "physics_callback.h"
  7. #include "resource_types.h"
  8. #include "math_types.h"
  9. #include "PxController.h"
  10. #include "PxControllerManager.h"
  11. using physx::PxController;
  12. using physx::PxControllerManager;
  13. using physx::PxPhysics;
  14. using physx::PxScene;
  15. using physx::PxU32;
  16. namespace crown
  17. {
  18. struct SceneGraph;
  19. ///
  20. /// @ingroup Physics
  21. struct Controller
  22. {
  23. Controller(const PhysicsResource* pr, SceneGraph& sg, int32_t node, PxPhysics* physics, PxControllerManager* manager);
  24. ~Controller();
  25. /// Moves the controller to @a pos.
  26. void move(const Vector3& pos);
  27. /// Sets the contoller height.
  28. void set_height(float height);
  29. /// Returns whether the contoller collides upwards.
  30. bool collides_up() const;
  31. /// Returns whether the controller collides downwards.
  32. bool collides_down() const;
  33. /// Returns whether the controller collides sidewards.
  34. bool collides_sides() const;
  35. /// Returns the position of the controller.
  36. Vector3 position() const;
  37. void update();
  38. private:
  39. const PhysicsResource* m_resource;
  40. SceneGraph& m_scene_graph;
  41. int32_t m_node;
  42. PxControllerManager* m_manager;
  43. PxController* m_controller;
  44. PxU32 m_flags;
  45. PhysicsControllerCallback m_callback;
  46. };
  47. } // namespace crown