void BatchedMesh::regenerateVboMesh(MaterialRef material) { // cout << "BatchedMesh::regenerateVboMesh(): Regenerating VboMesh for // material:" // << material << endl; TriMesh combinedMesh; vector<Vec3f> vertices; vector<ColorAf> colors; vector<Vec2f> texCoords; vector<uint32_t> indices; uint32_t vertCount = 0; _materialBounds[material] = AxisAlignedBox3f(); for (BatchInfoRef batchInfo : _meshes[material]) { TriMesh *internalMesh = batchInfo->mesh->getInternalMesh( batchInfo->transform->getTransformMatrixLocal()); vertices = internalMesh->getVertices(); combinedMesh.appendVertices(vertices.data(), vertices.size()); colors = internalMesh->getColorsRGBA(); combinedMesh.appendColorsRgba(colors.data(), colors.size()); texCoords = internalMesh->getTexCoords(); combinedMesh.appendTexCoords(texCoords.data(), texCoords.size()); indices = internalMesh->getIndices(); std::transform(std::begin(indices), std::end(indices), std::begin(indices), [vertCount](uint32_t x) { return x + vertCount; }); combinedMesh.appendIndices(indices.data(), indices.size()); vertCount += vertices.size(); _materialBounds[material].include(internalMesh->calcBoundingBox()); } _vboMeshes[material] = gl::VboMesh::create(combinedMesh); // Recalculate master bounds _bounds = AxisAlignedBox3f(); for (auto &kvp : _materialBounds) { _bounds.include(kvp.second); } }