shape_sw.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. /**************************************************************************/
  2. /* shape_sw.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef SHAPE_SW_H
  31. #define SHAPE_SW_H
  32. #include "core/local_vector.h"
  33. #include "core/math/bsp_tree.h"
  34. #include "core/math/geometry.h"
  35. #include "servers/physics_server.h"
  36. /*
  37. SHAPE_LINE, ///< plane:"plane"
  38. SHAPE_SEGMENT, ///< real_t:"length"
  39. SHAPE_CIRCLE, ///< real_t:"radius"
  40. SHAPE_RECTANGLE, ///< vec3:"extents"
  41. SHAPE_CONVEX_POLYGON, ///< array of planes:"planes"
  42. SHAPE_CONCAVE_POLYGON, ///< Vector3 array:"triangles" , or Dictionary with "indices" (int array) and "triangles" (Vector3 array)
  43. SHAPE_CUSTOM, ///< Server-Implementation based custom shape, calling shape_create() with this value will result in an error
  44. */
  45. class ShapeSW;
  46. class ShapeOwnerSW : public RID_Data {
  47. public:
  48. virtual void _shape_changed() = 0;
  49. virtual void remove_shape(ShapeSW *p_shape) = 0;
  50. virtual ~ShapeOwnerSW() {}
  51. };
  52. class ShapeSW : public RID_Data {
  53. RID self;
  54. AABB aabb;
  55. bool configured;
  56. real_t custom_bias;
  57. Map<ShapeOwnerSW *, int> owners;
  58. protected:
  59. void configure(const AABB &p_aabb);
  60. public:
  61. enum FeatureType {
  62. FEATURE_POINT,
  63. FEATURE_EDGE,
  64. FEATURE_FACE,
  65. FEATURE_CIRCLE,
  66. };
  67. virtual real_t get_area() const { return aabb.get_area(); }
  68. _FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; }
  69. _FORCE_INLINE_ RID get_self() const { return self; }
  70. virtual PhysicsServer::ShapeType get_type() const = 0;
  71. _FORCE_INLINE_ const AABB &get_aabb() const { return aabb; }
  72. _FORCE_INLINE_ bool is_configured() const { return configured; }
  73. virtual bool is_concave() const { return false; }
  74. virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const = 0;
  75. virtual Vector3 get_support(const Vector3 &p_normal) const;
  76. virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const = 0;
  77. virtual Vector3 get_closest_point_to(const Vector3 &p_point) const = 0;
  78. virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_point, Vector3 &r_normal) const = 0;
  79. virtual bool intersect_point(const Vector3 &p_point) const = 0;
  80. virtual Vector3 get_moment_of_inertia(real_t p_mass) const = 0;
  81. virtual void set_data(const Variant &p_data) = 0;
  82. virtual Variant get_data() const = 0;
  83. _FORCE_INLINE_ void set_custom_bias(real_t p_bias) { custom_bias = p_bias; }
  84. _FORCE_INLINE_ real_t get_custom_bias() const { return custom_bias; }
  85. void add_owner(ShapeOwnerSW *p_owner);
  86. void remove_owner(ShapeOwnerSW *p_owner);
  87. bool is_owner(ShapeOwnerSW *p_owner) const;
  88. const Map<ShapeOwnerSW *, int> &get_owners() const;
  89. ShapeSW();
  90. virtual ~ShapeSW();
  91. };
  92. class ConcaveShapeSW : public ShapeSW {
  93. public:
  94. // Returns true to stop the query.
  95. typedef bool (*QueryCallback)(void *p_userdata, ShapeSW *p_convex);
  96. virtual bool is_concave() const { return true; }
  97. virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const { r_amount = 0; }
  98. virtual void cull(const AABB &p_local_aabb, QueryCallback p_callback, void *p_userdata) const = 0;
  99. ConcaveShapeSW() {}
  100. };
  101. class PlaneShapeSW : public ShapeSW {
  102. Plane plane;
  103. void _setup(const Plane &p_plane);
  104. public:
  105. Plane get_plane() const;
  106. virtual real_t get_area() const { return Math_INF; }
  107. virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_PLANE; }
  108. virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
  109. virtual Vector3 get_support(const Vector3 &p_normal) const;
  110. virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const { r_amount = 0; }
  111. virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;
  112. virtual bool intersect_point(const Vector3 &p_point) const;
  113. virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;
  114. virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
  115. virtual void set_data(const Variant &p_data);
  116. virtual Variant get_data() const;
  117. PlaneShapeSW();
  118. };
  119. class RayShapeSW : public ShapeSW {
  120. real_t length;
  121. bool slips_on_slope;
  122. void _setup(real_t p_length, bool p_slips_on_slope);
  123. public:
  124. real_t get_length() const;
  125. bool get_slips_on_slope() const;
  126. virtual real_t get_area() const { return 0.0; }
  127. virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_RAY; }
  128. virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
  129. virtual Vector3 get_support(const Vector3 &p_normal) const;
  130. virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const;
  131. virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;
  132. virtual bool intersect_point(const Vector3 &p_point) const;
  133. virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;
  134. virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
  135. virtual void set_data(const Variant &p_data);
  136. virtual Variant get_data() const;
  137. RayShapeSW();
  138. };
  139. class SphereShapeSW : public ShapeSW {
  140. real_t radius;
  141. void _setup(real_t p_radius);
  142. public:
  143. real_t get_radius() const;
  144. virtual real_t get_area() const { return 4.0 / 3.0 * Math_PI * radius * radius * radius; }
  145. virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_SPHERE; }
  146. virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
  147. virtual Vector3 get_support(const Vector3 &p_normal) const;
  148. virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const;
  149. virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;
  150. virtual bool intersect_point(const Vector3 &p_point) const;
  151. virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;
  152. virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
  153. virtual void set_data(const Variant &p_data);
  154. virtual Variant get_data() const;
  155. SphereShapeSW();
  156. };
  157. class BoxShapeSW : public ShapeSW {
  158. Vector3 half_extents;
  159. void _setup(const Vector3 &p_half_extents);
  160. public:
  161. _FORCE_INLINE_ Vector3 get_half_extents() const { return half_extents; }
  162. virtual real_t get_area() const { return 8 * half_extents.x * half_extents.y * half_extents.z; }
  163. virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_BOX; }
  164. virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
  165. virtual Vector3 get_support(const Vector3 &p_normal) const;
  166. virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const;
  167. virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;
  168. virtual bool intersect_point(const Vector3 &p_point) const;
  169. virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;
  170. virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
  171. virtual void set_data(const Variant &p_data);
  172. virtual Variant get_data() const;
  173. BoxShapeSW();
  174. };
  175. class CapsuleShapeSW : public ShapeSW {
  176. real_t height;
  177. real_t radius;
  178. void _setup(real_t p_height, real_t p_radius);
  179. public:
  180. _FORCE_INLINE_ real_t get_height() const { return height; }
  181. _FORCE_INLINE_ real_t get_radius() const { return radius; }
  182. virtual real_t get_area() const { return height * Math_PI * radius * radius; }
  183. virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CAPSULE; }
  184. virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
  185. virtual Vector3 get_support(const Vector3 &p_normal) const;
  186. virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const;
  187. virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;
  188. virtual bool intersect_point(const Vector3 &p_point) const;
  189. virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;
  190. virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
  191. virtual void set_data(const Variant &p_data);
  192. virtual Variant get_data() const;
  193. CapsuleShapeSW();
  194. };
  195. class CylinderShapeSW : public ShapeSW {
  196. real_t height;
  197. real_t radius;
  198. void _setup(real_t p_height, real_t p_radius);
  199. public:
  200. _FORCE_INLINE_ real_t get_height() const { return height; }
  201. _FORCE_INLINE_ real_t get_radius() const { return radius; }
  202. virtual real_t get_area() const { return 4.0 / 3.0 * Math_PI * radius * radius * radius + height * Math_PI * radius * radius; }
  203. virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CYLINDER; }
  204. virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
  205. virtual Vector3 get_support(const Vector3 &p_normal) const;
  206. virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const;
  207. virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;
  208. virtual bool intersect_point(const Vector3 &p_point) const;
  209. virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;
  210. virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
  211. virtual void set_data(const Variant &p_data);
  212. virtual Variant get_data() const;
  213. CylinderShapeSW();
  214. };
  215. struct ConvexPolygonShapeSW : public ShapeSW {
  216. Geometry::MeshData mesh;
  217. void _setup(const Vector<Vector3> &p_vertices);
  218. public:
  219. const Geometry::MeshData &get_mesh() const { return mesh; }
  220. virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CONVEX_POLYGON; }
  221. virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
  222. virtual Vector3 get_support(const Vector3 &p_normal) const;
  223. virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const;
  224. virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;
  225. virtual bool intersect_point(const Vector3 &p_point) const;
  226. virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;
  227. virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
  228. virtual void set_data(const Variant &p_data);
  229. virtual Variant get_data() const;
  230. ConvexPolygonShapeSW();
  231. };
  232. struct _VolumeSW_BVH;
  233. struct FaceShapeSW;
  234. struct ConcavePolygonShapeSW : public ConcaveShapeSW {
  235. // always a trimesh
  236. struct Face {
  237. Vector3 normal;
  238. int indices[3];
  239. };
  240. PoolVector<Face> faces;
  241. PoolVector<Vector3> vertices;
  242. struct BVH {
  243. AABB aabb;
  244. int left;
  245. int right;
  246. int face_index;
  247. };
  248. PoolVector<BVH> bvh;
  249. struct _CullParams {
  250. AABB aabb;
  251. QueryCallback callback;
  252. void *userdata;
  253. const Face *faces;
  254. const Vector3 *vertices;
  255. const BVH *bvh;
  256. FaceShapeSW *face;
  257. };
  258. struct _SegmentCullParams {
  259. Vector3 from;
  260. Vector3 to;
  261. const Face *faces;
  262. const Vector3 *vertices;
  263. const BVH *bvh;
  264. Vector3 dir;
  265. Vector3 result;
  266. Vector3 normal;
  267. real_t min_d;
  268. int collisions;
  269. };
  270. void _cull_segment(int p_idx, _SegmentCullParams *p_params) const;
  271. bool _cull(int p_idx, _CullParams *p_params) const;
  272. void _fill_bvh(_VolumeSW_BVH *p_bvh_tree, BVH *p_bvh_array, int &p_idx);
  273. void _setup(PoolVector<Vector3> p_faces);
  274. public:
  275. PoolVector<Vector3> get_faces() const;
  276. virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CONCAVE_POLYGON; }
  277. virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
  278. virtual Vector3 get_support(const Vector3 &p_normal) const;
  279. virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;
  280. virtual bool intersect_point(const Vector3 &p_point) const;
  281. virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;
  282. virtual void cull(const AABB &p_local_aabb, QueryCallback p_callback, void *p_userdata) const;
  283. virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
  284. virtual void set_data(const Variant &p_data);
  285. virtual Variant get_data() const;
  286. ConcavePolygonShapeSW();
  287. };
  288. struct HeightMapShapeSW : public ConcaveShapeSW {
  289. friend struct _HeightmapSegmentCullParams;
  290. PoolVector<real_t> heights;
  291. int width;
  292. int depth;
  293. Vector3 local_origin;
  294. // Accelerator.
  295. struct Range {
  296. float min = 0.0;
  297. float max = 0.0;
  298. };
  299. LocalVector<Range> bounds_grid;
  300. int bounds_grid_width = 0;
  301. int bounds_grid_depth = 0;
  302. static const int BOUNDS_CHUNK_SIZE = 16;
  303. _FORCE_INLINE_ const Range &_get_bounds_chunk(int p_x, int p_z) const {
  304. return bounds_grid[(p_z * bounds_grid_width) + p_x];
  305. }
  306. _FORCE_INLINE_ real_t _get_height(int p_x, int p_z) const {
  307. return heights[(p_z * width) + p_x];
  308. }
  309. _FORCE_INLINE_ void _get_point(int p_x, int p_z, Vector3 &r_point) const {
  310. r_point.x = p_x - 0.5 * (width - 1.0);
  311. r_point.y = _get_height(p_x, p_z);
  312. r_point.z = p_z - 0.5 * (depth - 1.0);
  313. }
  314. void _get_cell(const Vector3 &p_point, int &r_x, int &r_y, int &r_z) const;
  315. void _build_accelerator();
  316. template <typename ProcessFunction>
  317. bool _intersect_grid_segment(ProcessFunction &p_process, const Vector3 &p_begin, const Vector3 &p_end, int p_width, int p_depth, const Vector3 &offset, Vector3 &r_point, Vector3 &r_normal) const;
  318. void _setup(const PoolVector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height);
  319. public:
  320. PoolVector<real_t> get_heights() const;
  321. int get_width() const;
  322. int get_depth() const;
  323. virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_HEIGHTMAP; }
  324. virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
  325. virtual Vector3 get_support(const Vector3 &p_normal) const;
  326. virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_point, Vector3 &r_normal) const;
  327. virtual bool intersect_point(const Vector3 &p_point) const;
  328. virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;
  329. virtual void cull(const AABB &p_local_aabb, QueryCallback p_callback, void *p_userdata) const;
  330. virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
  331. virtual void set_data(const Variant &p_data);
  332. virtual Variant get_data() const;
  333. HeightMapShapeSW();
  334. };
  335. //used internally
  336. struct FaceShapeSW : public ShapeSW {
  337. Vector3 normal; //cache
  338. Vector3 vertex[3];
  339. virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CONCAVE_POLYGON; }
  340. const Vector3 &get_vertex(int p_idx) const { return vertex[p_idx]; }
  341. void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
  342. Vector3 get_support(const Vector3 &p_normal) const;
  343. virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const;
  344. bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;
  345. virtual bool intersect_point(const Vector3 &p_point) const;
  346. virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;
  347. Vector3 get_moment_of_inertia(real_t p_mass) const;
  348. virtual void set_data(const Variant &p_data) {}
  349. virtual Variant get_data() const { return Variant(); }
  350. FaceShapeSW();
  351. };
  352. struct MotionShapeSW : public ShapeSW {
  353. ShapeSW *shape;
  354. Vector3 motion;
  355. virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CONVEX_POLYGON; }
  356. void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
  357. Vector3 cast = p_transform.basis.xform(motion);
  358. real_t mina, maxa;
  359. real_t minb, maxb;
  360. Transform ofsb = p_transform;
  361. ofsb.origin += cast;
  362. shape->project_range(p_normal, p_transform, mina, maxa);
  363. shape->project_range(p_normal, ofsb, minb, maxb);
  364. r_min = MIN(mina, minb);
  365. r_max = MAX(maxa, maxb);
  366. }
  367. Vector3 get_support(const Vector3 &p_normal) const {
  368. Vector3 support = shape->get_support(p_normal);
  369. if (p_normal.dot(motion) > 0) {
  370. support += motion;
  371. }
  372. return support;
  373. }
  374. virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const { r_amount = 0; }
  375. bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const { return false; }
  376. virtual bool intersect_point(const Vector3 &p_point) const { return false; }
  377. virtual Vector3 get_closest_point_to(const Vector3 &p_point) const { return p_point; }
  378. Vector3 get_moment_of_inertia(real_t p_mass) const { return Vector3(); }
  379. virtual void set_data(const Variant &p_data) {}
  380. virtual Variant get_data() const { return Variant(); }
  381. MotionShapeSW() { configure(AABB()); }
  382. };
  383. struct _ShapeTestConvexBSPSW {
  384. const BSP_Tree *bsp;
  385. const ShapeSW *shape;
  386. Transform transform;
  387. _FORCE_INLINE_ void project_range(const Vector3 &p_normal, real_t &r_min, real_t &r_max) const {
  388. shape->project_range(p_normal, transform, r_min, r_max);
  389. }
  390. };
  391. #endif // SHAPE_SW_H