@@ -493,6 +493,18 @@ public boolean isForceUpdateAllAabbs() {
493493 return isForceUpdateAllAabbs (spaceId );
494494 }
495495
496+ /**
497+ * Test whether the {@code needsCollision()} callback is enabled.
498+ *
499+ * @return true if it's enabled, otherwise false
500+ */
501+ public boolean isOverlapFilterEnabled () {
502+ long spaceId = nativeId ();
503+ boolean result = isOverlapFilterEnabled (spaceId );
504+
505+ return result ;
506+ }
507+
496508 /**
497509 * Test whether the "deterministic overlapping pairs" option is enabled in
498510 * the collision dispatcher (native field: m_deterministicOverlappingPairs).
@@ -523,7 +535,8 @@ public long jniEnvId() {
523535 * Callback to determine whether the specified objects should be allowed to
524536 * collide. Invoked during broadphase, after axis-aligned bounding boxes,
525537 * ignore lists, and collision groups have been checked. Override this
526- * method to implement dynamic collision filtering.
538+ * method to implement dynamic collision filtering. When not needed, the
539+ * callback can be disabled by {@code setOverlapFilterEnabled(false)}.
527540 *
528541 * @param pcoA the first collision object (not null)
529542 * @param pcoB the 2nd collision object (not null)
@@ -740,6 +753,17 @@ public static void setLocalThreadPhysicsSpace(CollisionSpace space) {
740753 physicsSpaceTL .set (space );
741754 }
742755
756+ /**
757+ * Alter whether the {@code needsCollision()} callback is enabled.
758+ *
759+ * @param enable true to enable the callback, or false to skip it
760+ * (default=true)
761+ */
762+ public void setOverlapFilterEnabled (boolean enable ) {
763+ long spaceId = nativeId ();
764+ setOverlapFilterEnabled (spaceId , enable );
765+ }
766+
743767 /**
744768 * Alter the flags used in ray tests (native field: m_flags).
745769 *
@@ -962,6 +986,8 @@ native private long createCollisionSpace(
962986
963987 native private static boolean isForceUpdateAllAabbs (long spaceId );
964988
989+ native private static boolean isOverlapFilterEnabled (long spaceId );
990+
965991 native private static int pairTest (long spaceId , long aId , long bId ,
966992 PhysicsCollisionListener listener );
967993
@@ -978,6 +1004,9 @@ native private static void rayTestNativeDp(
9781004 native private static void setDeterministicOverlappingPairs (
9791005 long spaceId , boolean desiredSetting );
9801006
1007+ native private static void setOverlapFilterEnabled (
1008+ long spaceId , boolean enable );
1009+
9811010 native private static void
9821011 setForceUpdateAllAabbs (long spaceId , boolean desiredSetting );
9831012
0 commit comments