Selection and deletion of faces in mesh.

I need to deletes the faces of a mesh which fall inside a selected region.

Selected region is rectangular and the selection is done using the mouse, then delete all triangles under this rectangle.

How to go about this? Some algorithmic tips.

Highly suggest you get this book:
http://realtimecollisiondetection.net/

You should search for ‘separating axis theorem’. Probably a reasonable approach box/triangle intersection.

A cruder approach would be to form the axis aligned bounding boxes of your triangles and test them against the rectangle. Heck, you might even do this as a first test to speed things up.
Depending on how often or at what speed you want to do this you might even throw all your triangles into a kd tree!

Get the book!

Perhaps, can you use something like this ?

  1. use a different color value for to draw each triangle in the framebuffer
    (but don’t display it in the front buffer)

  2. make the glReadPixels call

  3. list alls colors into your rectangular selection
    (the precedent glReadPixel call can of course only read your rectangular mouse selection, because glReadPixel calls seems really slow)

  4. delete triangles that are identified by colors that you have listed in the previous step

Ok, the color selection can limit the number of triangles, but you can make multiples passes if you want more to handle more triangles …

Note that you can too use a stencil value instead a color value