/** * Create a particle whose properties have been defined. No reference to the definition is * retained. A simulation step must occur before it's possible to interact with a newly created * particle. For example, DestroyParticleInShape() will not destroy a particle until Step() has * been called. This function is locked during callbacks. * * @return the index of the particle. */ public int createParticle(ParticleDef def) { assertNotLocked(); return particleSystem.createParticle(def); }
/** * Destroy body and remove from physics world. * * @param e physics entity */ private void destroyBody(Entity e) { jboxWorld.destroyBody(e.getComponent(PhysicsComponent.class).body); }
private void destroyAttachedJoints() { JointEdge je = this.m_jointList; while (je != null) { JointEdge je0 = je; je = je.next; if (world.getDestructionListener() != null) { world.getDestructionListener().onDestroy(je0.joint); } world.destroyJoint(je0.joint); this.m_jointList = je; } this.m_jointList = null; }
world.assertNotLocked(); BroadPhase broadPhase = world.getContactManager().broadPhase; for (Fixture f : fixtures) { f.createProxies(broadPhase, m_xf); BroadPhase broadPhase = world.getContactManager().broadPhase; for (Fixture f : fixtures) { f.destroyProxies(broadPhase);
solve(step); solveTOI(step); if (isAutoClearForces()) { clearForces();
/** * 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. * Note: This function is locked during callbacks. * * @param def the fixture definition */ public Fixture createFixture(FixtureDef def) { world.assertNotLocked(); Fixture fixture = new Fixture(this, def); if ((m_flags & e_activeFlag) == e_activeFlag) { BroadPhase broadPhase = world.getContactManager().broadPhase; fixture.createProxies(broadPhase, m_xf); } fixtures.add(fixture); // Adjust mass properties if needed. if (fixture.getDensity() > 0) { 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. world.notifyNewFixture(); return fixture; }
world.assertNotLocked(); final Vec2 oldCenter = world.getPool().popVec2(); final Vec2 temp = world.getPool().popVec2(); temp.set(m_sweep.c).subLocal(oldCenter); Vec2.crossToOut(m_angularVelocity, temp, temp); m_linearVelocity.addLocal(temp); world.getPool().pushVec2(2);
public ConstantVolumeJoint(World argWorld, ConstantVolumeJointDef def) { super(argWorld.getPool(), def); world = argWorld; if (def.bodies.size() <= 2) { djd.initialize(bodies[i], bodies[next], bodies[i].getWorldCenter(), bodies[next].getWorldCenter()); distanceJoints[i] = (DistanceJoint) world.createJoint(djd);
@Override public void destructor() { for (int i = 0; i < distanceJoints.length; ++i) { world.destroyJoint(distanceJoints[i]); } }
/** * Destroy particles in a group without enabling the destruction callback for destroyed particles. * This function is locked during callbacks. * * @param group the particle group to destroy. */ public void destroyParticlesInGroup(ParticleGroup group) { destroyParticlesInGroup(group, false); }
/** * Destroy a particle. The particle is removed after the next step. * * @param index particle index */ public void destroyParticle(int index) { destroyParticle(index, false); }
/** * Destroy particles inside a shape without enabling the destruction callback for destroyed * particles. This function is locked during callbacks. For more information see * DestroyParticleInShape(Shape&, Transform&,bool). * This function is locked during callbacks. * * @param shape which encloses particles that should be destroyed. * @param xf transform applied to the shape. * @return Number of particles destroyed. */ public int destroyParticlesInShape(Shape shape, Transform xf) { return destroyParticlesInShape(shape, xf, false); }
/** * 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(); }
island.init(getBodyCount(), contactManager.contactCount, jointCount, contactManager.getContactListener()); int stackSize = getBodyCount(); if (stack.length < stackSize) { stack = new Body[stackSize];
world.assertNotLocked(); BroadPhase broadPhase = world.getContactManager().broadPhase; for (Fixture f : fixtures) { f.createProxies(broadPhase, m_xf); BroadPhase broadPhase = world.getContactManager().broadPhase; for (Fixture f : fixtures) { f.destroyProxies(broadPhase);
solve(step); solveTOI(step); if (isAutoClearForces()) { clearForces();
/** * 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. * Note: This function is locked during callbacks. * * @param def the fixture definition */ public Fixture createFixture(FixtureDef def) { world.assertNotLocked(); Fixture fixture = new Fixture(this, def); if ((m_flags & e_activeFlag) == e_activeFlag) { BroadPhase broadPhase = world.getContactManager().broadPhase; fixture.createProxies(broadPhase, m_xf); } fixtures.add(fixture); // Adjust mass properties if needed. if (fixture.getDensity() > 0) { 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. world.notifyNewFixture(); return fixture; }
world.assertNotLocked(); final Vec2 oldCenter = world.getPool().popVec2(); final Vec2 temp = world.getPool().popVec2(); temp.set(m_sweep.c).subLocal(oldCenter); Vec2.crossToOut(m_angularVelocity, temp, temp); m_linearVelocity.addLocal(temp); world.getPool().pushVec2(2);
public ConstantVolumeJoint(World argWorld, ConstantVolumeJointDef def) { super(argWorld.getPool(), def); world = argWorld; if (def.bodies.size() <= 2) { djd.initialize(bodies[i], bodies[next], bodies[i].getWorldCenter(), bodies[next].getWorldCenter()); distanceJoints[i] = (DistanceJoint) world.createJoint(djd);
@Override public void destructor() { for (int i = 0; i < distanceJoints.length; ++i) { world.destroyJoint(distanceJoints[i]); } }