So I’ve been working on procedural planets and I’ve implemented and verified a working system in OpenGL I’m now building a renderer using optix and I don’t understand how Transform and Group works exactly:

for each of my GeometryGroups I have a Transform and I update them with:

```
auto pos = glm::vec3(instance.e->calculate_position());
auto rot = glm::mat3(instance.e->calculate_rotation_matrix());
glm::mat4 mat = glm::mat4(rot);
mat[3] = glm::vec4(pos, 1.0);
optix::Matrix4x4 matrix(glm::value_ptr(mat));
instance.transform->setChild(geometry_groups[instance.geometry_id]);
instance.transform->setMatrix(false, matrix.getData(), matrix.inverse().getData());
```

I also use the bbox and intesection programs from the tutorials, they are atteched to the geometry inside the geometry group:

```
#include <optix.h>
#include <optixu/optixu_aabb_namespace.h>
#include <optixu/optixu_math_namespace.h>
rtBuffer<float3> vertexBuffer;
rtBuffer<float2> uvBuffer;
rtBuffer<uint3> indicesBuffer;
RT_PROGRAM void boundingbox_triangle_indexed(int primitiveIndex, float result[6])
{
const uint3 indices = indicesBuffer[primitiveIndex];
const float3 v0 = vertexBuffer[indices.x];
const float3 v1 = vertexBuffer[indices.y];
const float3 v2 = vertexBuffer[indices.z];
const float area = optix::length(optix::cross(v1 - v0, v2 - v0));
optix::Aabb *aabb = (optix::Aabb *) result;
if (0.0f < area && !isinf(area))
{
aabb->m_min = fminf(fminf(v0, v1), v2);
aabb->m_max = fmaxf(fmaxf(v0, v1), v2);
}
else
{
aabb->invalidate();
}
}
```

```
#include <optix.h>
#include <optixu/optixu_math_namespace.h>
rtBuffer<float3> vertexBuffer;
rtBuffer<float2> uvBuffer;
rtBuffer<uint3> indicesBuffer;
rtDeclareVariable(optix::Ray, theRay, rtCurrentRay, );
rtDeclareVariable(optix::float3, varGeoNormal, attribute GEO_NORMAL, );
rtDeclareVariable(optix::float2, varTexCoord, attribute TEXCOORD, );
RT_PROGRAM void intersection_triangle_indexed(int primitiveIndex)
{
const uint3 indices = indicesBuffer[primitiveIndex];
const float3 v0 = vertexBuffer[indices.x];
const float3 v1 = vertexBuffer[indices.y];
const float3 v2 = vertexBuffer[indices.z];
const float2 uv0 = uvBuffer[indices.x];
const float2 uv1 = uvBuffer[indices.y];
const float2 uv2 = uvBuffer[indices.z];
float3 n;
float t;
float beta;
float gamma;
if (intersect_triangle(theRay, v0, v1, v2, n, t, beta, gamma))
{
if (rtPotentialIntersection(t))
{
const float alpha = 1.0f - beta - gamma;
varGeoNormal = n;
varTexCoord = uv0 * alpha + uv1 * beta + uv2 * gamma;
rtReportIntersection(0);
}
}
}
```

When I move an object I get weird fragments that look like bounding boxes. And also I don’t know how I can remove an object entirely from the scene. Setting the child count on the root group and adding the transforms as I iterate through objects seems extremely slow. Any ideas ?