@@ -155,6 +155,72 @@ describe("physics hooks", () => {
155155 expect ( onCollisionEnter ) . toHaveBeenCalled ( ) ;
156156 } ) ;
157157
158+ it ( "should block collisions when hook returns SolverFlags.EMPTY" , async ( ) => {
159+ let ballRef : RapierRigidBody | null = null ;
160+ let platformRef : RapierRigidBody | null = null ;
161+
162+ const TestComponent = ( ) => {
163+ const colliderRef = useRef < RapierCollider > ( null ) ;
164+ const platformBodyRef = useRef < RapierRigidBody > ( null ) ;
165+
166+ useEffect ( ( ) => {
167+ platformRef = platformBodyRef . current ;
168+ } , [ ] ) ;
169+
170+ useFilterContactPair (
171+ useCallback ( ( ) => {
172+ return SolverFlags . EMPTY ; // Block collision resolution
173+ } , [ ] )
174+ ) ;
175+
176+ useEffect ( ( ) => {
177+ if ( colliderRef . current ) {
178+ colliderRef . current . setActiveHooks (
179+ ActiveHooks . FILTER_CONTACT_PAIRS
180+ ) ;
181+ }
182+ } , [ ] ) ;
183+
184+ return (
185+ < RigidBody ref = { platformBodyRef } type = "fixed" position = { [ 0 , 0 , 0 ] } >
186+ < CuboidCollider ref = { colliderRef } args = { [ 5 , 0.5 , 5 ] } />
187+ </ RigidBody >
188+ ) ;
189+ } ;
190+
191+ const FallingBall = ( ) => {
192+ const ref = useRef < RapierRigidBody > ( null ) ;
193+
194+ useEffect ( ( ) => {
195+ ballRef = ref . current ;
196+ } , [ ] ) ;
197+
198+ return (
199+ < RigidBody ref = { ref } position = { [ 0 , 5 , 0 ] } >
200+ < CuboidCollider args = { [ 0.5 , 0.5 , 0.5 ] } />
201+ </ RigidBody >
202+ ) ;
203+ } ;
204+
205+ const step = await awaitReady (
206+ < >
207+ < TestComponent />
208+ < FallingBall />
209+ </ >
210+ ) ;
211+
212+ await ReactThreeTestRenderer . act ( async ( ) => {
213+ // Step enough times for ball to fall through platform
214+ for ( let i = 0 ; i < 120 ; i ++ ) {
215+ step ( 1 / 60 ) ;
216+ }
217+ } ) ;
218+
219+ // Ball should have fallen through the platform (y position below platform)
220+ // If collision was resolved, ball would be resting on top of platform at y ~1
221+ expect ( ballRef ! . translation ( ) . y ) . toBeLessThan ( - 2 ) ;
222+ } ) ;
223+
158224 it ( "should work with cached body state from useBeforePhysicsStep" , async ( ) => {
159225 const filterHook = vi . fn ( ( ) => 1 ) ;
160226
0 commit comments