internal NativeArray <bool> GetVertexMarkerFromMeshUV(int lod) { int dimension = GGeometryJobUtilities.VERTEX_MARKER_DIMENSION; NativeArray <bool> markers = new NativeArray <bool>(dimension * dimension, Allocator.TempJob); Mesh m = GetMesh(lod); Vector2[] uvs = m.uv; int x = 0; int y = 0; Vector2 uv = Vector2.zero; for (int i = 0; i < uvs.Length; ++i) { uv = uvs[i]; x = (int)(uv.x * (dimension - 1)); y = (int)(uv.y * (dimension - 1)); markers[GGeometryJobUtilities.To1DIndex(ref x, ref y, ref dimension)] = true; } GUtilities.EnsureArrayLength(ref vertexMarker_Cache, markers.Length); markers.CopyTo(vertexMarker_Cache); return(markers); }
internal void InitMeshDataNativeContainers(GAlbedoToVertexColorMode albedoToVertexColor) { int vertexCount = generationMetadata[0] * 3; vertexNativeArray = new NativeArray <Vector3>(vertexCount, Allocator.TempJob, NativeArrayOptions.UninitializedMemory); GUtilities.EnsureArrayLength(ref vertexArray, vertexCount); uvsNativeArray = new NativeArray <Vector2>(vertexCount, Allocator.TempJob, NativeArrayOptions.UninitializedMemory); GUtilities.EnsureArrayLength(ref uvsArray, vertexCount); trianglesNativeArray = new NativeArray <int>(vertexCount, Allocator.TempJob, NativeArrayOptions.UninitializedMemory); GUtilities.EnsureArrayLength(ref trianglesArray, vertexCount); normalsNativeArray = new NativeArray <Vector3>(vertexCount, Allocator.TempJob, NativeArrayOptions.UninitializedMemory); GUtilities.EnsureArrayLength(ref normalsArray, vertexCount); if (albedoToVertexColor == GAlbedoToVertexColorMode.None) { vertexColorsNativeArray = new NativeArray <Color32>(1, Allocator.TempJob, NativeArrayOptions.UninitializedMemory); } else { vertexColorsNativeArray = new NativeArray <Color32>(vertexCount, Allocator.TempJob, NativeArrayOptions.UninitializedMemory); GUtilities.EnsureArrayLength(ref vertexColorsArray, vertexCount); } }
internal void CacheVertexMarker() { if (vertexMarkerNativeArray.IsCreated) { GUtilities.EnsureArrayLength(ref vertexMarker_Cache, vertexMarkerNativeArray.Length); vertexMarkerNativeArray.CopyTo(vertexMarker_Cache); } }