PolygonAndCircleContact class
class PolygonAndCircleContact extends Contact { PolygonAndCircleContact(DefaultWorldPool argPool) : super(argPool) { } void init(Fixture fA, Fixture fB) { expect(ShapeType.POLYGON, fA.type); expect(ShapeType.CIRCLE, fB.type); super.init(fA, fB); } void evaluate(Manifold argManifold, Transform xfA, Transform xfB) { pool.collision.collidePolygonAndCircle(argManifold, fixtureA.shape, xfA, fixtureB.shape, xfB); } }
Extends
Contact > PolygonAndCircleContact
Constructors
new PolygonAndCircleContact(DefaultWorldPool argPool) #
PolygonAndCircleContact(DefaultWorldPool argPool) : super(argPool) { }
Properties
bool enabled #
inherited from Contact
Enable/disable this contact. This can be used inside the pre-solve contact listener. The contact is only disabled for the current time step (or sub-step in continuous collisions).
bool get enabled => (flags & ENABLED_FLAG) == ENABLED_FLAG;
void set enabled(bool flag) { if (flag) { flags |= ENABLED_FLAG; } else { flags &= ~ENABLED_FLAG; } }
Methods
void evaluate(Manifold argManifold, Transform xfA, Transform xfB) #
Abstract method.
docs inherited from Contact
void evaluate(Manifold argManifold, Transform xfA, Transform xfB) { pool.collision.collidePolygonAndCircle(argManifold, fixtureA.shape, xfA, fixtureB.shape, xfB); }
void flagForFiltering() #
inherited from Contact
Flag this contact for filtering. Filtering will occur the next time step.
void flagForFiltering() { flags |= FILTER_FLAG; }
void getWorldManifold(WorldManifold worldManifold) #
inherited from Contact
Intializes the given world manifold.
void getWorldManifold(WorldManifold worldManifold) { final Body bodyA = fixtureA.body; final Body bodyB = fixtureB.body; final Shape shapeA = fixtureA.shape; final Shape shapeB = fixtureB.shape; worldManifold.initialize(manifold, bodyA.originTransform, shapeA.radius, bodyB.originTransform, shapeB.radius); }
void init(Fixture fA, Fixture fB) #
Initialization for pooling.
docs inherited from Contact
void init(Fixture fA, Fixture fB) { expect(ShapeType.POLYGON, fA.type); expect(ShapeType.CIRCLE, fB.type); super.init(fA, fB); }
void update(ContactListener listener) #
inherited from Contact
void update(ContactListener listener) { _oldManifold.setFrom(manifold); // Re-enable this contact. flags |= ENABLED_FLAG; bool nowTouching = false; bool wasTouching = (flags & TOUCHING_FLAG) == TOUCHING_FLAG; bool sensorA = fixtureA.isSensor; bool sensorB = fixtureB.isSensor; bool sensor = sensorA || sensorB; Body bodyA = fixtureA.body; Body bodyB = fixtureB.body; Transform xfA = bodyA.originTransform; Transform xfB = bodyB.originTransform; if (sensor) { Shape shapeA = fixtureA.shape; Shape shapeB = fixtureB.shape; nowTouching = pool.collision.testOverlap(shapeA, shapeB, xfA, xfB); // Sensors don't generate manifolds. manifold.pointCount = 0; } else { evaluate(manifold, xfA, xfB); nowTouching = manifold.pointCount > 0; // Match old contact ids to new contact ids and copy the // stored impulses to warm start the solver. for (int i = 0; i < manifold.pointCount; ++i) { ManifoldPoint mp2 = manifold.points[i]; mp2.normalImpulse = 0.0; mp2.tangentImpulse = 0.0; ContactID id2 = mp2.id; for (int j = 0; j < _oldManifold.pointCount; ++j) { ManifoldPoint mp1 = _oldManifold.points[j]; if (mp1.id.isEqual(id2)) { mp2.normalImpulse = mp1.normalImpulse; mp2.tangentImpulse = mp1.tangentImpulse; break; } } } if (nowTouching != wasTouching) { bodyA.awake = true; bodyB.awake = true; } } if (nowTouching) { flags |= TOUCHING_FLAG; } else { flags &= ~TOUCHING_FLAG; } if (listener == null) { return; } if (!wasTouching && nowTouching) { listener.beginContact(this); } if (wasTouching && !nowTouching) { listener.endContact(this); } if (sensor == false && nowTouching) { listener.preSolve(this, _oldManifold); } }