split triangle

Started by
2 comments, last by TheJakub 20 years, 9 months ago
Can anyone give a good explanation of how to go about splitting triangles when building an octree? I just cant seem to find any good documentation on the subject.
Advertisement
I''ve found in the past that splitting your triangles can cause unwanted overhead by increasing your polycount by a large amount. If you find this happening to you (you may not - you may have large triangles for your world) then inserting the triangles into all nodes they intersect can work out faster, if you''re using an index buffer system.
here is some pseudo code,
if you have two triangles, you may get one four sided-poly in some cases....

std::vector frontPoly;
std::vector backPoly;

for (each vertex in tri)

if (edge intersects plane)
add intersection point to front and back poly
interpolate texture coords
end if

classify vertex
if (on front side of plane)
frontPoly.push_back(vertex);
else
backPoly.push_back(vertex);

end for

Thanks. I was also messing around with the notion of just inserting the triangles into all nodes without splitting them. I just wasn''t sure if its good practice. But when I think about it it wouldn''t really matter because its still rendering what you need it to render, right? Is there a downside to not splitting the triangles in an octree or bsp?

This topic is closed to new replies.

Advertisement