userData = bd.getUserData(); if (bd.isBullet()) { m_flags |= e_bulletFlag; if (bd.isFixedRotation()) { m_flags |= e_fixedRotationFlag; if (bd.isAllowSleep()) { m_flags |= e_autoSleepFlag; if (bd.isAwake()) { m_flags |= e_awakeFlag; if (bd.isActive()) { m_flags |= e_activeFlag; m_xf.p.set(bd.getPosition()); m_xf.q.set(bd.getAngle()); m_sweep.a0 = bd.getAngle(); m_sweep.a = bd.getAngle(); m_sweep.alpha0 = 0.0f; m_linearVelocity.set(bd.getLinearVelocity()); m_angularVelocity = bd.getAngularVelocity(); linearDamping = bd.getLinearDamping(); angularDamping = bd.getAngularDamping();
private void checkValid(BodyDef def) { if (!def.getPosition().isValid()) throw new IllegalArgumentException("Position is invalid"); if (!def.getLinearVelocity().isValid()) throw new IllegalArgumentException("Linear velocity is invalid"); if (def.getGravityScale() < 0) throw new IllegalArgumentException("Gravity scale is invalid"); if (def.getAngularDamping() < 0) throw new IllegalArgumentException("Angular damping is invalid"); if (def.getLinearDamping() < 0) throw new IllegalArgumentException("Linear damping is invalid"); }
/** * Create physics body and attach to physics world. * * @param e physics entity */ private void createBody(Entity e) { PhysicsComponent physics = e.getComponent(PhysicsComponent.class); physics.setWorld(this); // if position is 0, 0 then probably not set, so set ourselves if (physics.bodyDef.getPosition().x == 0 && physics.bodyDef.getPosition().y == 0) { physics.bodyDef.getPosition().set(toPoint(e.getCenter())); } if (physics.bodyDef.getAngle() == 0) { physics.bodyDef.setAngle((float) -Math.toRadians(e.getRotation())); } physics.body = jboxWorld.createBody(physics.bodyDef); createFixtures(e); createSensors(e); physics.body.setEntity(e); physics.onInitPhysics(); }
private void checkValid(BodyDef def) { if (!def.getPosition().isValid()) throw new IllegalArgumentException("Position is invalid"); if (!def.getLinearVelocity().isValid()) throw new IllegalArgumentException("Linear velocity is invalid"); if (def.getGravityScale() < 0) throw new IllegalArgumentException("Gravity scale is invalid"); if (def.getAngularDamping() < 0) throw new IllegalArgumentException("Angular damping is invalid"); if (def.getLinearDamping() < 0) throw new IllegalArgumentException("Linear damping is invalid"); }
/** * Create physics body and attach to physics world. * * @param e physics entity */ private void createBody(Entity e) { PhysicsComponent physics = e.getComponent(PhysicsComponent.class); // if position is 0, 0 then probably not set, so set ourselves if (physics.bodyDef.getPosition().x == 0 && physics.bodyDef.getPosition().y == 0) { physics.bodyDef.getPosition().set(toPoint(e.getCenter())); } if (physics.bodyDef.getAngle() == 0) { physics.bodyDef.setAngle((float) -Math.toRadians(e.getRotation())); } physics.body = jboxWorld.createBody(physics.bodyDef); createFixtures(e); if (physics.isGenerateGroundSensor()) { createGroundSensor(e); } createSensors(e); physics.body.setEntity(e); physics.onInitPhysics(); }
userData = bd.getUserData(); if (bd.isBullet()) { m_flags |= e_bulletFlag; if (bd.isFixedRotation()) { m_flags |= e_fixedRotationFlag; if (bd.isAllowSleep()) { m_flags |= e_autoSleepFlag; if (bd.isAwake()) { m_flags |= e_awakeFlag; if (bd.isActive()) { m_flags |= e_activeFlag; m_xf.p.set(bd.getPosition()); m_xf.q.set(bd.getAngle()); m_sweep.a0 = bd.getAngle(); m_sweep.a = bd.getAngle(); m_sweep.alpha0 = 0.0f; m_linearVelocity.set(bd.getLinearVelocity()); m_angularVelocity = bd.getAngularVelocity(); linearDamping = bd.getLinearDamping(); angularDamping = bd.getAngularDamping();