Mesh Intersection 3D

  3d, c++, computational-geometry, graphics

I’m trying to do mesh intersection using brute force approach, checking each triangle from mesh A against mesh B

Right now I’m getting the result image, but with the blue area not there and not account for the intersection.

for (size_t i = 0; i < tri_mesh_b.vertices.count; i += 3)
    {
        musa::Triangle triB{ tri_mesh_b.vertices[i], tri_mesh_b.vertices[i + 1], tri_mesh_b.vertices[i + 2] };
        
                for (size_t a = 0; a < tri_mesh_a.vertices.count; a += 3)
                {
                    musa::Triangle triA{ tri_mesh_a.vertices[a], tri_mesh_a.vertices[a + 1], tri_mesh_a.vertices[a + 2] };

                    if (triangle_triangle_intersection_check(triB, triA))
                    {
                        mn::buf_push(self->modelIntersection.points, triA.p0);

                        mn::buf_push(self->modelIntersection.points, triA.p1);

                        mn::buf_push(self->modelIntersection.points, triA.p2);


                        musa::Intersection_Segments segments_ = musa::triangle_triangle_intersection(triB, triA);



                        mn::buf_push(self->modelIntersection.points, segments_.segments[0].start);

                        mn::buf_push(self->modelIntersection.points, segments_.segments[0].end);


                        musa::Intersection_Points pts = musa::segment_triangle_intersection(segments_.segments[0], triA);
                        mn::buf_push(self->modelIntersection.points, pts.points[0]);

                        
                    }

        }
}

enter image description here

Source: Windows Questions C++

LEAVE A COMMENT