In addition, the laser impact effects have also been updated, with the impact explosion orientation now being determined by the normal of the impacted surface. It also kicks up some debris particle effects, although these are currently the same regardless of the surface type being hit, and thus look odd for some of the alien flora.
Flair intersectionThere were two parts to getting this to work, both of which drew heavily on my existing codebase for creating and merging vector brushes (which has held up surprisingly well, given that there are a few bits that could really do with improving).
The first part is, for a given 2D (or basic 3D) mesh, generating a 2D vector brush of the outline. This abridged version is as follows:
- Identify all edges within the mesh. This is something that needs calculating, as by default meshes are stored in terms of vertices/triangles.
- Identify the set of triangles that use each edge (the set must at least of size 1, else where the hell did the edge come from?)
- Determine whether each edge is potentially part of the outline. If an edge has only one triangle associated with it, then it's always an outline edge. For multiple triangles, it is an outline edge if the third point of each triangle (i.e. that not part of the edge) all lie on the same side of the line.
- Throw out all the non-outline-edge edges.
- Starting on any outline edge, following connected edges around until you come back to the original edge in a loop. In normal situations (apart from some awkward 3D configurations) there will never be any branching to worry about that. Add that as a vector path.
- Repeat 5. for any currently unused outline edges until all are accounted for.
- Merge the set of vector paths together to form the final outline (which is a whole different bunch of algorithms).