physics_types.h 2.9 KB

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