-
Notifications
You must be signed in to change notification settings - Fork 0
Track Mesh Generation
Mesh assets are saved and stored in the same directory of the trackMesh’s scene, in ${Scene Directory}/${Name of Scene}/${Name Of Spline}/Track Mesh.${Renderers Hash Code}.asset
When a mesh is re-baked, the old assets are deleted and replaced with new ones.
An endPoint value is walked along the track at a set increment, when a certain length around the spline has been reached, a mesh segment is added to the buffer. This mesh segment is deformed along its z position, interpolating the position and orientation of the two end points of the track.
After every n segment are added, the appended mesh data is split off and placed into a seperate object, allowing for proper frustum culling.
As meshes are split up into segments, they are places in mesh renderer objects, which are children of the TrackMesh component.
The finalized track meshes used to be stored in the scene, and were not disposed properly. This lead to a leak that was difficult to find and slow to happen, resulting in scene files being several orders of magnitude bigger than they needed to be. This was eventually solves by storing meshes as assets outside of the scene in separate files, allowing for proper monitoring of them.