当前位置: 首页>>代码示例>>Java>>正文


Java ContactID类代码示例

本文整理汇总了Java中org.jbox2d.collision.ContactID的典型用法代码示例。如果您正苦于以下问题:Java ContactID类的具体用法?Java ContactID怎么用?Java ContactID使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ContactID类属于org.jbox2d.collision包,在下文中一共展示了ContactID类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: update

import org.jbox2d.collision.ContactID; //导入依赖的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);
    }
  }
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:80,代码来源:Contact.java

示例2: update

import org.jbox2d.collision.ContactID; //导入依赖的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);
		}
	}
 
开发者ID:mleoking,项目名称:PhET,代码行数:82,代码来源:Contact.java

示例3: update

import org.jbox2d.collision.ContactID; //导入依赖的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);
	}
}
 
开发者ID:col726,项目名称:game-engine-CMZ,代码行数:81,代码来源:Contact.java


注:本文中的org.jbox2d.collision.ContactID类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。