Skip to content

unsafe aliasing thrown when getting collider or body in filterContactPair #339

@sylvanelite

Description

@sylvanelite

Using rapier3d-compat initially on version 0.15.0, but also tested on version 0.18.0

    world.step(new RAPIER.EventQueue(true),{
        filterContactPair:(collider1: number, collider2: number, body1: number, body2: number)=> {
            try{
                const c1 = world.getCollider(collider1);
                c1.isValid();//throws here, happens on a variety of "get" methods, such as .translation(), .collisionGroups(), rotation(), etc                
            }catch(e){
                console.log("ERROR - collider");
                console.log(e)
            }
            try{
                const b1 = world.getRigidBody(body1);
                b1.isValid(); //similarly throws here when getting from the body handle
            }catch(e){
                console.log("ERROR - body");
                console.log(e)
            }
            return RAPIER.SolverFlags.COMPUTE_IMPULSE;
        },
        filterIntersectionPair:(collider1: number, collider2: number, body1: number, body2: number)=>{ return true; }
    
    });

results in the following errors being caught:

ERROR - collider
demo.mts:54 Error: recursive use of an object detected which would lead to unsafe aliasing in rust
	at I.wbg.__wbindgen_throw (rapier.js:1:75208)
	at 006334fe:0x177d59
	at 006334fe:0x177d75
	at 006334fe:0x15b96f
	at T.contains (rapier.js:1:17017)
	at Yg.isValid (rapier.js:1:130463)
	at Object.filterContactPair (demo.mts:51:24)
	at rapier.js:1:72821
	at Q (rapier.js:1:219)
	at I.wbg.__wbg_call_833bed5770ea2041 (rapier.js:1:72786)
demo.mts:60 ERROR - body
demo.mts:61 Error: recursive use of an object detected which would lead to unsafe aliasing in rust
	at I.wbg.__wbindgen_throw (rapier.js:1:75208)
	at 006334fe:0x177d59
	at 006334fe:0x177d75
	at 006334fe:0x15b3da
	at LA.contains (rapier.js:1:62165)
	at GI.isValid (rapier.js:1:77554)
	at Object.filterContactPair (demo.mts:58:24)
	at rapier.js:1:72821
	at Q (rapier.js:1:219)
	at I.wbg.__wbg_call_833bed5770ea2041 (rapier.js:1:72786)

This appears to happen on methods called on world.getCollider or world.getBody.

The intention of the above code was to filter out collisions based on Y position of the colliding objects. This error appears to occur when calling "get" methods from the world.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions