Stage 5:
- Optimise gravity searching
- Optimise terrain searching
- Gravity smoothing
Gravity searching and terrain searching were done similarly. Firstly, gravity was no longer a single polygon, but now a complex mesh. I created a simple process to create the mesh in Maya using an EP curve, then duplicating the curve and moving the duplicate a small amount (0.1 in the + y axis), then lofting the 2 curves to create a NURBS surface, then tesselating the surface to create a polygon mesh. This was all because Maya and FBX do not support vertex lines.
Gravity searching and terrain searching optimisation required a specialised Model processor. I coded the processor to search through all the gravity vertices and add them to the AllGravity list, unless there is a vertex exactly 0.1 units above it. This removed all extra vertices created by the gravity creation process. The next stage was to go through each gravity point and find all the points that are connected to it. The process that the game engine used to find gravity was now different. Initially it searches through all gravity to find the nearest one, then only search the ones that are connected to the current gravity point. This reduced the time the CPU spends searching for gravity by a factor proportional to the number of gravity points (more than 1,000 times!).
The terrain searching was very similar. Add each terrain triangle to the list of AllTerrain, then for each triangle, search through all other triangles and add them to the surrounding triangle list if they share a vertex. The game engine then initially searches all terrain to find the initial terrain triangle the character is on, then only search the surrounding terrain. This reduced the time the CPU spends searching for terrain by a factor proportional to the number on terrain triangles (more than 10,000 times!!!). This also meant that build time took about 200 times longer.
Gravity smoothing was done by modifying the point which is used for gravity. The engine knows which gravity point is the closest, then searches for the next closest gravity point to the character and finds the intermediate point that is closest to the character. This smooths walking greatly and also reduces the number of gravity points needed in the level and implements true gravity spline functionality. A jitter still occurs when gravity shifts to a point that wasn't connected to the previous gravity point. This occurs around spirally surfaces and can be fixed by allowing the engine to search past the connecting gravity points at a cost of CPU time.
No comments:
Post a Comment