public void Execute(int t) { int requiredSurfaceCount = 0; for (int b = 0, count_b = brushRenderData.Length; b < count_b; b++) { requiredSurfaceCount += brushRenderData[b].brushSurfaceCount; } // THIS IS THE SLOWDOWN // TODO: store surface separately from brushes, *somehow* make lifetime work // => multiple arrays, one for each meshQuery! // => sorted by surface.layerParameters[meshQuery.layerParameterIndex]! // => this whole job could be removed // TODO: store surface info and its vertices/indices separately, both sequentially in arrays // TODO: store surface vertices/indices sequentially in a big array, *somehow* make ordering work subMeshSurfaces.AllocateWithCapacityForIndex(t, requiredSurfaceCount); var subMeshSurfaceList = subMeshSurfaces[t]; for (int b = 0, count_b = brushRenderData.Length; b < count_b; b++) { var brushData = brushRenderData[b]; var brushRenderBuffer = brushData.brushRenderBuffer; ref var querySurfaces = ref brushRenderBuffer.Value.querySurfaces[t]; // <-- 1. somehow this needs to // be in outer loop ref var brushNodeID = ref querySurfaces.brushNodeID;
public void Execute() { if (subMeshSections.Length == 0) return; subMeshesArray. ResizeExact(subMeshSections.Length); indicesArray. ResizeExact(subMeshSections.Length); brushIndicesArray. ResizeExact(subMeshSections.Length); positionsArray. ResizeExact(subMeshSections.Length); tangentsArray. ResizeExact(subMeshSections.Length); normalsArray. ResizeExact(subMeshSections.Length); uv0Array. ResizeExact(subMeshSections.Length); for (int i = 0; i < subMeshSections.Length; i++) { var section = subMeshSections[i]; var numberOfSubMeshes = section.endIndex - section.startIndex; var totalVertexCount = section.totalVertexCount; var totalIndexCount = section.totalIndexCount; if (section.meshQuery.LayerParameterIndex == LayerParameterIndex.None || section.meshQuery.LayerParameterIndex == LayerParameterIndex.RenderMaterial) { subMeshesArray .AllocateWithCapacityForIndex(i, numberOfSubMeshes); brushIndicesArray.AllocateWithCapacityForIndex(i, totalIndexCount / 3); indicesArray .AllocateWithCapacityForIndex(i, totalIndexCount); positionsArray .AllocateWithCapacityForIndex(i, totalVertexCount); tangentsArray .AllocateWithCapacityForIndex(i, totalVertexCount); normalsArray .AllocateWithCapacityForIndex(i, totalVertexCount); uv0Array .AllocateWithCapacityForIndex(i, totalVertexCount); subMeshesArray [i].Clear(); brushIndicesArray[i].Clear(); indicesArray [i].Clear(); positionsArray [i].Clear(); tangentsArray [i].Clear(); normalsArray [i].Clear(); uv0Array [i].Clear(); subMeshesArray [i].Resize(numberOfSubMeshes, NativeArrayOptions.ClearMemory); brushIndicesArray[i].Resize(totalIndexCount / 3, NativeArrayOptions.ClearMemory); indicesArray [i].Resize(totalIndexCount, NativeArrayOptions.ClearMemory); positionsArray [i].Resize(totalVertexCount, NativeArrayOptions.ClearMemory); tangentsArray [i].Resize(totalVertexCount, NativeArrayOptions.ClearMemory); normalsArray [i].Resize(totalVertexCount, NativeArrayOptions.ClearMemory); uv0Array [i].Resize(totalVertexCount, NativeArrayOptions.ClearMemory); } else if (section.meshQuery.LayerParameterIndex == LayerParameterIndex.PhysicsMaterial) { subMeshesArray .AllocateWithCapacityForIndex(i, 1); indicesArray .AllocateWithCapacityForIndex(i, totalIndexCount); positionsArray .AllocateWithCapacityForIndex(i, totalVertexCount); subMeshesArray [i].Clear(); indicesArray [i].Clear(); positionsArray [i].Clear(); subMeshesArray [i].Resize(1, NativeArrayOptions.ClearMemory); indicesArray [i].Resize(totalIndexCount, NativeArrayOptions.ClearMemory); positionsArray [i].Resize(totalVertexCount, NativeArrayOptions.ClearMemory); } } }