/** * 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); }
/** * Create a particle group whose properties have been defined. No reference to the definition is * retained. This function is locked during callbacks. * * @param def particle group definition * @return particle group */ public ParticleGroup createParticleGroup(ParticleGroupDef def) { assertNotLocked(); return particleSystem.createParticleGroup(def); }
/** * Join two particle groups. This function is locked during callbacks. * * @param groupA the first group. Expands to encompass the second group. * @param groupB the second group. It is destroyed. */ public void joinParticleGroups(ParticleGroup groupA, ParticleGroup groupB) { assertNotLocked(); particleSystem.joinParticleGroups(groupA, groupB); }
/** * 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); }
/** * Create a particle group whose properties have been defined. No reference to the definition is * retained. This function is locked during callbacks. * * @param def particle group definition * @return particle group */ public ParticleGroup createParticleGroup(ParticleGroupDef def) { assertNotLocked(); return particleSystem.createParticleGroup(def); }
/** * Destroy particles in a group. This function is locked during callbacks. * * @param group the particle group to destroy. * @param callDestructionListener Whether to call the world b2DestructionListener for each particle is destroyed. */ public void destroyParticlesInGroup(ParticleGroup group, boolean callDestructionListener) { assertNotLocked(); particleSystem.destroyParticlesInGroup(group, callDestructionListener); }
/** * Destroy particles inside a shape. This function is locked during callbacks. In addition, this * function immediately destroys particles in the shape in contrast to DestroyParticle() which * defers the destruction until the next simulation step. This function is locked during callbacks. * * @param shape which encloses particles that should be destroyed. * @param xf transform applied to the shape. * @param callDestructionListener whether to call the world b2DestructionListener for each particle destroyed. * @return Number of particles destroyed. */ public int destroyParticlesInShape(Shape shape, Transform xf, boolean callDestructionListener) { assertNotLocked(); return particleSystem.destroyParticlesInShape(shape, xf, callDestructionListener); }
/** * Join two particle groups. This function is locked during callbacks. * * @param groupA the first group. Expands to encompass the second group. * @param groupB the second group. It is destroyed. */ public void joinParticleGroups(ParticleGroup groupA, ParticleGroup groupB) { assertNotLocked(); particleSystem.joinParticleGroups(groupA, groupB); }
/** * Destroy particles in a group. This function is locked during callbacks. * * @param group the particle group to destroy. * @param callDestructionListener Whether to call the world b2DestructionListener for each particle is destroyed. */ public void destroyParticlesInGroup(ParticleGroup group, boolean callDestructionListener) { assertNotLocked(); particleSystem.destroyParticlesInGroup(group, callDestructionListener); }
/** * Destroy particles inside a shape. This function is locked during callbacks. In addition, this * function immediately destroys particles in the shape in contrast to DestroyParticle() which * defers the destruction until the next simulation step. This function is locked during callbacks. * * @param shape which encloses particles that should be destroyed. * @param xf transform applied to the shape. * @param callDestructionListener whether to call the world b2DestructionListener for each particle destroyed. * @return Number of particles destroyed. */ public int destroyParticlesInShape(Shape shape, Transform xf, boolean callDestructionListener) { assertNotLocked(); return particleSystem.destroyParticlesInShape(shape, xf, callDestructionListener); }
/** * Create a rigid body given a definition. * No reference to the definition is retained. * This function is locked during callbacks. * * @param def body definition * @return rigid body */ public Body createBody(BodyDef def) { assertNotLocked(); Body b = new Body(def, this); bodies.add(b); return b; }
/** * Destroy a rigid body. * This automatically deletes all associated shapes and joints. * This function is locked during callbacks. * * @param body body to destroy */ public void destroyBody(Body body) { assertNotLocked(); body.destroy(); bodies.removeValueByIdentity(body); // jbox2dTODO djm recycle body }
/** * Destroy a rigid body. * This automatically deletes all associated shapes and joints. * This function is locked during callbacks. * * @param body body to destroy */ public void destroyBody(Body body) { assertNotLocked(); body.destroy(); bodies.removeValueByIdentity(body); // jbox2dTODO djm recycle body }
/** * Create a rigid body given a definition. * No reference to the definition is retained. * This function is locked during callbacks. * * @param def body definition * @return rigid body */ public Body createBody(BodyDef def) { assertNotLocked(); Body b = new Body(def, this); bodies.add(b); return b; }
/** * 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; }
/** * 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; }
/** * 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 void setTransform(Vec2 position, float angle) { world.assertNotLocked(); 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 = world.getContactManager().broadPhase; for (Fixture f : fixtures) { f.synchronize(broadPhase, m_xf, m_xf); } }
/** * 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 void setTransform(Vec2 position, float angle) { world.assertNotLocked(); 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 = world.getContactManager().broadPhase; for (Fixture f : fixtures) { f.synchronize(broadPhase, m_xf, m_xf); } }