JointComponent.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <AnKi/Scene/Components/SceneComponent.h>
  7. #include <AnKi/Physics/PhysicsJoint.h>
  8. namespace anki {
  9. enum class JointComponentyType : U8
  10. {
  11. kPoint,
  12. kHinge,
  13. kCount,
  14. kFirst = 0
  15. };
  16. ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(JointComponentyType)
  17. inline constexpr Array<const Char*, U32(JointComponentyType::kCount)> kJointComponentTypeName = {"Point", "Hinge"};
  18. // Contains a single joint that connects the parent node with the 1st child node of the node that has this component.
  19. class JointComponent : public SceneComponent
  20. {
  21. ANKI_SCENE_COMPONENT(JointComponent)
  22. public:
  23. JointComponent(SceneNode* node);
  24. ~JointComponent();
  25. void setJointType(JointComponentyType type)
  26. {
  27. if(ANKI_EXPECT(type < JointComponentyType::kCount))
  28. {
  29. m_type = type;
  30. }
  31. }
  32. JointComponentyType getJointType() const
  33. {
  34. return m_type;
  35. }
  36. Bool isValid() const;
  37. private:
  38. PhysicsJointPtr m_joint;
  39. SceneNode* m_node = nullptr;
  40. U32 m_parentNodeUuid = 0;
  41. U32 m_childNodeUuid = 0;
  42. JointComponentyType m_type = JointComponentyType::kPoint;
  43. void update(SceneComponentUpdateInfo& info, Bool& updated) override;
  44. };
  45. } // end namespace anki