/** Add the instance to the managed instances. * You should avoid using this method. This method is intended for internal purposes only. */ public static void addInstance(final btCollisionObject obj) { instances.put(getCPtr(obj), obj); }
/** Add the instance to the managed instances. * You should avoid using this method. This method is intended for internal purposes only. */ public static void addInstance(final btCollisionObject obj) { instances.put(getCPtr(obj), obj); }
public void putAll (LongMap<? extends V> map) { for (Entry<? extends V> entry : map.entries()) put(entry.key, entry.value); }
public void putAll (LongMap<? extends V> map) { for (Entry<? extends V> entry : map.entries()) put(entry.key, entry.value); }
public Face newMemoryFace(ByteBuffer buffer, int faceIndex) { long face = newMemoryFace(address, buffer, buffer.remaining(), faceIndex); if(face == 0) { if (BufferUtils.isUnsafeByteBuffer(buffer)) BufferUtils.disposeUnsafeByteBuffer(buffer); throw new GdxRuntimeException("Couldn't load font, FreeType error code: " + getLastErrorCode()); } else { fontData.put(face, buffer); return new Face(face, this); } }
public Face newMemoryFace(ByteBuffer buffer, int faceIndex) { long face = newMemoryFace(address, buffer, buffer.remaining(), faceIndex); if(face == 0) { if (BufferUtils.isUnsafeByteBuffer(buffer)) BufferUtils.disposeUnsafeByteBuffer(buffer); throw new GdxRuntimeException("Couldn't load font, FreeType error code: " + getLastErrorCode()); } else { fontData.put(face, buffer); return new Face(face, this); } }
/** Create a rigid body given a definition. No reference to the definition is retained. * Bodies created by this method are pooled internally by the World object. * They will be freed upon calling {@link World#destroyBody(Body)} * @see Pool * @warning This function is locked during callbacks. */ public Body createBody (BodyDef def) { long bodyAddr = jniCreateBody(addr, def.type.getValue(), def.position.x, def.position.y, def.angle, def.linearVelocity.x, def.linearVelocity.y, def.angularVelocity, def.linearDamping, def.angularDamping, def.allowSleep, def.awake, def.fixedRotation, def.bullet, def.active, def.gravityScale); Body body = freeBodies.obtain(); body.reset(bodyAddr); this.bodies.put(body.addr, body); return body; }
/** 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. * @param def the fixture definition. * @warning This function is locked during callbacks. */ public Fixture createFixture (FixtureDef def) { long fixtureAddr = jniCreateFixture(addr, def.shape.addr, def.friction, def.restitution, def.density, def.isSensor, def.filter.categoryBits, def.filter.maskBits, def.filter.groupIndex); Fixture fixture = this.world.freeFixtures.obtain(); fixture.reset(this, fixtureAddr); this.world.fixtures.put(fixture.addr, fixture); this.fixtures.add(fixture); return fixture; }
/** Creates a fixture from a shape and attach it to this body. This is a convenience function. Use b2FixtureDef if you need to * set parameters like friction, restitution, user data, or filtering. If the density is non-zero, this function automatically * updates the mass of the body. * @param shape the shape to be cloned. * @param density the shape density (set to zero for static bodies). * @warning This function is locked during callbacks. */ public Fixture createFixture (Shape shape, float density) { long fixtureAddr = jniCreateFixture(addr, shape.addr, density); Fixture fixture = this.world.freeFixtures.obtain(); fixture.reset(this, fixtureAddr); this.world.fixtures.put(fixture.addr, fixture); this.fixtures.add(fixture); return fixture; }
int obtainSource (boolean isMusic) { if (noDevice) return 0; for (int i = 0, n = idleSources.size; i < n; i++) { int sourceId = idleSources.get(i); int state = alGetSourcei(sourceId, AL_SOURCE_STATE); if (state != AL_PLAYING && state != AL_PAUSED) { if (isMusic) { idleSources.removeIndex(i); } else { if (sourceToSoundId.containsKey(sourceId)) { long soundId = sourceToSoundId.get(sourceId); sourceToSoundId.remove(sourceId); soundIdToSource.remove(soundId); } long soundId = nextSoundId++; sourceToSoundId.put(sourceId, soundId); soundIdToSource.put(soundId, sourceId); } alSourceStop(sourceId); alSourcei(sourceId, AL_BUFFER, 0); AL10.alSourcef(sourceId, AL10.AL_GAIN, 1); AL10.alSourcef(sourceId, AL10.AL_PITCH, 1); AL10.alSource3f(sourceId, AL10.AL_POSITION, 0, 0, 1f); return sourceId; } } return -1; }
int obtainSource (boolean isMusic) { if (noDevice) return 0; for (int i = 0, n = idleSources.size; i < n; i++) { int sourceId = idleSources.get(i); int state = alGetSourcei(sourceId, AL_SOURCE_STATE); if (state != AL_PLAYING && state != AL_PAUSED) { if (isMusic) { idleSources.removeIndex(i); } else { if (sourceToSoundId.containsKey(sourceId)) { long soundId = sourceToSoundId.get(sourceId); sourceToSoundId.remove(sourceId); soundIdToSource.remove(soundId); } long soundId = nextSoundId++; sourceToSoundId.put(sourceId, soundId); soundIdToSource.put(soundId, sourceId); } alSourceStop(sourceId); alSourcei(sourceId, AL_BUFFER, 0); AL10.alSourcef(sourceId, AL10.AL_GAIN, 1); AL10.alSourcef(sourceId, AL10.AL_PITCH, 1); AL10.alSource3f(sourceId, AL10.AL_POSITION, 0, 0, 1f); return sourceId; } } return -1; }
int obtainSource (boolean isMusic) { if (noDevice) return 0; for (int i = 0, n = idleSources.size; i < n; i++) { int sourceId = idleSources.get(i); int state = alGetSourcei(sourceId, AL_SOURCE_STATE); if (state != AL_PLAYING && state != AL_PAUSED) { if (isMusic) { idleSources.removeIndex(i); } else { if (sourceToSoundId.containsKey(sourceId)) { long soundId = sourceToSoundId.get(sourceId); sourceToSoundId.remove(sourceId); soundIdToSource.remove(soundId); } long soundId = nextSoundId++; sourceToSoundId.put(sourceId, soundId); soundIdToSource.put(soundId, sourceId); } alSourceStop(sourceId); alSourcei(sourceId, AL_BUFFER, 0); AL10.alSourcef(sourceId, AL10.AL_GAIN, 1); AL10.alSourcef(sourceId, AL10.AL_PITCH, 1); AL10.alSource3f(sourceId, AL10.AL_POSITION, 0, 0, 1f); return sourceId; } } return -1; }
int obtainSource (boolean isMusic) { if (noDevice) return 0; for (int i = 0, n = idleSources.size; i < n; i++) { int sourceId = idleSources.get(i); int state = alGetSourcei(sourceId, AL_SOURCE_STATE); if (state != AL_PLAYING && state != AL_PAUSED) { if (isMusic) { idleSources.removeIndex(i); } else { if (sourceToSoundId.containsKey(sourceId)) { long soundId = sourceToSoundId.get(sourceId); sourceToSoundId.remove(sourceId); soundIdToSource.remove(soundId); } long soundId = nextSoundId++; sourceToSoundId.put(sourceId, soundId); soundIdToSource.put(soundId, sourceId); } alSourceStop(sourceId); alSourcei(sourceId, AL_BUFFER, 0); AL10.alSourcef(sourceId, AL10.AL_GAIN, 1); AL10.alSourcef(sourceId, AL10.AL_PITCH, 1); AL10.alSource3f(sourceId, AL10.AL_POSITION, 0, 0, 1f); return sourceId; } } return -1; }
/** Create a joint to constrain bodies together. No reference to the definition is retained. This may cause the connected bodies * to cease colliding. * @warning This function is locked during callbacks. */ public Joint createJoint (JointDef def) { long jointAddr = createProperJoint(def); Joint joint = null; if (def.type == JointType.DistanceJoint) joint = new DistanceJoint(this, jointAddr); if (def.type == JointType.FrictionJoint) joint = new FrictionJoint(this, jointAddr); if (def.type == JointType.GearJoint) joint = new GearJoint(this, jointAddr, ((GearJointDef) def).joint1, ((GearJointDef) def).joint2); if (def.type == JointType.MotorJoint) joint = new MotorJoint(this, jointAddr); if (def.type == JointType.MouseJoint) joint = new MouseJoint(this, jointAddr); if (def.type == JointType.PrismaticJoint) joint = new PrismaticJoint(this, jointAddr); if (def.type == JointType.PulleyJoint) joint = new PulleyJoint(this, jointAddr); if (def.type == JointType.RevoluteJoint) joint = new RevoluteJoint(this, jointAddr); if (def.type == JointType.RopeJoint) joint = new RopeJoint(this, jointAddr); if (def.type == JointType.WeldJoint) joint = new WeldJoint(this, jointAddr); if (def.type == JointType.WheelJoint) joint = new WheelJoint(this, jointAddr); if (joint != null) joints.put(joint.addr, joint); JointEdge jointEdgeA = new JointEdge(def.bodyB, joint); JointEdge jointEdgeB = new JointEdge(def.bodyA, joint); joint.jointEdgeA = jointEdgeA; joint.jointEdgeB = jointEdgeB; def.bodyA.joints.add(jointEdgeA); def.bodyB.joints.add(jointEdgeB); return joint; }
public void put(Long key, T value) { int idx = (int) (key % N); maps[idx].put(key, value); empty = false; }
/** Add the instance to the managed instances. * You should avoid using this method. This method is intended for internal purposes only. */ public static void addInstance(final btCollisionObject obj) { instances.put(getCPtr(obj), obj); }
public void putAll (LongMap<? extends V> map) { for (Entry<? extends V> entry : map.entries()) put(entry.key, entry.value); }
public void addEffect (String name, PostProcessorEffect effect) { if (hasPostProcessor) { postProcessor.addEffect(effect); effects.put(Hash.APHash(name), effect); } }
public static ScreenTransition getTransition (TransitionType transitionType) { ScreenTransition transition = transitions.get(transitionType.hash); if (transition == null) { transition = createTransition(transitionType); transitions.put(transitionType.hash, transition); } else { transition.reset(); } return transition; }
public Face newMemoryFace(ByteBuffer buffer, int faceIndex) { long face = newMemoryFace(address, buffer, buffer.remaining(), faceIndex); if(face == 0) { if (BufferUtils.isUnsafeByteBuffer(buffer)) BufferUtils.disposeUnsafeByteBuffer(buffer); throw new GdxRuntimeException("Couldn't load font, FreeType error code: " + getLastErrorCode()); } else { fontData.put(face, buffer); return new Face(face, this); } }