branchrust_reboot/main/optimize_train_track_meshescancel
17 Commits over 31 Days - 0.02cph!
Fix IsAnyLODVisible() not being inverted in OnMeshJobFinished() causing rail meshes to be always deleted instead of only deleted if the LOD was hidden before the mesh generation job finished
Fix filter to only generate lowest LOD only checking if filter is null, not if filter is empty
- fixes rivers + roads + train track meshes not generating at all
merge from main -> optimize_train_track_meshes
Fix "Double invocation of a deferred action"
Fix null check using .Equals() instead of == null
Fix CLIENT compile errors
merge from main -> optimize_train_track_meshes
merge from main -> optimize_train_track_meshes
Rename PathMeshLOD -> RailMeshLOD, less generic but much clearer what it does
Fix the AddToHeightMap at the end of GenerateRailMeshes not having a collider available due to the client deferring the generation of meshes & therefore mesh colliders
- still generate meshes for colliders right away on servers
- generate the lowest LOD in the rare case that a client is generating a map (and not loading a cached map)
- keep PathMeshLOD components disabled until procgen finishes to ensure they don't update LODs mid-map generation and start deleting the colliders
Rename CreatePathMeshJob -> PathMeshTemplate to make it clearer
Defer the integration of the generated mesh by sending it to the load balance
- it would be quick but Unity doesn't letting us assign the UV distribution float manually from C# so we have to call mesh.RecalculateUVDistributionMetrics() on main thread which takes 0.8ms
Add `printrails` command to print all the railroad meshes currently active
Add profiling markers
Destroy mesh instead of assigning to MeshLOD if the railroad LOD is hidden before the mesh generation request finishes
merge from main -> optimize_train_track_meshes
More progress
- generate meshes right away when running on server (so they can be assigned to colliders) while keeping it defered on the client so we only generated meshes when in LOD range
- create PathMeshLOD which is MeshLOD + request mesh generation when the lowest LOD becomes visible & destroy when no LOD is visible
- fix the "job" version creating a job per mesh segment instead of batching every 5 segments together
- some more fixes with the mesh generation (stuff like handling both 16bit and 32bit indicies instead of assuming every mesh is <65k verts)
Wrap PathList.CreateMesh() with a request class
- preparing to generate and destroy the meshes when the rail segments are loaded by WorldGrid instead of generating all rail meshes at startup and keeping them in memory for the whole session
- proxy the normal CreateMesh() method to use the "job" class internally (even though it runs on worker threads instead of the job system)
- switched to the NativeArray mesh building methods instead of using MeshCache.Data for storage