Archived

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

TheJakub

split triangle

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites