PreSolveContact Struct
Contact information passed to the pre-solve filter registered with
SetPreSolveFilter(Func<PreSolveContact,bool>). Return false to cancel the contact
for the current step without generating collision response forces.
public readonly struct PreSolveContact
Remarks¶
The pre-solve callback is invoked by the Box2D solver on the simulation thread every step for every active contact pair. Keep the callback allocation-free.
Primary use-case: one-way platforms. Check Normal and cancel the contact when the body is approaching from the wrong side:
world.SetPreSolveFilter(c =>
{
bool platformIsA = c.BodyA.Entity?.Name == "Platform";
var normal = platformIsA ? c.Normal : -c.Normal;
return normal.Y <= 0f; // only collide from above (Y-down)
});
| Properties | |
|---|---|
| BodyA | Body A in the contact pair. |
| BodyB | Body B in the contact pair. |
| Normal | The contact normal pointing from BodyA toward BodyB. |
| SubShapeA | The sub-shape on BodyA involved in the contact, or null when the primary shape is the contact shape. |
| SubShapeB | The sub-shape on BodyB involved in the contact, or null when the primary shape is the contact shape. |