Newb Question:
Below is my code that loads a mesh into an optix::context for rendering. How can I remove this geom_instance and all its children (materials/triangles) from my context?
I couldn’t find an ctx->destroyGeometryInstance or any method on GeometryInstance to do the trick.
My Code:
optix::GeometryTriangles geom_tri = ctx->createGeometryTriangles();
geom_tri->setPrimitiveCount(num_triangles);
geom_tri->setTriangleIndices(buffers.tri_indices, RT_FORMAT_UNSIGNED_INT3);
geom_tri->setVertices(num_vertices, buffers.positions, buffers.positions->getFormat());
geom_tri->setBuildFlags(RTgeometrybuildflags(0));
geom_tri->setAttributeProgram(createAttributeProgram(ptx));
size_t num_matls = optix_materials.size();
geom_tri->setMaterialCount((unsigned int)num_matls);
geom_tri->setMaterialIndices(buffers.mat_indices, 0, sizeof(unsigned), RT_FORMAT_UNSIGNED_INT);
geom_instance = ctx->createGeometryInstance();
geom_instance->setGeometryTriangles(geom_tri);
// Set the materials
geom_instance->setMaterialCount((unsigned int)num_matls);
for (size_t idx = 0; idx < num_matls; ++idx)
{
geom_instance->setMaterial((unsigned int)idx, optix_materials[idx]);
}