void clear() { buffer.clear(); }
/** @param frustum Set the frustum plane buffers to this frustum */ private void setFrustumPlanes (Frustum frustum) { // All frustum planes except 'near' (index 0) should be sent to Bullet. frustumNormals.clear(); frustumOffsets.clear(); for (int i = 1; i < 6; i++) { Plane plane = frustum.planes[i]; // Since the plane normals map to an array of btVector3, all four vector components (x, y, z, w) // required by the C++ struct must be provided. The plane offset from origin (d) must also be set. frustumNormals.put(plane.normal.x); frustumNormals.put(plane.normal.y); frustumNormals.put(plane.normal.z); frustumNormals.put(0); frustumOffsets.put(plane.d); } } }
/** Clears the depth buffer by setting the depth to -1. */ public void clear () { buffer.clear(); while (buffer.position() < buffer.capacity()) buffer.put(-1); }
private FloatBuffer toFloatBuffer (float v[], int offset, int count) { ensureBufferCapacity(count << 2); floatBuffer.clear(); floatBuffer.limit(count); floatBuffer.put(v, offset, count); floatBuffer.position(0); return floatBuffer; }
private FloatBuffer toFloatBuffer (float v[], int offset, int count) { ensureBufferCapacity(count << 2); floatBuffer.clear(); floatBuffer.limit(count); floatBuffer.put(v, offset, count); floatBuffer.position(0); return floatBuffer; }
private FloatBuffer toFloatBuffer (float v[], int offset, int count) { ensureBufferCapacity(count << 2); floatBuffer.clear(); com.badlogic.gdx.utils.BufferUtils.copy(v, floatBuffer, count, offset); return floatBuffer; }
private FloatBuffer toFloatBuffer (float v[], int offset, int count) { ensureBufferCapacity(count << 2); floatBuffer.clear(); com.badlogic.gdx.utils.BufferUtils.copy(v, floatBuffer, count, offset); return floatBuffer; }
/** * Create a new FloatBuffer of the specified size. * * @param size * required number of floats to store. * @return the new FloatBuffer */ public static FloatBuffer createFloatBuffer(int size) { FloatBuffer buf = allocator.allocate(4 * size).order(ByteOrder.nativeOrder()).asFloatBuffer(); buf.clear(); onBufferAllocated(buf); return buf; }
@Override public void setVertices (float[] vertices, int offset, int count) { isDirty = true; if (isDirect) { BufferUtils.copy(vertices, byteBuffer, count, offset); buffer.position(0); buffer.limit(count); } else { buffer.clear(); buffer.put(vertices, offset, count); buffer.flip(); byteBuffer.position(0); byteBuffer.limit(buffer.limit() << 2); } bufferChanged(); }
@Override public void setVertices (float[] vertices, int offset, int count) { isDirty = true; if (isDirect) { BufferUtils.copy(vertices, byteBuffer, count, offset); buffer.position(0); buffer.limit(count); } else { buffer.clear(); buffer.put(vertices, offset, count); buffer.flip(); byteBuffer.position(0); byteBuffer.limit(buffer.limit() << 2); } bufferChanged(); }
/** * Generates a Vector3f array from the given FloatBuffer. * * @param buff * the FloatBuffer to read from * @return a newly generated array of Vector3f objects */ public static Vector3f[] getVector3Array(FloatBuffer buff) { buff.clear(); Vector3f[] verts = new Vector3f[buff.limit() / 3]; for (int x = 0; x < verts.length; x++) { Vector3f v = new Vector3f(buff.get(), buff.get(), buff.get()); verts[x] = v; } return verts; }
/** Invalidates all cache IDs and resets the SpriteCache so new caches can be added. */ public void clear () { caches.clear(); mesh.getVerticesBuffer().clear().flip(); }
/** Invalidates all cache IDs and resets the SpriteCache so new caches can be added. */ public void clear () { caches.clear(); mesh.getVerticesBuffer().clear().flip(); }
/** * Generates a Vector2f array from the given FloatBuffer. * * @param buff * the FloatBuffer to read from * @return a newly generated array of Vector2f objects */ public static Vector2f[] getVector2Array(FloatBuffer buff) { buff.clear(); Vector2f[] verts = new Vector2f[buff.limit() / 2]; for (int x = 0; x < verts.length; x++) { Vector2f v = new Vector2f(buff.get(), buff.get()); verts[x] = v; } return verts; }
/** * Generate a new FloatBuffer using the given array of float primitives. * * @param data * array of float primitives to place into a new FloatBuffer */ public static FloatBuffer createFloatBuffer(float... data) { if (data == null) { return null; } FloatBuffer buff = createFloatBuffer(data.length); buff.clear(); buff.put(data); buff.flip(); return buff; }
public static Mesh getDebugMesh(CollisionShape shape) { Mesh mesh = null; if (shape.getCShape() instanceof ConvexShape) { mesh = new Mesh(); mesh.setBuffer(Type.Position, 3, getVertices((ConvexShape) shape.getCShape())); mesh.getFloatBuffer(Type.Position).clear(); } else if (shape.getCShape() instanceof ConcaveShape) { mesh = new Mesh(); mesh.setBuffer(Type.Position, 3, getVertices((ConcaveShape) shape.getCShape())); mesh.getFloatBuffer(Type.Position).clear(); } return mesh; }
/** * Create a mesh for visualizing the specified shape. * * @param shape (not null, unaffected) * @return a new mesh (not null) */ public static Mesh getDebugMesh(CollisionShape shape) { Mesh mesh = new Mesh(); DebugMeshCallback callback = new DebugMeshCallback(); long id = shape.getObjectId(); getVertices(id, callback); mesh.setBuffer(Type.Position, 3, callback.getVertices()); mesh.getFloatBuffer(Type.Position).clear(); return mesh; }