private MeshBuilder getBuilder (final VertexAttributes attributes) { for (final MeshBuilder mb : builders) if (mb.getAttributes().equals(attributes) && mb.lastIndex() < Short.MAX_VALUE / 2) return mb; final MeshBuilder result = new MeshBuilder(); result.begin(attributes); builders.add(result); return result; }
private MeshBuilder getBuilder (final VertexAttributes attributes) { for (final MeshBuilder mb : builders) if (mb.getAttributes().equals(attributes) && mb.lastIndex() < Short.MAX_VALUE / 2) return mb; final MeshBuilder result = new MeshBuilder(); result.begin(attributes); builders.add(result); return result; }
@Override public Mesh obtain (VertexAttributes vertexAttributes, int vertexCount, int indexCount) { for (int i = 0, n = freeMeshes.size; i < n; ++i) { final Mesh mesh = freeMeshes.get(i); if (mesh.getVertexAttributes().equals(vertexAttributes) && mesh.getMaxVertices() >= vertexCount && mesh.getMaxIndices() >= indexCount) { freeMeshes.removeIndex(i); usedMeshes.add(mesh); return mesh; } } vertexCount = 1 + (int)Short.MAX_VALUE; indexCount = Math.max(1 + (int)Short.MAX_VALUE, 1 << (32 - Integer.numberOfLeadingZeros(indexCount - 1))); Mesh result = new Mesh(false, vertexCount, indexCount, vertexAttributes); usedMeshes.add(result); return result; }
@Override public Mesh obtain (VertexAttributes vertexAttributes, int vertexCount, int indexCount) { for (int i = 0, n = freeMeshes.size; i < n; ++i) { final Mesh mesh = freeMeshes.get(i); if (mesh.getVertexAttributes().equals(vertexAttributes) && mesh.getMaxVertices() >= vertexCount && mesh.getMaxIndices() >= indexCount) { freeMeshes.removeIndex(i); usedMeshes.add(mesh); return mesh; } } vertexCount = 1 + (int)Short.MAX_VALUE; indexCount = Math.max(1 + (int)Short.MAX_VALUE, 1 << (32 - Integer.numberOfLeadingZeros(indexCount - 1))); Mesh result = new Mesh(false, vertexCount, indexCount, vertexAttributes); usedMeshes.add(result); return result; }
@Override public Mesh obtain (VertexAttributes vertexAttributes, int vertexCount, int indexCount) { for (int i = 0, n = freeMeshes.size; i < n; ++i) { final Mesh mesh = freeMeshes.get(i); if (mesh.getVertexAttributes().equals(vertexAttributes) && mesh.getMaxVertices() == vertexCount && mesh.getMaxIndices() == indexCount) { freeMeshes.removeIndex(i); usedMeshes.add(mesh); return mesh; } } Mesh result = new Mesh(true, vertexCount, indexCount, vertexAttributes); usedMeshes.add(result); return result; }
@Override public Mesh obtain (VertexAttributes vertexAttributes, int vertexCount, int indexCount) { for (int i = 0, n = freeMeshes.size; i < n; ++i) { final Mesh mesh = freeMeshes.get(i); if (mesh.getVertexAttributes().equals(vertexAttributes) && mesh.getMaxVertices() == vertexCount && mesh.getMaxIndices() == indexCount) { freeMeshes.removeIndex(i); usedMeshes.add(mesh); return mesh; } } Mesh result = new Mesh(true, vertexCount, indexCount, vertexAttributes); usedMeshes.add(result); return result; }
@Override public void addMesh (Mesh mesh, int indexOffset, int numIndices) { if (!attributes.equals(mesh.getVertexAttributes())) throw new GdxRuntimeException("Vertex attributes do not match"); if (numIndices <= 0) return; // silently ignore an empty mesh part // FIXME don't triple copy, instead move the copy to jni int numFloats = mesh.getNumVertices() * stride; tmpVertices.clear(); tmpVertices.ensureCapacity(numFloats); tmpVertices.size = numFloats; mesh.getVertices(tmpVertices.items); tmpIndices.clear(); tmpIndices.ensureCapacity(numIndices); tmpIndices.size = numIndices; mesh.getIndices(indexOffset, numIndices, tmpIndices.items, 0); addMesh(tmpVertices.items, tmpIndices.items, 0, numIndices); }
@Override public void addMesh (Mesh mesh, int indexOffset, int numIndices) { if (!attributes.equals(mesh.getVertexAttributes())) throw new GdxRuntimeException("Vertex attributes do not match"); if (numIndices <= 0) return; // silently ignore an empty mesh part // FIXME don't triple copy, instead move the copy to jni int numFloats = mesh.getNumVertices() * stride; tmpVertices.clear(); tmpVertices.ensureCapacity(numFloats); tmpVertices.size = numFloats; mesh.getVertices(tmpVertices.items); tmpIndices.clear(); tmpIndices.ensureCapacity(numIndices); tmpIndices.size = numIndices; mesh.getIndices(indexOffset, numIndices, tmpIndices.items, 0); addMesh(tmpVertices.items, tmpIndices.items, 0, numIndices); }
/** End building the mesh and returns the mesh * @param mesh The mesh to receive the built vertices and indices, must have the same attributes and must be big enough to hold * the data, any existing data will be overwritten. */ public Mesh end (Mesh mesh) { endpart(); if (attributes == null) throw new GdxRuntimeException("Call begin() first"); if (!attributes.equals(mesh.getVertexAttributes())) throw new GdxRuntimeException("Mesh attributes don't match"); if ((mesh.getMaxVertices() * stride) < vertices.size) throw new GdxRuntimeException("Mesh can't hold enough vertices: " + mesh.getMaxVertices() + " * " + stride + " < " + vertices.size); if (mesh.getMaxIndices() < indices.size) throw new GdxRuntimeException("Mesh can't hold enough indices: " + mesh.getMaxIndices() + " < " + indices.size); mesh.setVertices(vertices.items, 0, vertices.size); mesh.setIndices(indices.items, 0, indices.size); for (MeshPart p : parts) p.mesh = mesh; parts.clear(); attributes = null; vertices.clear(); indices.clear(); return mesh; }
/** End building the mesh and returns the mesh * @param mesh The mesh to receive the built vertices and indices, must have the same attributes and must be big enough to hold * the data, any existing data will be overwritten. */ public Mesh end (Mesh mesh) { endpart(); if (attributes == null) throw new GdxRuntimeException("Call begin() first"); if (!attributes.equals(mesh.getVertexAttributes())) throw new GdxRuntimeException("Mesh attributes don't match"); if ((mesh.getMaxVertices() * stride) < vertices.size) throw new GdxRuntimeException("Mesh can't hold enough vertices: " + mesh.getMaxVertices() + " * " + stride + " < " + vertices.size); if (mesh.getMaxIndices() < indices.size) throw new GdxRuntimeException("Mesh can't hold enough indices: " + mesh.getMaxIndices() + " < " + indices.size); mesh.setVertices(vertices.items, 0, vertices.size); mesh.setIndices(indices.items, 0, indices.size); for (MeshPart p : parts) p.mesh = mesh; parts.clear(); attributes = null; vertices.clear(); indices.clear(); return mesh; }
final int pt = renderable.meshPart.primitiveType; final boolean sameMesh = va.equals(vertexAttributes)
final int pt = renderable.meshPart.primitiveType; final boolean sameMesh = va.equals(vertexAttributes)
private MeshBuilder getBuilder (final VertexAttributes attributes) { for (final MeshBuilder mb : builders) if (mb.getAttributes().equals(attributes) && mb.lastIndex() < Short.MAX_VALUE / 2) return mb; final MeshBuilder result = new MeshBuilder(); result.begin(attributes); builders.add(result); return result; }
private MeshBuilder2 getBuilder(final VertexAttributes attributes) { for (final MeshBuilder2 mb : builders) if (mb.getAttributes().equals(attributes) && mb.lastIndex() < Short.MAX_VALUE / 2) return mb; final MeshBuilder2 result = new MeshBuilder2(); result.begin(attributes); builders.add(result); return result; }
@Override public Mesh obtain (VertexAttributes vertexAttributes, int vertexCount, int indexCount) { for (int i = 0, n = freeMeshes.size; i < n; ++i) { final Mesh mesh = freeMeshes.get(i); if (mesh.getVertexAttributes().equals(vertexAttributes) && mesh.getMaxVertices() >= vertexCount && mesh.getMaxIndices() >= indexCount) { freeMeshes.removeIndex(i); usedMeshes.add(mesh); return mesh; } } vertexCount = 1 + (int)Short.MAX_VALUE; indexCount = Math.max(1 + (int)Short.MAX_VALUE, 1 << (32 - Integer.numberOfLeadingZeros(indexCount - 1))); Mesh result = new Mesh(false, vertexCount, indexCount, vertexAttributes); usedMeshes.add(result); return result; }
@Override public Mesh obtain (VertexAttributes vertexAttributes, int vertexCount, int indexCount) { for (int i = 0, n = freeMeshes.size; i < n; ++i) { final Mesh mesh = freeMeshes.get(i); if (mesh.getVertexAttributes().equals(vertexAttributes) && mesh.getMaxVertices() == vertexCount && mesh.getMaxIndices() == indexCount) { freeMeshes.removeIndex(i); usedMeshes.add(mesh); return mesh; } } Mesh result = new Mesh(true, vertexCount, indexCount, vertexAttributes); usedMeshes.add(result); return result; }
@Override public void addMesh (Mesh mesh, int indexOffset, int numIndices) { if (!attributes.equals(mesh.getVertexAttributes())) throw new GdxRuntimeException("Vertex attributes do not match"); if (numIndices <= 0) return; // silently ignore an empty mesh part // FIXME don't triple copy, instead move the copy to jni int numFloats = mesh.getNumVertices() * stride; tmpVertices.clear(); tmpVertices.ensureCapacity(numFloats); tmpVertices.size = numFloats; mesh.getVertices(tmpVertices.items); tmpIndices.clear(); tmpIndices.ensureCapacity(numIndices); tmpIndices.size = numIndices; mesh.getIndices(indexOffset, numIndices, tmpIndices.items, 0); addMesh(tmpVertices.items, tmpIndices.items, 0, numIndices); }
/** End building the mesh and returns the mesh * @param mesh The mesh to receive the built vertices and indices, must have the same attributes and must be big enough to hold * the data, any existing data will be overwritten. */ public Mesh end (Mesh mesh) { endpart(); if (attributes == null) throw new GdxRuntimeException("Call begin() first"); if (!attributes.equals(mesh.getVertexAttributes())) throw new GdxRuntimeException("Mesh attributes don't match"); if ((mesh.getMaxVertices() * stride) < vertices.size) throw new GdxRuntimeException("Mesh can't hold enough vertices: " + mesh.getMaxVertices() + " * " + stride + " < " + vertices.size); if (mesh.getMaxIndices() < indices.size) throw new GdxRuntimeException("Mesh can't hold enough indices: " + mesh.getMaxIndices() + " < " + indices.size); mesh.setVertices(vertices.items, 0, vertices.size); mesh.setIndices(indices.items, 0, indices.size); for (MeshPart p : parts) p.mesh = mesh; parts.clear(); attributes = null; vertices.clear(); indices.clear(); return mesh; }
final int pt = renderable.meshPart.primitiveType; final boolean sameMesh = va.equals(vertexAttributes)