private void pushContact(Contact contact) { Fixture fixtureA = contact.getFixtureA(); Fixture fixtureB = contact.getFixtureB(); if (contact.m_manifold.pointCount > 0 && !fixtureA.isSensor() && !fixtureB.isSensor()) { fixtureA.getBody().setAwake(true); fixtureB.getBody().setAwake(true); } ShapeType type1 = fixtureA.getType(); ShapeType type2 = fixtureB.getType(); IDynamicStack<Contact> creator = contactStacks[type1.ordinal()][type2.ordinal()].creator; creator.push(contact); } }
private void pushContact(Contact contact) { Fixture fixtureA = contact.getFixtureA(); Fixture fixtureB = contact.getFixtureB(); if (contact.m_manifold.pointCount > 0 && !fixtureA.isSensor() && !fixtureB.isSensor()) { fixtureA.getBody().setAwake(true); fixtureB.getBody().setAwake(true); } ShapeType type1 = fixtureA.getType(); ShapeType type2 = fixtureB.getType(); IDynamicStack<Contact> creator = contactStacks[type1.ordinal()][type2.ordinal()].creator; creator.push(contact); } }
world.assertNotLocked(); assert (fixture.getBody() == this); assert fixtures.contains(fixture);
world.assertNotLocked(); assert (fixture.getBody() == this); assert fixtures.contains(fixture);
/** * Performs a ray cast from start point to end point. * * @param start start point * @param end end point * @return ray cast result */ public RaycastResult raycast(Point2D start, Point2D end) { raycastCallback.reset(); jboxWorld.raycast(raycastCallback, toPoint(start), toPoint(end)); Entity entity = null; Point2D point = null; if (raycastCallback.getFixture() != null) entity = raycastCallback.getFixture().getBody().getEntity(); if (raycastCallback.getPoint() != null) point = toPoint(raycastCallback.getPoint()); if (entity == null && point == null) return RaycastResult.NONE; return new RaycastResult(entity, point); }
/** * Performs a ray cast from start point to end point. * * @param start start point * @param end end point * @return ray cast result */ public RaycastResult raycast(Point2D start, Point2D end) { raycastCallback.reset(); jboxWorld.raycast(raycastCallback, toPoint(start), toPoint(end)); Entity entity = null; Point2D point = null; if (raycastCallback.getFixture() != null) entity = raycastCallback.getFixture().getBody().getEntity(); if (raycastCallback.getPoint() != null) point = toPoint(raycastCallback.getPoint()); if (entity == null && point == null) return RaycastResult.NONE; return new RaycastResult(entity, point); }
@Override public void endContact(Contact contact) { Entity e1 = contact.getFixtureA().getBody().getEntity(); Entity e2 = contact.getFixtureB().getBody().getEntity(); // check sensors first if (contact.getFixtureA().isSensor()) { notifySensorCollisionEnd(e1, e2, contact.getFixtureA().getHitBox()); return; } else if (contact.getFixtureB().isSensor()) { notifySensorCollisionEnd(e2, e1, contact.getFixtureB().getHitBox()); return; } if (!areCollidable(e1, e2)) return; CollisionHandler handler = getHandler(e1, e2); if (handler != null) { int pairIndex = getPairIndex(e1, e2); // collision registered, so remove it and put pair back to pool if (pairIndex != -1) { CollisionPair pair = collisions.get(pairIndex); collisions.removeIndex(pairIndex); pair.collisionEnd(); Pools.free(pair); } } }
@Override public void endContact(Contact contact) { Entity e1 = contact.getFixtureA().getBody().getEntity(); Entity e2 = contact.getFixtureB().getBody().getEntity(); // check sensors first if (contact.getFixtureA().isSensor()) { HitBox box = (HitBox) contact.getFixtureA().getUserData(); SensorCollisionHandler h = e1.getComponent(PhysicsComponent.class).getSensorHandlers().get(box); h.onCollisionEnd(e2); return; } else if (contact.getFixtureB().isSensor()) { HitBox box = (HitBox) contact.getFixtureB().getUserData(); SensorCollisionHandler h = e2.getComponent(PhysicsComponent.class).getSensorHandlers().get(box); h.onCollisionEnd(e1); return; } if (!areCollidable(e1, e2)) return; CollisionHandler handler = getHandler(e1, e2); if (handler != null) { int pairIndex = getPairIndex(e1, e2); // collision registered, so remove it and put pair back to pool if (pairIndex != -1) { CollisionPair pair = collisions.get(pairIndex); collisions.removeIndex(pairIndex); pair.collisionEnd(); Pools.free(pair); } } }
Body body = fixture.getBody(); int childCount = shape.getChildCount(); for (int childIndex = 0; childIndex < childCount; childIndex++) {
Body body = fixture.getBody(); int childCount = shape.getChildCount(); for (int childIndex = 0; childIndex < childCount; childIndex++) {