RegisterTypes.cpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #include <Jolt/Jolt.h>
  4. #include <Jolt/RegisterTypes.h>
  5. #include <Jolt/Core/Factory.h>
  6. #include <Jolt/Core/RTTI.h>
  7. #include <Jolt/Physics/Collision/Shape/TriangleShape.h>
  8. #include <Jolt/Physics/Collision/Shape/SphereShape.h>
  9. #include <Jolt/Physics/Collision/Shape/BoxShape.h>
  10. #include <Jolt/Physics/Collision/Shape/CapsuleShape.h>
  11. #include <Jolt/Physics/Collision/Shape/TaperedCapsuleShape.h>
  12. #include <Jolt/Physics/Collision/Shape/CylinderShape.h>
  13. #include <Jolt/Physics/Collision/Shape/ScaledShape.h>
  14. #include <Jolt/Physics/Collision/Shape/MeshShape.h>
  15. #include <Jolt/Physics/Collision/Shape/ConvexHullShape.h>
  16. #include <Jolt/Physics/Collision/Shape/HeightFieldShape.h>
  17. #include <Jolt/Physics/Collision/Shape/RotatedTranslatedShape.h>
  18. #include <Jolt/Physics/Collision/Shape/OffsetCenterOfMassShape.h>
  19. #include <Jolt/Physics/Collision/Shape/MutableCompoundShape.h>
  20. #include <Jolt/Physics/Collision/Shape/StaticCompoundShape.h>
  21. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, Skeleton)
  22. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, SkeletalAnimation)
  23. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, CompoundShapeSettings)
  24. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, StaticCompoundShapeSettings)
  25. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, MutableCompoundShapeSettings)
  26. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, TriangleShapeSettings)
  27. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, SphereShapeSettings)
  28. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, BoxShapeSettings)
  29. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, CapsuleShapeSettings)
  30. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, TaperedCapsuleShapeSettings)
  31. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, CylinderShapeSettings)
  32. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, ScaledShapeSettings)
  33. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, MeshShapeSettings)
  34. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, ConvexHullShapeSettings)
  35. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, HeightFieldShapeSettings)
  36. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, RotatedTranslatedShapeSettings)
  37. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, OffsetCenterOfMassShapeSettings)
  38. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, RagdollSettings)
  39. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, PointConstraintSettings)
  40. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, SixDOFConstraintSettings)
  41. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, SliderConstraintSettings)
  42. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, SwingTwistConstraintSettings)
  43. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, DistanceConstraintSettings)
  44. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, HingeConstraintSettings)
  45. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, FixedConstraintSettings)
  46. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, ConeConstraintSettings)
  47. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, PathConstraintSettings)
  48. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, PathConstraintPath)
  49. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, PathConstraintPathHermite)
  50. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, VehicleConstraintSettings)
  51. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, WheeledVehicleControllerSettings)
  52. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, MotorSettings)
  53. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, PhysicsScene)
  54. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, PhysicsMaterial)
  55. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, PhysicsMaterialSimple)
  56. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, GroupFilter)
  57. JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH, GroupFilterTable)
  58. JPH_NAMESPACE_BEGIN
  59. void RegisterTypes()
  60. {
  61. JPH_ASSERT(Factory::sInstance != nullptr, "Need to create a factory first!");
  62. // Register base classes first so that we can specialize them later
  63. CompoundShape::sRegister();
  64. ConvexShape::sRegister();
  65. // Register compounds before others so that we can specialize them later (register them in reverse order of collision complexity)
  66. MutableCompoundShape::sRegister();
  67. StaticCompoundShape::sRegister();
  68. // Leaf classes
  69. TriangleShape::sRegister();
  70. SphereShape::sRegister();
  71. BoxShape::sRegister();
  72. CapsuleShape::sRegister();
  73. TaperedCapsuleShape::sRegister();
  74. CylinderShape::sRegister();
  75. MeshShape::sRegister();
  76. ConvexHullShape::sRegister();
  77. HeightFieldShape::sRegister();
  78. // Register these last because their collision functions are simple so we want to execute them first (register them in reverse order of collision complexity)
  79. RotatedTranslatedShape::sRegister();
  80. OffsetCenterOfMassShape::sRegister();
  81. ScaledShape::sRegister();
  82. // Create list of all types
  83. const RTTI *types[] = {
  84. JPH_RTTI(SkeletalAnimation),
  85. JPH_RTTI(Skeleton),
  86. JPH_RTTI(CompoundShapeSettings),
  87. JPH_RTTI(StaticCompoundShapeSettings),
  88. JPH_RTTI(MutableCompoundShapeSettings),
  89. JPH_RTTI(TriangleShapeSettings),
  90. JPH_RTTI(SphereShapeSettings),
  91. JPH_RTTI(BoxShapeSettings),
  92. JPH_RTTI(CapsuleShapeSettings),
  93. JPH_RTTI(TaperedCapsuleShapeSettings),
  94. JPH_RTTI(CylinderShapeSettings),
  95. JPH_RTTI(ScaledShapeSettings),
  96. JPH_RTTI(MeshShapeSettings),
  97. JPH_RTTI(ConvexHullShapeSettings),
  98. JPH_RTTI(HeightFieldShapeSettings),
  99. JPH_RTTI(RotatedTranslatedShapeSettings),
  100. JPH_RTTI(OffsetCenterOfMassShapeSettings),
  101. JPH_RTTI(RagdollSettings),
  102. JPH_RTTI(PointConstraintSettings),
  103. JPH_RTTI(SixDOFConstraintSettings),
  104. JPH_RTTI(SliderConstraintSettings),
  105. JPH_RTTI(SwingTwistConstraintSettings),
  106. JPH_RTTI(DistanceConstraintSettings),
  107. JPH_RTTI(HingeConstraintSettings),
  108. JPH_RTTI(FixedConstraintSettings),
  109. JPH_RTTI(ConeConstraintSettings),
  110. JPH_RTTI(PathConstraintSettings),
  111. JPH_RTTI(VehicleConstraintSettings),
  112. JPH_RTTI(WheeledVehicleControllerSettings),
  113. JPH_RTTI(PathConstraintPath),
  114. JPH_RTTI(PathConstraintPathHermite),
  115. JPH_RTTI(MotorSettings),
  116. JPH_RTTI(PhysicsScene),
  117. JPH_RTTI(PhysicsMaterial),
  118. JPH_RTTI(PhysicsMaterialSimple),
  119. JPH_RTTI(GroupFilter),
  120. JPH_RTTI(GroupFilterTable)
  121. };
  122. // Register them all
  123. Factory::sInstance->Register(types, (uint)size(types));
  124. }
  125. JPH_NAMESPACE_END