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


Java ManifoldPoint类代码示例

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


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

示例1: update

import org.jbox2d.collision.ManifoldPoint; //导入依赖的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: testManifoldConstructor

import org.jbox2d.collision.ManifoldPoint; //导入依赖的package包/类
@Test
public void testManifoldConstructor() {
    ManifoldPoint thePoint = new ManifoldPoint();
    Assert.assertNotNull(thePoint.id);
}
 
开发者ID:mirkosertic,项目名称:Bytecoder,代码行数:6,代码来源:JBox2DTest.java

示例3: update

import org.jbox2d.collision.ManifoldPoint; //导入依赖的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

示例4: initialize

import org.jbox2d.collision.ManifoldPoint; //导入依赖的package包/类
public void initialize(Contact[] contacts, int count, Body toiBody){
		//clear();
		
		m_count = count;
		m_toiBody = toiBody;
		
		// TODO djm: can I pool this? for now just having an expandable array
		if(m_count >= m_constraints.length){
			TOIConstraint[] old = m_constraints;
			m_constraints = new TOIConstraint[old.length*2];
			System.arraycopy(old, 0, m_constraints, 0, old.length);
			for(int i=old.length; i<m_constraints.length; i++){
				m_constraints[i] = new TOIConstraint();
			}
		}
//		m_constraints = new TOIConstraint[count];

		for(int i=0; i<m_count; i++){
			Contact contact = contacts[i];
			
			Fixture fixtureA = contact.getFixtureA();
			Fixture fixtureB = contact.getFixtureB();
			Shape shapeA = fixtureA.getShape();
			Shape shapeB = fixtureB.getShape();
			float radiusA = shapeA.m_radius;
			float radiusB = shapeB.m_radius;
			Body bodyA = fixtureA.getBody();
			Body bodyB = fixtureB.getBody();
			Manifold manifold = contact.getManifold();
			
			assert(manifold.pointCount > 0);
			
//			m_constraints[i] = new TOIConstraint();
			TOIConstraint constraint = m_constraints[i];
			constraint.bodyA = bodyA;
			constraint.bodyB = bodyB;
			constraint.localNormal.set(manifold.localNormal);
			constraint.localPoint.set(manifold.localPoint);
			constraint.type = manifold.type;
			constraint.pointCount = manifold.pointCount;
			constraint.radius = radiusA + radiusB;

			for (int j = 0; j < constraint.pointCount; ++j){
				ManifoldPoint cp = manifold.points[j];
				constraint.localPoints[j] = cp.localPoint;
			}
		}
	}
 
开发者ID:mleoking,项目名称:PhET,代码行数:49,代码来源:TOISolver.java

示例5: update

import org.jbox2d.collision.ManifoldPoint; //导入依赖的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

示例6: initialize

import org.jbox2d.collision.ManifoldPoint; //导入依赖的package包/类
public void initialize(Contact[] contacts, int count, Body toiBody){
	//clear();
	
	m_count = count;
	m_toiBody = toiBody;
	
	if(m_count > m_constraints.length){
		TOIConstraint[] old = m_constraints;
		// thanks zel1990!  Fix for issue 24
		final int newLen = MathUtils.max(m_count, old.length*2);
		m_constraints = new TOIConstraint[newLen];
		System.arraycopy(old, 0, m_constraints, 0, old.length);
		for(int i=old.length; i<m_constraints.length; i++){
			m_constraints[i] = new TOIConstraint();
		}
	}

	for(int i=0; i<m_count; i++){
		Contact contact = contacts[i];
		
		Fixture fixtureA = contact.getFixtureA();
		Fixture fixtureB = contact.getFixtureB();
		Shape shapeA = fixtureA.getShape();
		Shape shapeB = fixtureB.getShape();
		float radiusA = shapeA.m_radius;
		float radiusB = shapeB.m_radius;
		Body bodyA = fixtureA.getBody();
		Body bodyB = fixtureB.getBody();
		Manifold manifold = contact.getManifold();
		
		assert(manifold.pointCount > 0);
		
		TOIConstraint constraint = m_constraints[i];
		constraint.bodyA = bodyA;
		constraint.bodyB = bodyB;
		constraint.localNormal.set(manifold.localNormal);
		constraint.localPoint.set(manifold.localPoint);
		constraint.type = manifold.type;
		constraint.pointCount = manifold.pointCount;
		constraint.radius = radiusA + radiusB;

		for (int j = 0; j < constraint.pointCount; ++j){
			ManifoldPoint cp = manifold.points[j];
			constraint.localPoints[j] = cp.localPoint;
		}
	}
}
 
开发者ID:col726,项目名称:game-engine-CMZ,代码行数:48,代码来源:TOISolver.java


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