Little progress is still progress!

I wanted to share a screenshot from Unity to show something concrete. I created a simple low-poly humanoid model in Blender. Then I imported it into Unity and cut in half with my mesh splitting algorithm.

pentti

The splitter still leaves holes in meshes (triangles missing) and doesn’t always find an edge loop to triangulate 🙁 So some work is still needed! But I hope the screenshot gives you an idea of the gameplay I am aiming for in this game – knights battling and cutting of limbs!

Joining adjacent triangles

Previously I wrote about useless triangles that are created when a mesh is split in two. By useless I mean they are adjacent to each other and on the same plane (plus have the same normal vectors). So why not join them? In the following I present two simple rules that can be used to determine if three triangles (created by splitting a mesh by plane) can be presented with two triangles.

From polygon to triangles

We need to reduce the number of triangles in a mesh. A quad (polygon with four vertices) can be represented with two triangles. So if we find quads that consist of more than two triangles we optimize!

BLOGO
A quad can be presented with two triangles, a polygon with five vertices needs more.

When looking for optimization candidates we only have to check the triangles that have one or two vertices on the splitting plane. We don’t want to accidentally ”optimize” other parts of the model that should be unaffected by the splitting 🙂 Also, if a triangle has one or all vertices on the splitting plane it is not interesting as it is not split.

A quad with three triangles, gross!!

If we take a triangle that has one or two vertices on a plane we have one of the following ”neighborhood situations”:

optimointi - viereisten kolmioiden yhdistäminen
The light green triangle has one or two vertices on the splitting plane (yellow line). All the triangles are on the same plane.

Below the triangles is the number of vertices in a polygon created by the intersecting triangle (light green) and its neighbors. If n = 4 we have a quad and we can represent that with two triangles. If n = 3 the situation is even better – we can represent all three triangles with a single triangle. Cool! If n > 4 we cannot join the triangles since impossibru!

Thats it! In one of the next articles I will show what kind of impact these two simple optimizations can actually have when implemented (in Unity).