NarrowPhaseQuery.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #include <Jolt/Jolt.h>
  5. #include <Jolt/Physics/Collision/NarrowPhaseQuery.h>
  6. #include <Jolt/Physics/Collision/CollisionDispatch.h>
  7. #include <Jolt/Physics/Collision/RayCast.h>
  8. #include <Jolt/Physics/Collision/AABoxCast.h>
  9. #include <Jolt/Physics/Collision/ShapeCast.h>
  10. #include <Jolt/Physics/Collision/CollideShape.h>
  11. #include <Jolt/Physics/Collision/CollisionCollectorImpl.h>
  12. #include <Jolt/Physics/Collision/CastResult.h>
  13. #include <Jolt/Physics/Collision/InternalEdgeRemovingCollector.h>
  14. JPH_NAMESPACE_BEGIN
  15. bool NarrowPhaseQuery::CastRay(const RRayCast &inRay, RayCastResult &ioHit, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter) const
  16. {
  17. JPH_PROFILE_FUNCTION();
  18. class MyCollector : public RayCastBodyCollector
  19. {
  20. public:
  21. MyCollector(const RRayCast &inRay, RayCastResult &ioHit, const BodyLockInterface &inBodyLockInterface, const BodyFilter &inBodyFilter) :
  22. mRay(inRay),
  23. mHit(ioHit),
  24. mBodyLockInterface(inBodyLockInterface),
  25. mBodyFilter(inBodyFilter)
  26. {
  27. UpdateEarlyOutFraction(ioHit.mFraction);
  28. }
  29. virtual void AddHit(const ResultType &inResult) override
  30. {
  31. JPH_ASSERT(inResult.mFraction < mHit.mFraction, "This hit should not have been passed on to the collector");
  32. // Only test shape if it passes the body filter
  33. if (mBodyFilter.ShouldCollide(inResult.mBodyID))
  34. {
  35. // Lock the body
  36. BodyLockRead lock(mBodyLockInterface, inResult.mBodyID);
  37. if (lock.SucceededAndIsInBroadPhase()) // Race condition: body could have been removed since it has been found in the broadphase, ensures body is in the broadphase while we call the callbacks
  38. {
  39. const Body &body = lock.GetBody();
  40. // Check body filter again now that we've locked the body
  41. if (mBodyFilter.ShouldCollideLocked(body))
  42. {
  43. // Collect the transformed shape
  44. TransformedShape ts = body.GetTransformedShape();
  45. // Release the lock now, we have all the info we need in the transformed shape
  46. lock.ReleaseLock();
  47. // Do narrow phase collision check
  48. if (ts.CastRay(mRay, mHit))
  49. {
  50. // Test that we didn't find a further hit by accident
  51. JPH_ASSERT(mHit.mFraction >= 0.0f && mHit.mFraction < GetEarlyOutFraction());
  52. // Update early out fraction based on narrow phase collector
  53. UpdateEarlyOutFraction(mHit.mFraction);
  54. }
  55. }
  56. }
  57. }
  58. }
  59. RRayCast mRay;
  60. RayCastResult & mHit;
  61. const BodyLockInterface & mBodyLockInterface;
  62. const BodyFilter & mBodyFilter;
  63. };
  64. // Do broadphase test, note that the broadphase uses floats so we drop precision here
  65. MyCollector collector(inRay, ioHit, *mBodyLockInterface, inBodyFilter);
  66. mBroadPhaseQuery->CastRay(RayCast(inRay), collector, inBroadPhaseLayerFilter, inObjectLayerFilter);
  67. return ioHit.mFraction <= 1.0f;
  68. }
  69. void NarrowPhaseQuery::CastRay(const RRayCast &inRay, const RayCastSettings &inRayCastSettings, CastRayCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter) const
  70. {
  71. JPH_PROFILE_FUNCTION();
  72. class MyCollector : public RayCastBodyCollector
  73. {
  74. public:
  75. MyCollector(const RRayCast &inRay, const RayCastSettings &inRayCastSettings, CastRayCollector &ioCollector, const BodyLockInterface &inBodyLockInterface, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter) :
  76. RayCastBodyCollector(ioCollector),
  77. mRay(inRay),
  78. mRayCastSettings(inRayCastSettings),
  79. mCollector(ioCollector),
  80. mBodyLockInterface(inBodyLockInterface),
  81. mBodyFilter(inBodyFilter),
  82. mShapeFilter(inShapeFilter)
  83. {
  84. }
  85. virtual void AddHit(const ResultType &inResult) override
  86. {
  87. JPH_ASSERT(inResult.mFraction < mCollector.GetEarlyOutFraction(), "This hit should not have been passed on to the collector");
  88. // Only test shape if it passes the body filter
  89. if (mBodyFilter.ShouldCollide(inResult.mBodyID))
  90. {
  91. // Lock the body
  92. BodyLockRead lock(mBodyLockInterface, inResult.mBodyID);
  93. if (lock.SucceededAndIsInBroadPhase()) // Race condition: body could have been removed since it has been found in the broadphase, ensures body is in the broadphase while we call the callbacks
  94. {
  95. const Body &body = lock.GetBody();
  96. // Check body filter again now that we've locked the body
  97. if (mBodyFilter.ShouldCollideLocked(body))
  98. {
  99. // Collect the transformed shape
  100. TransformedShape ts = body.GetTransformedShape();
  101. // Notify collector of new body
  102. mCollector.OnBody(body);
  103. // Release the lock now, we have all the info we need in the transformed shape
  104. lock.ReleaseLock();
  105. // Do narrow phase collision check
  106. ts.CastRay(mRay, mRayCastSettings, mCollector, mShapeFilter);
  107. // Update early out fraction based on narrow phase collector
  108. UpdateEarlyOutFraction(mCollector.GetEarlyOutFraction());
  109. }
  110. }
  111. }
  112. }
  113. RRayCast mRay;
  114. RayCastSettings mRayCastSettings;
  115. CastRayCollector & mCollector;
  116. const BodyLockInterface & mBodyLockInterface;
  117. const BodyFilter & mBodyFilter;
  118. const ShapeFilter & mShapeFilter;
  119. };
  120. // Do broadphase test, note that the broadphase uses floats so we drop precision here
  121. MyCollector collector(inRay, inRayCastSettings, ioCollector, *mBodyLockInterface, inBodyFilter, inShapeFilter);
  122. mBroadPhaseQuery->CastRay(RayCast(inRay), collector, inBroadPhaseLayerFilter, inObjectLayerFilter);
  123. }
  124. void NarrowPhaseQuery::CollidePoint(RVec3Arg inPoint, CollidePointCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter) const
  125. {
  126. JPH_PROFILE_FUNCTION();
  127. class MyCollector : public CollideShapeBodyCollector
  128. {
  129. public:
  130. MyCollector(RVec3Arg inPoint, CollidePointCollector &ioCollector, const BodyLockInterface &inBodyLockInterface, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter) :
  131. CollideShapeBodyCollector(ioCollector),
  132. mPoint(inPoint),
  133. mCollector(ioCollector),
  134. mBodyLockInterface(inBodyLockInterface),
  135. mBodyFilter(inBodyFilter),
  136. mShapeFilter(inShapeFilter)
  137. {
  138. }
  139. virtual void AddHit(const ResultType &inResult) override
  140. {
  141. // Only test shape if it passes the body filter
  142. if (mBodyFilter.ShouldCollide(inResult))
  143. {
  144. // Lock the body
  145. BodyLockRead lock(mBodyLockInterface, inResult);
  146. if (lock.SucceededAndIsInBroadPhase()) // Race condition: body could have been removed since it has been found in the broadphase, ensures body is in the broadphase while we call the callbacks
  147. {
  148. const Body &body = lock.GetBody();
  149. // Check body filter again now that we've locked the body
  150. if (mBodyFilter.ShouldCollideLocked(body))
  151. {
  152. // Collect the transformed shape
  153. TransformedShape ts = body.GetTransformedShape();
  154. // Notify collector of new body
  155. mCollector.OnBody(body);
  156. // Release the lock now, we have all the info we need in the transformed shape
  157. lock.ReleaseLock();
  158. // Do narrow phase collision check
  159. ts.CollidePoint(mPoint, mCollector, mShapeFilter);
  160. // Update early out fraction based on narrow phase collector
  161. UpdateEarlyOutFraction(mCollector.GetEarlyOutFraction());
  162. }
  163. }
  164. }
  165. }
  166. RVec3 mPoint;
  167. CollidePointCollector & mCollector;
  168. const BodyLockInterface & mBodyLockInterface;
  169. const BodyFilter & mBodyFilter;
  170. const ShapeFilter & mShapeFilter;
  171. };
  172. // Do broadphase test (note: truncates double to single precision since the broadphase uses single precision)
  173. MyCollector collector(inPoint, ioCollector, *mBodyLockInterface, inBodyFilter, inShapeFilter);
  174. mBroadPhaseQuery->CollidePoint(Vec3(inPoint), collector, inBroadPhaseLayerFilter, inObjectLayerFilter);
  175. }
  176. void NarrowPhaseQuery::CollideShape(const Shape *inShape, Vec3Arg inShapeScale, RMat44Arg inCenterOfMassTransform, const CollideShapeSettings &inCollideShapeSettings, RVec3Arg inBaseOffset, CollideShapeCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter) const
  177. {
  178. JPH_PROFILE_FUNCTION();
  179. class MyCollector : public CollideShapeBodyCollector
  180. {
  181. public:
  182. MyCollector(const Shape *inShape, Vec3Arg inShapeScale, RMat44Arg inCenterOfMassTransform, const CollideShapeSettings &inCollideShapeSettings, RVec3Arg inBaseOffset, CollideShapeCollector &ioCollector, const BodyLockInterface &inBodyLockInterface, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter) :
  183. CollideShapeBodyCollector(ioCollector),
  184. mShape(inShape),
  185. mShapeScale(inShapeScale),
  186. mCenterOfMassTransform(inCenterOfMassTransform),
  187. mCollideShapeSettings(inCollideShapeSettings),
  188. mBaseOffset(inBaseOffset),
  189. mCollector(ioCollector),
  190. mBodyLockInterface(inBodyLockInterface),
  191. mBodyFilter(inBodyFilter),
  192. mShapeFilter(inShapeFilter)
  193. {
  194. }
  195. virtual void AddHit(const ResultType &inResult) override
  196. {
  197. // Only test shape if it passes the body filter
  198. if (mBodyFilter.ShouldCollide(inResult))
  199. {
  200. // Lock the body
  201. BodyLockRead lock(mBodyLockInterface, inResult);
  202. if (lock.SucceededAndIsInBroadPhase()) // Race condition: body could have been removed since it has been found in the broadphase, ensures body is in the broadphase while we call the callbacks
  203. {
  204. const Body &body = lock.GetBody();
  205. // Check body filter again now that we've locked the body
  206. if (mBodyFilter.ShouldCollideLocked(body))
  207. {
  208. // Collect the transformed shape
  209. TransformedShape ts = body.GetTransformedShape();
  210. // Notify collector of new body
  211. mCollector.OnBody(body);
  212. // Release the lock now, we have all the info we need in the transformed shape
  213. lock.ReleaseLock();
  214. // Do narrow phase collision check
  215. ts.CollideShape(mShape, mShapeScale, mCenterOfMassTransform, mCollideShapeSettings, mBaseOffset, mCollector, mShapeFilter);
  216. // Update early out fraction based on narrow phase collector
  217. UpdateEarlyOutFraction(mCollector.GetEarlyOutFraction());
  218. }
  219. }
  220. }
  221. }
  222. const Shape * mShape;
  223. Vec3 mShapeScale;
  224. RMat44 mCenterOfMassTransform;
  225. const CollideShapeSettings & mCollideShapeSettings;
  226. RVec3 mBaseOffset;
  227. CollideShapeCollector & mCollector;
  228. const BodyLockInterface & mBodyLockInterface;
  229. const BodyFilter & mBodyFilter;
  230. const ShapeFilter & mShapeFilter;
  231. };
  232. // Calculate bounds for shape and expand by max separation distance
  233. AABox bounds = inShape->GetWorldSpaceBounds(inCenterOfMassTransform, inShapeScale);
  234. bounds.ExpandBy(Vec3::sReplicate(inCollideShapeSettings.mMaxSeparationDistance));
  235. // Do broadphase test
  236. MyCollector collector(inShape, inShapeScale, inCenterOfMassTransform, inCollideShapeSettings, inBaseOffset, ioCollector, *mBodyLockInterface, inBodyFilter, inShapeFilter);
  237. mBroadPhaseQuery->CollideAABox(bounds, collector, inBroadPhaseLayerFilter, inObjectLayerFilter);
  238. }
  239. void NarrowPhaseQuery::CollideShapeWithInternalEdgeRemoval(const Shape *inShape, Vec3Arg inShapeScale, RMat44Arg inCenterOfMassTransform, const CollideShapeSettings &inCollideShapeSettings, RVec3Arg inBaseOffset, CollideShapeCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter) const
  240. {
  241. JPH_PROFILE_FUNCTION();
  242. class MyCollector : public CollideShapeBodyCollector
  243. {
  244. public:
  245. MyCollector(const Shape *inShape, Vec3Arg inShapeScale, RMat44Arg inCenterOfMassTransform, const CollideShapeSettings &inCollideShapeSettings, RVec3Arg inBaseOffset, CollideShapeCollector &ioCollector, const BodyLockInterface &inBodyLockInterface, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter) :
  246. CollideShapeBodyCollector(ioCollector),
  247. mShape(inShape),
  248. mShapeScale(inShapeScale),
  249. mCenterOfMassTransform(inCenterOfMassTransform),
  250. mBaseOffset(inBaseOffset),
  251. mBodyLockInterface(inBodyLockInterface),
  252. mBodyFilter(inBodyFilter),
  253. mShapeFilter(inShapeFilter),
  254. mCollideShapeSettings(inCollideShapeSettings),
  255. mCollector(ioCollector)
  256. {
  257. // We require these settings for internal edge removal to work
  258. mCollideShapeSettings.mActiveEdgeMode = EActiveEdgeMode::CollideWithAll;
  259. mCollideShapeSettings.mCollectFacesMode = ECollectFacesMode::CollectFaces;
  260. }
  261. virtual void AddHit(const ResultType &inResult) override
  262. {
  263. // Only test shape if it passes the body filter
  264. if (mBodyFilter.ShouldCollide(inResult))
  265. {
  266. // Lock the body
  267. BodyLockRead lock(mBodyLockInterface, inResult);
  268. if (lock.SucceededAndIsInBroadPhase()) // Race condition: body could have been removed since it has been found in the broadphase, ensures body is in the broadphase while we call the callbacks
  269. {
  270. const Body &body = lock.GetBody();
  271. // Check body filter again now that we've locked the body
  272. if (mBodyFilter.ShouldCollideLocked(body))
  273. {
  274. // Collect the transformed shape
  275. TransformedShape ts = body.GetTransformedShape();
  276. // Notify collector of new body
  277. mCollector.OnBody(body);
  278. // Release the lock now, we have all the info we need in the transformed shape
  279. lock.ReleaseLock();
  280. // Do narrow phase collision check
  281. ts.CollideShape(mShape, mShapeScale, mCenterOfMassTransform, mCollideShapeSettings, mBaseOffset, mCollector, mShapeFilter);
  282. // After each body, we need to flush the InternalEdgeRemovingCollector because it uses 'ts' as context and it will go out of scope at the end of this block
  283. mCollector.Flush();
  284. // Update early out fraction based on narrow phase collector
  285. UpdateEarlyOutFraction(mCollector.GetEarlyOutFraction());
  286. }
  287. }
  288. }
  289. }
  290. const Shape * mShape;
  291. Vec3 mShapeScale;
  292. RMat44 mCenterOfMassTransform;
  293. RVec3 mBaseOffset;
  294. const BodyLockInterface & mBodyLockInterface;
  295. const BodyFilter & mBodyFilter;
  296. const ShapeFilter & mShapeFilter;
  297. CollideShapeSettings mCollideShapeSettings;
  298. InternalEdgeRemovingCollector mCollector;
  299. };
  300. // Calculate bounds for shape and expand by max separation distance
  301. AABox bounds = inShape->GetWorldSpaceBounds(inCenterOfMassTransform, inShapeScale);
  302. bounds.ExpandBy(Vec3::sReplicate(inCollideShapeSettings.mMaxSeparationDistance));
  303. // Do broadphase test
  304. MyCollector collector(inShape, inShapeScale, inCenterOfMassTransform, inCollideShapeSettings, inBaseOffset, ioCollector, *mBodyLockInterface, inBodyFilter, inShapeFilter);
  305. mBroadPhaseQuery->CollideAABox(bounds, collector, inBroadPhaseLayerFilter, inObjectLayerFilter);
  306. }
  307. void NarrowPhaseQuery::CastShape(const RShapeCast &inShapeCast, const ShapeCastSettings &inShapeCastSettings, RVec3Arg inBaseOffset, CastShapeCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter) const
  308. {
  309. JPH_PROFILE_FUNCTION();
  310. class MyCollector : public CastShapeBodyCollector
  311. {
  312. public:
  313. MyCollector(const RShapeCast &inShapeCast, const ShapeCastSettings &inShapeCastSettings, RVec3Arg inBaseOffset, CastShapeCollector &ioCollector, const BodyLockInterface &inBodyLockInterface, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter) :
  314. CastShapeBodyCollector(ioCollector),
  315. mShapeCast(inShapeCast),
  316. mShapeCastSettings(inShapeCastSettings),
  317. mBaseOffset(inBaseOffset),
  318. mCollector(ioCollector),
  319. mBodyLockInterface(inBodyLockInterface),
  320. mBodyFilter(inBodyFilter),
  321. mShapeFilter(inShapeFilter)
  322. {
  323. }
  324. virtual void AddHit(const ResultType &inResult) override
  325. {
  326. JPH_ASSERT(inResult.mFraction <= max(0.0f, mCollector.GetEarlyOutFraction()), "This hit should not have been passed on to the collector");
  327. // Only test shape if it passes the body filter
  328. if (mBodyFilter.ShouldCollide(inResult.mBodyID))
  329. {
  330. // Lock the body
  331. BodyLockRead lock(mBodyLockInterface, inResult.mBodyID);
  332. if (lock.SucceededAndIsInBroadPhase()) // Race condition: body could have been removed since it has been found in the broadphase, ensures body is in the broadphase while we call the callbacks
  333. {
  334. const Body &body = lock.GetBody();
  335. // Check body filter again now that we've locked the body
  336. if (mBodyFilter.ShouldCollideLocked(body))
  337. {
  338. // Collect the transformed shape
  339. TransformedShape ts = body.GetTransformedShape();
  340. // Notify collector of new body
  341. mCollector.OnBody(body);
  342. // Release the lock now, we have all the info we need in the transformed shape
  343. lock.ReleaseLock();
  344. // Do narrow phase collision check
  345. ts.CastShape(mShapeCast, mShapeCastSettings, mBaseOffset, mCollector, mShapeFilter);
  346. // Update early out fraction based on narrow phase collector
  347. UpdateEarlyOutFraction(mCollector.GetEarlyOutFraction());
  348. }
  349. }
  350. }
  351. }
  352. RShapeCast mShapeCast;
  353. const ShapeCastSettings & mShapeCastSettings;
  354. RVec3 mBaseOffset;
  355. CastShapeCollector & mCollector;
  356. const BodyLockInterface & mBodyLockInterface;
  357. const BodyFilter & mBodyFilter;
  358. const ShapeFilter & mShapeFilter;
  359. };
  360. // Do broadphase test
  361. MyCollector collector(inShapeCast, inShapeCastSettings, inBaseOffset, ioCollector, *mBodyLockInterface, inBodyFilter, inShapeFilter);
  362. mBroadPhaseQuery->CastAABox({ inShapeCast.mShapeWorldBounds, inShapeCast.mDirection }, collector, inBroadPhaseLayerFilter, inObjectLayerFilter);
  363. }
  364. void NarrowPhaseQuery::CollectTransformedShapes(const AABox &inBox, TransformedShapeCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter) const
  365. {
  366. class MyCollector : public CollideShapeBodyCollector
  367. {
  368. public:
  369. MyCollector(const AABox &inBox, TransformedShapeCollector &ioCollector, const BodyLockInterface &inBodyLockInterface, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter) :
  370. CollideShapeBodyCollector(ioCollector),
  371. mBox(inBox),
  372. mCollector(ioCollector),
  373. mBodyLockInterface(inBodyLockInterface),
  374. mBodyFilter(inBodyFilter),
  375. mShapeFilter(inShapeFilter)
  376. {
  377. }
  378. virtual void AddHit(const ResultType &inResult) override
  379. {
  380. // Only test shape if it passes the body filter
  381. if (mBodyFilter.ShouldCollide(inResult))
  382. {
  383. // Lock the body
  384. BodyLockRead lock(mBodyLockInterface, inResult);
  385. if (lock.SucceededAndIsInBroadPhase()) // Race condition: body could have been removed since it has been found in the broadphase, ensures body is in the broadphase while we call the callbacks
  386. {
  387. const Body &body = lock.GetBody();
  388. // Check body filter again now that we've locked the body
  389. if (mBodyFilter.ShouldCollideLocked(body))
  390. {
  391. // Collect the transformed shape
  392. TransformedShape ts = body.GetTransformedShape();
  393. // Notify collector of new body
  394. mCollector.OnBody(body);
  395. // Release the lock now, we have all the info we need in the transformed shape
  396. lock.ReleaseLock();
  397. // Do narrow phase collision check
  398. ts.CollectTransformedShapes(mBox, mCollector, mShapeFilter);
  399. // Update early out fraction based on narrow phase collector
  400. UpdateEarlyOutFraction(mCollector.GetEarlyOutFraction());
  401. }
  402. }
  403. }
  404. }
  405. const AABox & mBox;
  406. TransformedShapeCollector & mCollector;
  407. const BodyLockInterface & mBodyLockInterface;
  408. const BodyFilter & mBodyFilter;
  409. const ShapeFilter & mShapeFilter;
  410. };
  411. // Do broadphase test
  412. MyCollector collector(inBox, ioCollector, *mBodyLockInterface, inBodyFilter, inShapeFilter);
  413. mBroadPhaseQuery->CollideAABox(inBox, collector, inBroadPhaseLayerFilter, inObjectLayerFilter);
  414. }
  415. JPH_NAMESPACE_END