本文整理汇总了Java中org.jbox2d.callbacks.ContactListener.beginContact方法的典型用法代码示例。如果您正苦于以下问题:Java ContactListener.beginContact方法的具体用法?Java ContactListener.beginContact怎么用?Java ContactListener.beginContact使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jbox2d.callbacks.ContactListener
的用法示例。
在下文中一共展示了ContactListener.beginContact方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import org.jbox2d.callbacks.ContactListener; //导入方法依赖的package包/类
public void update(ContactListener listener) {
oldManifold.set(m_manifold);
// Re-enable this contact.
m_flags |= ENABLED_FLAG;
boolean touching = false;
boolean wasTouching = (m_flags & TOUCHING_FLAG) == TOUCHING_FLAG;
boolean sensorA = m_fixtureA.isSensor();
boolean sensorB = m_fixtureB.isSensor();
boolean sensor = sensorA || sensorB;
Body bodyA = m_fixtureA.getBody();
Body bodyB = m_fixtureB.getBody();
Transform xfA = bodyA.getTransform();
Transform xfB = bodyB.getTransform();
// log.debug("TransformA: "+xfA);
// log.debug("TransformB: "+xfB);
if (sensor) {
Shape shapeA = m_fixtureA.getShape();
Shape shapeB = m_fixtureB.getShape();
touching = pool.getCollision().testOverlap(shapeA, m_indexA, shapeB, m_indexB, xfA, xfB);
// Sensors don't generate manifolds.
m_manifold.pointCount = 0;
} else {
evaluate(m_manifold, xfA, xfB);
touching = m_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 < m_manifold.pointCount; ++i) {
ManifoldPoint mp2 = m_manifold.points[i];
mp2.normalImpulse = 0.0f;
mp2.tangentImpulse = 0.0f;
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 (touching != wasTouching) {
bodyA.setAwake(true);
bodyB.setAwake(true);
}
}
if (touching) {
m_flags |= TOUCHING_FLAG;
} else {
m_flags &= ~TOUCHING_FLAG;
}
if (listener == null) {
return;
}
if (wasTouching == false && touching == true) {
listener.beginContact(this);
}
if (wasTouching == true && touching == false) {
listener.endContact(this);
}
if (sensor == false && touching) {
listener.preSolve(this, oldManifold);
}
}
示例2: update
import org.jbox2d.callbacks.ContactListener; //导入方法依赖的package包/类
public void update(ContactListener listener) {
Manifold oldManifold = tloldManifold.get();
oldManifold.set(m_manifold);
// Re-enable this contact.
m_flags |= ENABLED_FLAG;
boolean touching = false;
boolean wasTouching = (m_flags & TOUCHING_FLAG) == TOUCHING_FLAG;
boolean sensorA = m_fixtureA.isSensor();
boolean sensorB = m_fixtureB.isSensor();
boolean sensor = sensorA || sensorB;
Body bodyA = m_fixtureA.getBody();
Body bodyB = m_fixtureB.getBody();
Transform xfA = bodyA.getTransform();
Transform xfB = bodyB.getTransform();
//log.debug("TransformA: "+xfA);
//log.debug("TransformB: "+xfB);
if (sensor) {
Shape shapeA = m_fixtureA.getShape();
Shape shapeB = m_fixtureB.getShape();
touching = pool.getCollision().testOverlap(shapeA, shapeB,
xfA, xfB);
// Sensors don't generate manifolds.
m_manifold.pointCount = 0;
} else {
evaluate(m_manifold, xfA, xfB);
touching = m_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 < m_manifold.pointCount; ++i) {
ManifoldPoint mp2 = m_manifold.points[i];
mp2.normalImpulse = 0.0f;
mp2.tangentImpulse = 0.0f;
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 (touching != wasTouching) {
bodyA.setAwake(true);
bodyB.setAwake(true);
}
}
if (touching) {
m_flags |= TOUCHING_FLAG;
} else {
m_flags &= ~TOUCHING_FLAG;
}
if (listener == null) {
return;
}
if (wasTouching == false && touching == true) {
listener.beginContact(this);
}
if (wasTouching == true && touching == false) {
listener.endContact(this);
}
if (sensor == false && touching) {
listener.preSolve(this, oldManifold);
}
}
示例3: update
import org.jbox2d.callbacks.ContactListener; //导入方法依赖的package包/类
public void update(ContactListener listener) {
oldManifold.set(m_manifold);
// Re-enable this contact.
m_flags |= ENABLED_FLAG;
boolean touching = false;
boolean wasTouching = (m_flags & TOUCHING_FLAG) == TOUCHING_FLAG;
boolean sensorA = m_fixtureA.isSensor();
boolean sensorB = m_fixtureB.isSensor();
boolean sensor = sensorA || sensorB;
Body bodyA = m_fixtureA.getBody();
Body bodyB = m_fixtureB.getBody();
Transform xfA = bodyA.getTransform();
Transform xfB = bodyB.getTransform();
//log.debug("TransformA: "+xfA);
//log.debug("TransformB: "+xfB);
if (sensor) {
Shape shapeA = m_fixtureA.getShape();
Shape shapeB = m_fixtureB.getShape();
touching = pool.getCollision().testOverlap(shapeA, shapeB,
xfA, xfB);
// Sensors don't generate manifolds.
m_manifold.pointCount = 0;
} else {
evaluate(m_manifold, xfA, xfB);
touching = m_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 < m_manifold.pointCount; ++i) {
ManifoldPoint mp2 = m_manifold.points[i];
mp2.normalImpulse = 0.0f;
mp2.tangentImpulse = 0.0f;
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 (touching != wasTouching) {
bodyA.setAwake(true);
bodyB.setAwake(true);
}
}
if (touching) {
m_flags |= TOUCHING_FLAG;
} else {
m_flags &= ~TOUCHING_FLAG;
}
if (listener == null) {
return;
}
if (wasTouching == false && touching == true) {
listener.beginContact(this);
}
if (wasTouching == true && touching == false) {
listener.endContact(this);
}
if (sensor == false && touching) {
listener.preSolve(this, oldManifold);
}
}