本文整理匯總了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);
}