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


Java BroadPhase类代码示例

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


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

示例1: setTransform

import org.jbox2d.collision.broadphase.BroadPhase; //导入依赖的package包/类
/**
 * Set the position of the body's origin and rotation. This breaks any contacts and wakes the
 * other bodies. Manipulating a body's transform may cause non-physical behavior. Note: contacts
 * are updated on the next call to World.step().
 * 
 * @param position the world position of the body's local origin.
 * @param angle the world rotation in radians.
 */
public final void setTransform(Vec2 position, float angle) {
  assert (m_world.isLocked() == false);
  if (m_world.isLocked() == true) {
    return;
  }

  m_xf.q.set(angle);
  m_xf.p.set(position);

  // m_sweep.c0 = m_sweep.c = Mul(m_xf, m_sweep.localCenter);
  Transform.mulToOutUnsafe(m_xf, m_sweep.localCenter, m_sweep.c);
  m_sweep.a = angle;

  m_sweep.c0.set(m_sweep.c);
  m_sweep.a0 = m_sweep.a;

  BroadPhase broadPhase = m_world.m_contactManager.m_broadPhase;
  for (Fixture f = m_fixtureList; f != null; f = f.m_next) {
    f.synchronize(broadPhase, m_xf, m_xf);
  }
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:30,代码来源:Body.java

示例2: setTransform

import org.jbox2d.collision.broadphase.BroadPhase; //导入依赖的package包/类
/**
 * Set the position of the body's origin and rotation.
 * This breaks any contacts and wakes the other bodies.
 * Manipulating a body's transform may cause non-physical behavior.
 * 
 * @param position
 *            the world position of the body's local origin.
 * @param angle
 *            the world rotation in radians.
 */
public final void setTransform(Vec2 position, float angle) {
	assert (m_world.isLocked() == false);
	if (m_world.isLocked() == true) {
		return;
	}
	
	m_xf.R.set(angle);
	m_xf.position.set(position);
	
	// m_sweep.c0 = m_sweep.c = Mul(m_xf, m_sweep.localCenter);
	Transform.mulToOut(m_xf, m_sweep.localCenter, m_sweep.c0);
	m_sweep.c.set(m_sweep.c0);
	
	m_sweep.a0 = m_sweep.a = angle;
	
	BroadPhase broadPhase = m_world.m_contactManager.m_broadPhase;
	for (Fixture f = m_fixtureList; f != null; f = f.m_next) {
		f.synchronize(broadPhase, m_xf, m_xf);
	}
	
	m_world.m_contactManager.findNewContacts();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:33,代码来源:Body.java

示例3: synchronize

import org.jbox2d.collision.broadphase.BroadPhase; //导入依赖的package包/类
/**
 * Internal method
 * 
 * @param broadPhase
 * @param xf1
 * @param xf2
 */
protected void synchronize(BroadPhase broadPhase, final Transform transform1,
    final Transform transform2) {
  if (m_proxyCount == 0) {
    return;
  }

  for (int i = 0; i < m_proxyCount; ++i) {
    FixtureProxy proxy = m_proxies[i];

    // Compute an AABB that covers the swept shape (may miss some rotation effect).
    final AABB aabb1 = pool1;
    final AABB aab = pool2;
    m_shape.computeAABB(aabb1, transform1, proxy.childIndex);
    m_shape.computeAABB(aab, transform2, proxy.childIndex);

    proxy.aabb.lowerBound.x = aabb1.lowerBound.x < aab.lowerBound.x ? aabb1.lowerBound.x : aab.lowerBound.x;
    proxy.aabb.lowerBound.y = aabb1.lowerBound.y < aab.lowerBound.y ? aabb1.lowerBound.y : aab.lowerBound.y;
    proxy.aabb.upperBound.x = aabb1.upperBound.x > aab.upperBound.x ? aabb1.upperBound.x : aab.upperBound.x;
    proxy.aabb.upperBound.y = aabb1.upperBound.y > aab.upperBound.y ? aabb1.upperBound.y : aab.upperBound.y;
    displacement.x = transform2.p.x - transform1.p.x;
    displacement.y = transform2.p.y - transform1.p.y;

    broadPhase.moveProxy(proxy.proxyId, proxy.aabb, displacement);
  }
}
 
开发者ID:pianoman373,项目名称:Point-Engine,代码行数:33,代码来源:Fixture.java

示例4: setTransform

import org.jbox2d.collision.broadphase.BroadPhase; //导入依赖的package包/类
/**
 * Set the position of the body's origin and rotation. This breaks any contacts and wakes the
 * other bodies. Manipulating a body's transform may cause non-physical behavior.
 * 
 * @param position the world position of the body's local origin.
 * @param angle the world rotation in radians.
 */
public final void setTransform(Vector2 position, float angle) {
  assert (m_world.isLocked() == false);
  if (m_world.isLocked() == true) {
    return;
  }

  m_xf.q.set(angle);
  m_xf.p.set(position);

  // m_sweep.c0 = m_sweep.c = Mul(m_xf, m_sweep.localCenter);
  Transform.mulToOutUnsafe(m_xf, m_sweep.localCenter, m_sweep.c);
  m_sweep.a = angle;

  m_sweep.c0.set(m_sweep.c);
  m_sweep.a0 = m_sweep.a;

  BroadPhase broadPhase = m_world.m_contactManager.m_broadPhase;
  for (Fixture f = m_fixtureList; f != null; f = f.m_next) {
    f.synchronize(broadPhase, m_xf, m_xf);
  }

  m_world.m_contactManager.findNewContacts();
}
 
开发者ID:pianoman373,项目名称:Point-Engine,代码行数:31,代码来源:Body.java

示例5: setTransform

import org.jbox2d.collision.broadphase.BroadPhase; //导入依赖的package包/类
/**
 * Set the position of the body's origin and rotation. This breaks any contacts and wakes the
 * other bodies. Manipulating a body's transform may cause non-physical behavior.
 * 
 * @param position the world position of the body's local origin.
 * @param angle the world rotation in radians.
 */
public final void setTransform(Vec2 position, float angle) {
  assert (m_world.isLocked() == false);
  if (m_world.isLocked() == true) {
    return;
  }

  m_xf.q.set(angle);
  m_xf.p.set(position);

  // m_sweep.c0 = m_sweep.c = Mul(m_xf, m_sweep.localCenter);
  Transform.mulToOutUnsafe(m_xf, m_sweep.localCenter, m_sweep.c);
  m_sweep.a = angle;

  m_sweep.c0.set(m_sweep.c);
  m_sweep.a0 = m_sweep.a;

  BroadPhase broadPhase = m_world.m_contactManager.m_broadPhase;
  for (Fixture f = m_fixtureList; f != null; f = f.m_next) {
    f.synchronize(broadPhase, m_xf, m_xf);
  }

  m_world.m_contactManager.findNewContacts();
}
 
开发者ID:weimingtom,项目名称:jbox2d,代码行数:31,代码来源:Body.java

示例6: setTransform

import org.jbox2d.collision.broadphase.BroadPhase; //导入依赖的package包/类
/**
 * Set the position of the body's origin and rotation. This breaks any
 * contacts and wakes the other bodies. Manipulating a body's transform may
 * cause non-physical behavior.
 * 
 * @param position
 *            the world position of the body's local origin.
 * @param angle
 *            the world rotation in radians.
 */
public final void setTransform(Vec2 position, float angle) {
	assert (m_world.isLocked() == false);
	if (m_world.isLocked() == true) {
		return;
	}

	m_xf.R.set(angle);
	m_xf.position.set(position);

	// m_sweep.c0 = m_sweep.c = Mul(m_xf, m_sweep.localCenter);
	Transform.mulToOut(m_xf, m_sweep.localCenter, m_sweep.c0);
	m_sweep.c.set(m_sweep.c0);

	m_sweep.a0 = m_sweep.a = angle;

	BroadPhase broadPhase = m_world.m_contactManager.m_broadPhase;
	for (Fixture f = m_fixtureList; f != null; f = f.m_next) {
		f.synchronize(broadPhase, m_xf, m_xf);
	}

	m_world.m_contactManager.findNewContacts();
}
 
开发者ID:col726,项目名称:game-engine-CMZ,代码行数:33,代码来源:Body.java

示例7: refilter

import org.jbox2d.collision.broadphase.BroadPhase; //导入依赖的package包/类
/**
 * Call this if you want to establish collision that was previously disabled by
 * ContactFilter::ShouldCollide.
 */
public void refilter() {
  if (m_body == null) {
    return;
  }

  // Flag associated contacts for filtering.
  ContactEdge edge = m_body.getContactList();
  while (edge != null) {
    Contact contact = edge.contact;
    Fixture fixtureA = contact.getFixtureA();
    Fixture fixtureB = contact.getFixtureB();
    if (fixtureA == this || fixtureB == this) {
      contact.flagForFiltering();
    }
    edge = edge.next;
  }

  World world = m_body.getWorld();

  if (world == null) {
    return;
  }

  // Touch each proxy so that new pairs may be created
  BroadPhase broadPhase = world.m_contactManager.m_broadPhase;
  for (int i = 0; i < m_proxyCount; ++i) {
    broadPhase.touchProxy(m_proxies[i].proxyId);
  }
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:34,代码来源:Fixture.java

示例8: createProxies

import org.jbox2d.collision.broadphase.BroadPhase; //导入依赖的package包/类
public void createProxies(BroadPhase broadPhase, final Transform xf) {
  assert (m_proxyCount == 0);

  // Create proxies in the broad-phase.
  m_proxyCount = m_shape.getChildCount();

  for (int i = 0; i < m_proxyCount; ++i) {
    FixtureProxy proxy = m_proxies[i];
    m_shape.computeAABB(proxy.aabb, xf, i);
    proxy.proxyId = broadPhase.createProxy(proxy.aabb, proxy);
    proxy.fixture = this;
    proxy.childIndex = i;
  }
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:15,代码来源:Fixture.java

示例9: destroyProxies

import org.jbox2d.collision.broadphase.BroadPhase; //导入依赖的package包/类
/**
 * Internal method
 * 
 * @param broadPhase
 */
public void destroyProxies(BroadPhase broadPhase) {
  // Destroy proxies in the broad-phase.
  for (int i = 0; i < m_proxyCount; ++i) {
    FixtureProxy proxy = m_proxies[i];
    broadPhase.destroyProxy(proxy.proxyId);
    proxy.proxyId = BroadPhase.NULL_PROXY;
  }

  m_proxyCount = 0;
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:16,代码来源:Fixture.java

示例10: synchronize

import org.jbox2d.collision.broadphase.BroadPhase; //导入依赖的package包/类
/**
 * Internal method
 * 
 * @param broadPhase
 * @param xf1
 * @param xf2
 */
protected void synchronize(BroadPhase broadPhase, final Transform transform1,
    final Transform transform2) {
  if (m_proxyCount == 0) {
    return;
  }

  for (int i = 0; i < m_proxyCount; ++i) {
    FixtureProxy proxy = m_proxies[i];

    // Compute an AABB that covers the swept shape (may miss some rotation effect).
    final AABB aabb1 = pool1;
    final AABB aab = pool2;
    m_shape.computeAABB(aabb1, transform1, proxy.childIndex);
    m_shape.computeAABB(aab, transform2, proxy.childIndex);

    proxy.aabb.lowerBound.x =
        aabb1.lowerBound.x < aab.lowerBound.x ? aabb1.lowerBound.x : aab.lowerBound.x;
    proxy.aabb.lowerBound.y =
        aabb1.lowerBound.y < aab.lowerBound.y ? aabb1.lowerBound.y : aab.lowerBound.y;
    proxy.aabb.upperBound.x =
        aabb1.upperBound.x > aab.upperBound.x ? aabb1.upperBound.x : aab.upperBound.x;
    proxy.aabb.upperBound.y =
        aabb1.upperBound.y > aab.upperBound.y ? aabb1.upperBound.y : aab.upperBound.y;
    displacement.x = transform2.p.x - transform1.p.x;
    displacement.y = transform2.p.y - transform1.p.y;

    broadPhase.moveProxy(proxy.proxyId, proxy.aabb, displacement);
  }
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:37,代码来源:Fixture.java

示例11: createFixture

import org.jbox2d.collision.broadphase.BroadPhase; //导入依赖的package包/类
/**
 * Creates a fixture and attach it to this body. Use this function if you need to set some fixture
 * parameters, like friction. Otherwise you can create the fixture directly from a shape. If the
 * density is non-zero, this function automatically updates the mass of the body. Contacts are not
 * created until the next time step.
 * 
 * @param def the fixture definition.
 * @warning This function is locked during callbacks.
 */
public final Fixture createFixture(FixtureDef def) {
  assert (m_world.isLocked() == false);

  if (m_world.isLocked() == true) {
    return null;
  }

  Fixture fixture = new Fixture();
  fixture.create(this, def);

  if ((m_flags & e_activeFlag) == e_activeFlag) {
    BroadPhase broadPhase = m_world.m_contactManager.m_broadPhase;
    fixture.createProxies(broadPhase, m_xf);
  }

  fixture.m_next = m_fixtureList;
  m_fixtureList = fixture;
  ++m_fixtureCount;

  fixture.m_body = this;

  // Adjust mass properties if needed.
  if (fixture.m_density > 0.0f) {
    resetMassData();
  }

  // Let the world know we have a new fixture. This will cause new contacts
  // to be created at the beginning of the next time step.
  m_world.m_flags |= World.NEW_FIXTURE;

  return fixture;
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:42,代码来源:Body.java

示例12: ContactManager

import org.jbox2d.collision.broadphase.BroadPhase; //导入依赖的package包/类
public ContactManager(World argPool, BroadPhase broadPhase) {
  m_contactList = null;
  m_contactCount = 0;
  m_contactFilter = new ContactFilter();
  m_contactListener = null;
  m_broadPhase = broadPhase;
  pool = argPool;
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:9,代码来源:ContactManager.java

示例13: World

import org.jbox2d.collision.broadphase.BroadPhase; //导入依赖的package包/类
public World(Vec2 gravity, IWorldPool pool, BroadPhase broadPhase) {
  this.pool = pool;
  m_destructionListener = null;
  m_debugDraw = null;

  m_bodyList = null;
  m_jointList = null;

  m_bodyCount = 0;
  m_jointCount = 0;

  m_warmStarting = true;
  m_continuousPhysics = true;
  m_subStepping = false;
  m_stepComplete = true;

  m_allowSleep = true;
  m_gravity.set(gravity);

  m_flags = CLEAR_FORCES;

  m_inv_dt0 = 0f;

  m_contactManager = new ContactManager(this, broadPhase);
  m_profile = new Profile();

  m_particleSystem = new ParticleSystem(this);

  initializeRegisters();
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:31,代码来源:World.java

示例14: createProxy

import org.jbox2d.collision.broadphase.BroadPhase; //导入依赖的package包/类
public void createProxy(BroadPhase broadPhase, final Transform xf){
	assert(m_proxy == null);
	
	// Create proxy in the broad-phase.
	m_shape.computeAABB( m_aabb, xf);
	m_proxy = broadPhase.createProxy( m_aabb, this);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:Fixture.java

示例15: destroyProxy

import org.jbox2d.collision.broadphase.BroadPhase; //导入依赖的package包/类
/**
 * Internal method
 * @param broadPhase
 */
public void destroyProxy(BroadPhase broadPhase){
	if(m_proxy == null){
		return;
	}
	
	broadPhase.destroyProxy( m_proxy);
	m_proxy = null;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:13,代码来源:Fixture.java


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