controller.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) 2012-2015 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 "world_types.h"
  8. #include "resource_types.h"
  9. #include "math_types.h"
  10. #include "PxController.h"
  11. #include "PxControllerManager.h"
  12. using physx::PxController;
  13. using physx::PxControllerManager;
  14. using physx::PxPhysics;
  15. using physx::PxScene;
  16. using physx::PxU32;
  17. namespace crown
  18. {
  19. struct SceneGraph;
  20. ///
  21. /// @ingroup Physics
  22. struct Controller
  23. {
  24. Controller(const ControllerResource* cr, SceneGraph& sg, UnitId id, PxPhysics* physics, PxControllerManager* manager);
  25. ~Controller();
  26. /// Moves the controller to @a pos.
  27. void move(const Vector3& pos);
  28. /// Sets the contoller height.
  29. void set_height(float height);
  30. /// Returns whether the contoller collides upwards.
  31. bool collides_up() const;
  32. /// Returns whether the controller collides downwards.
  33. bool collides_down() const;
  34. /// Returns whether the controller collides sidewards.
  35. bool collides_sides() const;
  36. /// Returns the position of the controller.
  37. Vector3 position() const;
  38. void update();
  39. private:
  40. const ControllerResource* m_resource;
  41. SceneGraph& m_scene_graph;
  42. UnitId _unit_id;
  43. PxControllerManager* m_manager;
  44. PxController* m_controller;
  45. PxU32 m_flags;
  46. PhysicsControllerCallback m_callback;
  47. };
  48. } // namespace crown