• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ManifoldPoint类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OperationType类代码示例发布时间:2022-05-22
下一篇:
Java Jump类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap