Bug #28634
Unnecessary GCAlloc and Increased CPU Time Building Terrain
0%
Description
When profiling the game when a terrain quad is being built, there is a significant amount of GC.Alloc (garbage) being created. The profiler does have a performance hit, but these allocations are taking up 19% of the quad building time. It can be easily avoided, reducing both garbage generated and CPU time.
When accessing Mesh.normals, a new copy of the normals array is returned. In one of the pictures I have attached, Mesh.normals is being accessed for every vertex in the PQS cache. This is the source of these GC.Alloc flags. To fix this, refer to the last image I have attached. In my proposed solution, only 1 copy of the array is created. When accessing that array, a new copy is not made. This will improve quad building times and reduce GC.Alloc flags significantly.