Detecting if a tri is inside an axis-aligned cube
how i do that? some approach to that is using ray-tracing collision and classifying the tri vertices about their side of cube planes, but i'm wondering if there is a faster way....
you said axis-aligned so basically you're just checking against the box's min and max values along the axial directions.
bool isTriInside(Vertex *vertices){ for (int i = 0; i < 3; ++i ) { if ( vertices.x < box.minX || vertices.x > box.maxX || vertices.y < box.minY || vertices.y > box.maxY || vertices.z < box.minZ || vertices.z > box.maxZ ) { //this vertex is outside the box return false; } } return true;}
Quote:Original post by Palidine
you said axis-aligned so basically you're just checking against the box's min and max values along the axial directions.
*** Source Snippet Removed ***
quite incorrect.
Quote:Original post by Eelco
quite incorrect.
no, it's correct. he said "axis-aligned", not Object Oriented BOunding Box, in which case you have to check against the planes. with axis aligned you just have to check the coords.
-me
Palidine, your algorithm just check if the vertices is inside the cube
a poly could overlap a cube with all it's vertices outside the cube
Eelco, is "seperating planes algorithm" the fastest way for this case?
thx for your replies
a poly could overlap a cube with all it's vertices outside the cube
Eelco, is "seperating planes algorithm" the fastest way for this case?
thx for your replies
Quote:Original post by Jungle Boy
Palidine, your algorithm just check if the vertices is in the cube
a poly could overlap an cube with all it's vertices outside the cube
Eelco, is "seperating planes algorithm" the fastest way for this case?
thx for your replies
Ah, you said inside, which i took to mean "contained by", not "intersecting".
-me
Quote:Palidine, your algorithm just check if the vertices is inside the cubeI take it from this that you don't want a 'tri in axis-aligned cube' test, but rather a 'tri intersects axis-aligned cube' test. In that case eelco's suggestion may be your best bet.
a poly could overlap a cube with all it's vertices outside the cube.
What's the test for? Is it a pre-processing step, e.g. octree construction? Or something else? Depending on the context, different solutions may be more or less appropriate. It's hard to say though without knowing more about the application.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement