PhysicsTypes.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. Copyright (c) 2013 Daniele Bartolini, Michele Rossi
  3. Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
  4. Permission is hereby granted, free of charge, to any person
  5. obtaining a copy of this software and associated documentation
  6. files (the "Software"), to deal in the Software without
  7. restriction, including without limitation the rights to use,
  8. copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the
  10. Software is furnished to do so, subject to the following
  11. conditions:
  12. The above copyright notice and this permission notice shall be
  13. included in all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  16. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  18. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  19. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  21. OTHER DEALINGS IN THE SOFTWARE.
  22. */
  23. #pragma once
  24. #include "Vector3.h"
  25. namespace crown
  26. {
  27. typedef Id ActorId;
  28. typedef Id ControllerId;
  29. typedef Id TriggerId;
  30. typedef Id JointId;
  31. typedef Id RaycastId;
  32. struct Actor;
  33. //-----------------------------------------------------------------------------
  34. struct ActorType
  35. {
  36. enum Enum
  37. {
  38. STATIC,
  39. DYNAMIC_PHYSICAL,
  40. DYNAMIC_KINEMATIC
  41. };
  42. };
  43. //-----------------------------------------------------------------------------
  44. struct ShapeType
  45. {
  46. enum Enum
  47. {
  48. SPHERE,
  49. CAPSULE,
  50. BOX,
  51. PLANE,
  52. CONVEX_MESH
  53. };
  54. };
  55. //-----------------------------------------------------------------------------
  56. struct JointType
  57. {
  58. enum Enum
  59. {
  60. FIXED,
  61. SPHERICAL,
  62. REVOLUTE,
  63. PRISMATIC,
  64. DISTANCE,
  65. D6
  66. };
  67. };
  68. //-----------------------------------------------------------------------------
  69. struct CollisionGroup
  70. {
  71. enum Enum
  72. {
  73. GROUP_0 = (1<<0), // Collisions disabled
  74. GROUP_1 = (1<<1),
  75. GROUP_2 = (1<<2),
  76. GROUP_3 = (1<<3),
  77. GROUP_4 = (1<<4),
  78. GROUP_5 = (1<<5),
  79. GROUP_6 = (1<<6),
  80. GROUP_7 = (1<<7),
  81. GROUP_8 = (1<<8),
  82. GROUP_9 = (1<<9),
  83. GROUP_10 = (1<<10),
  84. GROUP_11 = (1<<11),
  85. GROUP_12 = (1<<12),
  86. GROUP_13 = (1<<13),
  87. GROUP_14 = (1<<14),
  88. GROUP_15 = (1<<15),
  89. GROUP_16 = (1<<16),
  90. GROUP_17 = (1<<17),
  91. GROUP_18 = (1<<18),
  92. GROUP_19 = (1<<19),
  93. GROUP_20 = (1<<20),
  94. GROUP_21 = (1<<21),
  95. GROUP_22 = (1<<22),
  96. GROUP_23 = (1<<23),
  97. GROUP_24 = (1<<24),
  98. GROUP_25 = (1<<25),
  99. GROUP_26 = (1<<26),
  100. GROUP_27 = (1<<27),
  101. GROUP_28 = (1<<28),
  102. GROUP_29 = (1<<29),
  103. GROUP_30 = (1<<30),
  104. GROUP_31 = (1<<31)
  105. };
  106. };
  107. //-----------------------------------------------------------------------------
  108. struct SceneQueryType
  109. {
  110. enum Enum
  111. {
  112. RAYCAST,
  113. OVERLAP
  114. };
  115. };
  116. //-----------------------------------------------------------------------------
  117. struct SceneQueryMode
  118. {
  119. enum Enum
  120. {
  121. CLOSEST,
  122. ANY,
  123. ALL
  124. };
  125. };
  126. //-----------------------------------------------------------------------------
  127. struct SceneQueryFilter
  128. {
  129. enum Enum
  130. {
  131. STATIC,
  132. DYNAMIC,
  133. BOTH
  134. };
  135. };
  136. namespace physics_world
  137. {
  138. //-----------------------------------------------------------------------------
  139. struct EventType
  140. {
  141. enum Enum
  142. {
  143. COLLISION,
  144. TRIGGER,
  145. SCENE_QUERY
  146. };
  147. };
  148. //-----------------------------------------------------------------------------
  149. struct CollisionEvent
  150. {
  151. Actor* actors[2];
  152. Vector3 where;
  153. };
  154. //-----------------------------------------------------------------------------
  155. struct TriggerEvent
  156. {
  157. Actor* actor;
  158. };
  159. //-----------------------------------------------------------------------------
  160. struct SceneQueryEvent
  161. {
  162. const char* callback;
  163. SceneQueryType::Enum type;
  164. SceneQueryMode::Enum mode;
  165. bool hit;
  166. Vector3 position;
  167. float distance;
  168. Vector3 normal;
  169. Actor* actor;
  170. };
  171. }
  172. } // namespace crown