• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# Raytracing problem with Octree

## Recommended Posts

Hi, i coded an octree, and it works for rendering. But for my main concern, to speed up shadow calculations for my radiosity processor, it fails... the problem is not the ray / polygon intersection (it is unchanged), shadow calculations worked before using the octree. maybe it is useful to post my code for the octree raytracer: To explain: The code returns the leaf node with the smallest box that intersects the ray. The leaf is then returned and its primitives are processed by the caller.
ZNode* raytrace_node(ZNode *node, const vec3 &rO, const vec3 &delta)
{
if (!node->ray_intersect(rO, delta))
return 0;

if (node->_isLeaf)
{
return node;
}

for (int i = 0; i < 8; i++)
{
ZNode *thisNode = 0;

if (node->_octants[i])
{
thisNode = raytrace_node(node->_octants[i], rO, delta);

if (thisNode)
return thisNode;
}
}

return 0;
}

greets
Gammastrahler