Terrain destruction vol.2

After long break with posting ( caused by achieving bachelor’s degree – successful btw^^ ) I managed to create various holes in terrain.  Shape of hole can be circle, rectangle, convex polygon, concave also, generally every shape that can be represented by list of vertices. Here you can see circular holes (wire frame view enabled)

Previous Image
Next Image

You can see on pics that in some places there are unnecessary triangles. The algorithm is not optimized, it is based only on dividing into smaller triangles:

1.    Find triangles that collide hole shape in certain place ( bullet AABB test)
2.    For each found triangle:

–    A = triangle vertices, B = hole vertices
–    Make polygon difference (complement), output polygon C =A B
–    triangulate C and add to world triangles that we get
–    delete original triangle A

I still need something to merge multiple triangles into one bigger

Leave a Reply

Your email address will not be published. Required fields are marked *