physics_types.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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 JointId;
  30. typedef Id RaycastId;
  31. struct Actor;
  32. struct Controller;
  33. struct Joint;
  34. struct Raycast;
  35. class PhysicsWorld;
  36. //-----------------------------------------------------------------------------
  37. struct ActorType
  38. {
  39. enum Enum
  40. {
  41. STATIC,
  42. DYNAMIC_PHYSICAL,
  43. DYNAMIC_KINEMATIC
  44. };
  45. };
  46. //-----------------------------------------------------------------------------
  47. struct ShapeType
  48. {
  49. enum Enum
  50. {
  51. SPHERE,
  52. CAPSULE,
  53. BOX,
  54. PLANE,
  55. CONVEX_MESH
  56. };
  57. };
  58. //-----------------------------------------------------------------------------
  59. struct JointType
  60. {
  61. enum Enum
  62. {
  63. FIXED,
  64. SPHERICAL,
  65. REVOLUTE,
  66. PRISMATIC,
  67. DISTANCE,
  68. D6
  69. };
  70. };
  71. //-----------------------------------------------------------------------------
  72. struct CollisionGroup
  73. {
  74. enum Enum
  75. {
  76. GROUP_0 = (1<<0), // Collisions disabled
  77. GROUP_1 = (1<<1),
  78. GROUP_2 = (1<<2),
  79. GROUP_3 = (1<<3),
  80. GROUP_4 = (1<<4),
  81. GROUP_5 = (1<<5),
  82. GROUP_6 = (1<<6),
  83. GROUP_7 = (1<<7),
  84. GROUP_8 = (1<<8),
  85. GROUP_9 = (1<<9),
  86. GROUP_10 = (1<<10),
  87. GROUP_11 = (1<<11),
  88. GROUP_12 = (1<<12),
  89. GROUP_13 = (1<<13),
  90. GROUP_14 = (1<<14),
  91. GROUP_15 = (1<<15),
  92. GROUP_16 = (1<<16),
  93. GROUP_17 = (1<<17),
  94. GROUP_18 = (1<<18),
  95. GROUP_19 = (1<<19),
  96. GROUP_20 = (1<<20),
  97. GROUP_21 = (1<<21),
  98. GROUP_22 = (1<<22),
  99. GROUP_23 = (1<<23),
  100. GROUP_24 = (1<<24),
  101. GROUP_25 = (1<<25),
  102. GROUP_26 = (1<<26),
  103. GROUP_27 = (1<<27),
  104. GROUP_28 = (1<<28),
  105. GROUP_29 = (1<<29),
  106. GROUP_30 = (1<<30),
  107. GROUP_31 = (1<<31)
  108. };
  109. };
  110. //-----------------------------------------------------------------------------
  111. struct CollisionType
  112. {
  113. enum Enum
  114. {
  115. STATIC,
  116. DYNAMIC,
  117. BOTH
  118. };
  119. };
  120. //-----------------------------------------------------------------------------
  121. struct CollisionMode
  122. {
  123. enum Enum
  124. {
  125. CLOSEST,
  126. ANY,
  127. ALL
  128. };
  129. };
  130. namespace physics_world
  131. {
  132. //-----------------------------------------------------------------------------
  133. struct EventType
  134. {
  135. enum Enum
  136. {
  137. COLLISION,
  138. TRIGGER
  139. };
  140. };
  141. //-----------------------------------------------------------------------------
  142. struct CollisionEvent
  143. {
  144. enum { BEGIN_TOUCH, END_TOUCH } type;
  145. Actor* actors[2];
  146. Vector3 where;
  147. Vector3 normal;
  148. };
  149. //-----------------------------------------------------------------------------
  150. struct TriggerEvent
  151. {
  152. enum { BEGIN_TOUCH, END_TOUCH } type;
  153. Actor* trigger;
  154. Actor* other;
  155. };
  156. } // namespace physics_world
  157. } // namespace crown