當前位置: 首頁>>代碼示例>>Java>>正文


Java Vec2.crossToOut方法代碼示例

本文整理匯總了Java中org.jbox2d.common.Vec2.crossToOut方法的典型用法代碼示例。如果您正苦於以下問題:Java Vec2.crossToOut方法的具體用法?Java Vec2.crossToOut怎麽用?Java Vec2.crossToOut使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jbox2d.common.Vec2的用法示例。


在下文中一共展示了Vec2.crossToOut方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setMassData

import org.jbox2d.common.Vec2; //導入方法依賴的package包/類
/**
 * Set the mass properties to override the mass properties of the fixtures. Note that this changes
 * the center of mass position. Note that creating or destroying fixtures can also alter the mass.
 * This function has no effect if the body isn't dynamic.
 * 
 * @param massData the mass properties.
 */
public final void setMassData(MassData massData) {
  // TODO_ERIN adjust linear velocity and torque to account for movement of center.
  assert (m_world.isLocked() == false);
  if (m_world.isLocked() == true) {
    return;
  }

  if (m_type != BodyType.DYNAMIC) {
    return;
  }

  m_invMass = 0.0f;
  m_I = 0.0f;
  m_invI = 0.0f;

  m_mass = massData.mass;
  if (m_mass <= 0.0f) {
    m_mass = 1f;
  }

  m_invMass = 1.0f / m_mass;

  if (massData.I > 0.0f && (m_flags & e_fixedRotationFlag) == 0) {
    m_I = massData.I - m_mass * Vec2.dot(massData.center, massData.center);
    assert (m_I > 0.0f);
    m_invI = 1.0f / m_I;
  }

  final Vec2 oldCenter = m_world.getPool().popVec2();
  // Move center of mass.
  oldCenter.set(m_sweep.c);
  m_sweep.localCenter.set(massData.center);
  // m_sweep.c0 = m_sweep.c = Mul(m_xf, m_sweep.localCenter);
  Transform.mulToOutUnsafe(m_xf, m_sweep.localCenter, m_sweep.c0);
  m_sweep.c.set(m_sweep.c0);

  // Update center of mass velocity.
  // m_linearVelocity += Cross(m_angularVelocity, m_sweep.c - oldCenter);
  final Vec2 temp = m_world.getPool().popVec2();
  temp.set(m_sweep.c).subLocal(oldCenter);
  Vec2.crossToOut(m_angularVelocity, temp, temp);
  m_linearVelocity.addLocal(temp);

  m_world.getPool().pushVec2(2);
}
 
開發者ID:jfcameron,項目名稱:G2Dj,代碼行數:53,代碼來源:Body.java


注:本文中的org.jbox2d.common.Vec2.crossToOut方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。