bump.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. #ifndef BUMP_H_INCLUDED
  2. #define BUMP_H_INCLUDED
  3. #include "bevec.h"
  4. #include "bumpshape.h"
  5. typedef struct BumpBody_ BumpBody;
  6. typedef struct BumpHull_ BumpHull;
  7. typedef struct BumpHoopHull_ BumpHoopHull;
  8. typedef struct BumpBoxHull_ BumpBoxHull;
  9. typedef struct BumpTilemap_ BumpTilemap;
  10. typedef struct BumpWorld_ BumpWorld;
  11. enum BumpTile_ {
  12. BUMP_TILE_NONE = 0,
  13. BUMP_TILE_WALL = 1 << 1,
  14. BUMP_TILE_WATER = 1 << 2,
  15. BUMP_TILE_LEDGE = 1 << 3,
  16. BUMP_TILE_STAIR = 1 << 4,
  17. BUMP_TILE_PUSH = 1 << 5,
  18. BUMP_TILE_NORTH = 1 << 6,
  19. BUMP_TILE_SOUTH = 1 << 7,
  20. BUMP_TILE_EAST = 1 << 8,
  21. BUMP_TILE_WEST = 1 << 9,
  22. BUMP_TILE_UP = 1 << 10,
  23. BUMP_TILE_DOWN = 1 << 11,
  24. BUMP_TILE_ICE = 1 << 12,
  25. };
  26. typedef enum BumpTile_ BumpTile;
  27. enum BumpFlag_ {
  28. /* Default hull flags. */
  29. BUMP_FLAG_NORMAL = 0,
  30. /* Sensor hulls detect collisions but don't push or get pushed. */
  31. BUMP_FLAG_SENSOR = 1 << 1,
  32. /* Disabled hulls are temporary disabled and do nothing.
  33. * They may show up in hull searches, though. */
  34. BUMP_FLAG_DISABLED = 1 << 2,
  35. /* User defined flags start from this value */
  36. BUMP_FLAG_USER1 = 1 << 16,
  37. BUMP_FLAG_USER2 = 1 << 17,
  38. BUMP_FLAG_USER3 = 1 << 18,
  39. BUMP_FLAG_USER4 = 1 << 19,
  40. };
  41. enum BumpKind_ {
  42. BUMP_KIND_PLAYER = 1,
  43. BUMP_KIND_NPC = 2,
  44. BUMP_KIND_FOE = 3,
  45. BUMP_KIND_SWITCH = 4,
  46. BUMP_KIND_TREASURE = 5,
  47. BUMP_KIND_PLATE = 6,
  48. BUMP_KIND_BOX = 7,
  49. BUMP_KIND_ATTACK = 128,
  50. /* Flag to mark search hulls. */
  51. BUMP_KIND_SEARCH = 129,
  52. /* Flag to mark art or technique hulls. */
  53. BUMP_KIND_ART = 130,
  54. };
  55. BumpBody * bumpbody_alloc();
  56. BumpBody * bumpbody_init(BumpBody * self, BeVec p, double mass);
  57. BumpBody * bumpbody_new(BeVec p, double mass);
  58. BumpBody * bumpbody_done(BumpBody * self);
  59. BumpBody * bumpbody_free(BumpBody * self);
  60. BeVec bumpbody_p(BumpBody * self);
  61. BeVec bumpbody_v(BumpBody * self);
  62. BeVec bumpbody_a(BumpBody * self);
  63. void * bumpbody_data(BumpBody * self);
  64. BeVec bumpbody_p_(BumpBody * self, BeVec v);
  65. BeVec bumpbody_v_(BumpBody * self, BeVec v);
  66. BeVec bumpbody_a_(BumpBody * self, BeVec v);
  67. void bumpbody_data_(BumpBody * self, void * data);
  68. BeVec bumpbody_p_impulse(BumpBody * self, BeVec v);
  69. BeVec bumpbody_v_impulse(BumpBody * self, BeVec v);
  70. BeVec bumpbody_a_impulse(BumpBody * self, BeVec v);
  71. void bumpbody_applyforce(BumpBody * self, BeVec v);
  72. void bumpbody_applyimpulse(BumpBody * self, BeVec v);
  73. void bumpbody_resetforces(BumpBody * self);
  74. BumpHull * bumphull_alloc();
  75. BumpHull * bumphull_initall(BumpHull * self,
  76. BumpBody * body, BeVec delta,
  77. BumpAABB bounds, int layers, int kind);
  78. BumpHull * bumphull_init(BumpHull * self, BumpBody * body, BumpAABB bounds);
  79. BumpHull * bumphull_newall(BumpBody * body,
  80. BeVec delta, BumpAABB bounds, int layers, int kind);
  81. BumpHull * bumphull_new(BumpBody * body, BumpAABB bounds);
  82. BumpHull * bumphull_done(BumpHull * self);
  83. BumpHull * bumphull_free(BumpHull * self);
  84. BumpHull * bumphull_layers_(BumpHull * hull, int layers);
  85. int bumphull_layers(BumpHull * hull);
  86. BumpHull * bumphull_kind_(BumpHull * hull, int kind);
  87. int bumphull_layers(BumpHull * hull);
  88. void * bumphull_body_data(BumpHull * hull);
  89. int bumphull_flags(BumpHull * hull);
  90. int bumphull_flags_(BumpHull * hull, int flags);
  91. int bumphull_get_flag(BumpHull * hull, int flag);
  92. int bumphull_set_flag(BumpHull * hull, int flag);
  93. int bumphull_unset_flag(BumpHull * hull, int flag);
  94. BumpAABB bumphull_aabb(BumpHull * hull);
  95. BumpAABB * bumphull_aabbptr(BumpHull * hull);
  96. BumpBody * bumphull_body(BumpHull * hull);
  97. int bumphull_id(BumpHull * hull);
  98. BumpWorld * bumpworld_alloc();
  99. BumpWorld * bumpworld_init(BumpWorld * self);
  100. BumpWorld * bumpworld_new();
  101. BumpWorld * bumpworld_done(BumpWorld * self);
  102. BumpWorld * bumpworld_free(BumpWorld * self);
  103. BumpBody * bumpworld_movebody(BumpWorld * to, BumpWorld * from, BumpBody * body);
  104. BumpHull * bumpworld_hull(BumpWorld * self, int index);
  105. BumpBody * bumpworld_body(BumpWorld * self, int index);
  106. int bumpworld_body_count(BumpWorld * self);
  107. int bumpworld_hull_count(BumpWorld * self);
  108. BumpBody * bumpworld_add_body(BumpWorld * self, BumpBody * body);
  109. BumpHull * bumpworld_add_hull(BumpWorld * self, BumpHull * hull);
  110. BumpHull * bumpworld_new_hull(BumpWorld * self, BumpBody * body, BeVec delta, BumpAABB bounds, int layers, int kind);
  111. BumpHull * bumpworld_remove_hull(BumpWorld * self, BumpHull * hull);
  112. BumpBody * bumpworld_remove_body_only(BumpWorld * self, BumpBody * body);
  113. BumpWorld * bumpworld_delete_hull(BumpWorld * self, BumpHull * hull);
  114. BumpWorld * bumpworld_delete_body_only(BumpWorld * self, BumpBody * body);
  115. BumpWorld * bumpworld_delete_body_only_index(BumpWorld * self, int index);
  116. BumpWorld * bumpworld_delete_hull_index(BumpWorld * self, int index);
  117. BumpWorld * bumpworld_delete_hulls_for(BumpWorld * self, BumpBody * body);
  118. BumpWorld * bumpworld_delete_body(BumpWorld * world, BumpBody * body);
  119. BumpWorld * bumpworld_delete_body_index(BumpWorld * world, int index);
  120. void * bumpworld_tilemap_(BumpWorld * self, void * map);
  121. BumpWorld * bumpworld_update(BumpWorld * self, double dt);
  122. BumpWorld * bumpworld_commit(BumpWorld * self);
  123. BumpWorld * bumpworld_draw_debug(BumpWorld * self);
  124. int bumphull_support(BumpHull * hull);
  125. int bumpworld_find_hulls(BumpWorld * self, BumpAABB search, void * extra,
  126. int (*callback)(BumpHull * hull, void * extra));
  127. int bumpworld_find_and_fetch_hulls(BumpWorld * self, BumpAABB search,
  128. BumpHull ** hulls, int max_hulls);
  129. int bumpworld_fetch_body_hulls(BumpWorld * self, BumpBody * body,
  130. BumpHull ** hulls, int max_hulls);
  131. int bumpworld_find_body_hulls(BumpWorld * self, BumpBody * body, void * extra,
  132. int (*callback)(BumpHull * hull, void * extra));
  133. int bumpworld_set_hull_flag(BumpWorld * me, int index, int flag);
  134. int bumpworld_unset_hull_flag(BumpWorld * me, int index, int flag);
  135. int bumpworld_hull_flags_(BumpWorld * me, int index, int flags);
  136. int bumpworld_hull_flags(BumpWorld * me, int index);
  137. int bumphull_group(BumpHull * hull);
  138. int bumphull_group_(BumpHull * hull, int group);
  139. #endif