private Unity.Collections.NativeList <GridNodeData> AstarSearch(ref int statVisited, GridGraph graph, GridNode startNode, GridNode endNode, Constraint constraint, int threadIndex) { var graphSize = graph.size; var graphCenter = graph.graphCenter; var burstConstraint = constraint.GetBurstConstraint(); var resultPath = new Unity.Collections.NativeList <GridNodeData>(10, Unity.Collections.Allocator.Persistent); var arr = new Unity.Collections.NativeArray <GridNodeData>(graph.nodesData, Unity.Collections.Allocator.TempJob); var openList = new PriorityQueueNative <GridNodeData>(Unity.Collections.Allocator.TempJob, 500, true); var results = new Unity.Collections.NativeArray <int>(2, Unity.Collections.Allocator.TempJob); var endNodeIndex = endNode.index; var startNodeIndex = startNode.index; var job = new Job() { graphCenter = graphCenter, graphSize = graphSize, burstConstraint = burstConstraint, resultPath = resultPath, arr = arr, openList = openList, results = results, endNodeIndex = endNodeIndex, startNodeIndex = startNodeIndex, }; job.Schedule().Complete(); statVisited = results[0]; results.Dispose(); openList.Dispose(); arr.Dispose(); return(resultPath); }
public void Execute() { this.pathResults[0] = default; this.pathResults[1] = default; //UnityEngine.Debug.Log("Exec1"); var from = this.query.MapLocation(this.fromPoint, new Vector3(100f, 100f, 100f), this.agentTypeId, this.areas); if (from.polygon.IsNull() == true) { return; } //UnityEngine.Debug.Log("Exec2"); var to = this.query.MapLocation(this.toPoint, new Vector3(100f, 100f, 100f), this.agentTypeId, this.areas); if (to.polygon.IsNull() == true) { return; } //UnityEngine.Debug.Log("Exec3"); this.query.BeginFindPath(from, to, this.areas); this.query.UpdateFindPath(PathfindingNavMeshProcessor.MAX_ITERATIONS, out var performed); //statVisited = performed; var result = this.query.EndFindPath(out var pathSize); if ((result & UnityEngine.Experimental.AI.PathQueryStatus.Success) != 0) { var pathInternal = new Unity.Collections.NativeArray <UnityEngine.Experimental.AI.PolygonId>(pathSize, Unity.Collections.Allocator.Temp); var straightPathFlags = new Unity.Collections.NativeArray <StraightPathFlags>(PathfindingNavMeshProcessor.MAX_PATH_SIZE, Unity.Collections.Allocator.Temp); var vertexSide = new Unity.Collections.NativeArray <float>(PathfindingNavMeshProcessor.MAX_PATH_SIZE, Unity.Collections.Allocator.Temp); //UnityEngine.Debug.Log("Exec4"); this.query.GetPathResult(pathInternal); var job = new FindStraightPathJob() { query = this.query, from = from, to = to, pathInternal = pathInternal, pathSize = pathSize, results = this.results, straightPathFlags = straightPathFlags, vertexSide = vertexSide, resultStatus = this.pathResults, }; job.Execute(); if ((result & UnityEngine.Experimental.AI.PathQueryStatus.PartialResult) != 0) { this.pathResults[0] |= (int)UnityEngine.Experimental.AI.PathQueryStatus.PartialResult; } vertexSide.Dispose(); straightPathFlags.Dispose(); pathInternal.Dispose(); } }
public void RunTasks(Unity.Collections.NativeArray <PathTask> tasks, ref BufferArray <Path> results) { ArrayUtils.Resize(tasks.Length, ref Pathfinding.results); Pathfinding.pathfinding = this; var job = new RunTasksJob() { arr = tasks, }; var jobHandle = job.Schedule(tasks.Length, 64); jobHandle.Complete(); results = Pathfinding.results; /* * for (int i = 0; i < tasks.Count; ++i) { * * var task = tasks[i]; * task.result = this.CalculatePath(task.@from, task.to, task.constraint, task.pathCornersModifier); * tasks[i] = task; * * }*/ }
public static void CopyWithIndex <T, TCopy>(Unity.Collections.NativeArray <T> fromArr, ref Unity.Collections.NativeArray <T> arr, TCopy copy) where TCopy : IArrayElementCopyWithIndex <T> where T : struct { if (fromArr.IsCreated == false) { if (arr.IsCreated == true) { NativeArrayUtils.RecycleWithIndex(ref arr, copy); } arr = default; return; } if (arr.IsCreated == false || fromArr.Length != arr.Length) { if (arr.IsCreated == true) { NativeArrayUtils.RecycleWithIndex(ref arr, copy); } arr = new Unity.Collections.NativeArray <T>(fromArr.Length, Unity.Collections.Allocator.Persistent); } for (int i = 0; i < fromArr.Length; ++i) { copy.Copy(i, fromArr[i], ref arr.GetRef(i)); } }
public static bool Resize <T>(int index, ref Unity.Collections.NativeArray <T> arr, bool resizeWithOffset = true, Unity.Collections.Allocator allocator = Unity.Collections.Allocator.Persistent) where T : struct { var offset = (resizeWithOffset == true ? 2 : 1); if (arr.IsCreated == false) { arr = new Unity.Collections.NativeArray <T>(index * offset + 1, allocator); } if (index < arr.Length) { return(false); } var newLength = arr.Length * offset + 1; if (newLength == 0 || newLength <= index) { newLength = index * offset + 1; } var newArr = new Unity.Collections.NativeArray <T>(newLength, allocator); Unity.Collections.NativeArray <T> .Copy(arr, 0, newArr, 0, arr.Length); arr.Dispose(); arr = newArr; return(true); }
public static void DrawLine(Texture2D tex, Vector2 p1, Vector2 p2, Color32 col, int radius = 3) { Vector2 t = p1; float frac = 1 / Mathf.Sqrt(Mathf.Pow(p2.x - p1.x, 2) + Mathf.Pow(p2.y - p1.y, 2)); float ctr = 0; // RGBA32 texture format data layout exactly matches Color32 struct Unity.Collections.NativeArray <Color32> data = tex.GetRawTextureData <Color32>(); data[(int)(tex.width * (0.5f + tex.height / 2))] = col; while ((int)t.x != (int)p2.x || (int)t.y != (int)p2.y) { t = Vector2.Lerp(p1, p2, ctr); ctr += frac; for (int i = -radius; i < radius; ++i) { for (int j = -radius; j < radius; ++j) { int x = (int)(t.x) + i; int y = (int)(t.y) + j; float distSquared = Mathf.Sqrt(i * i + j * j); if (distSquared <= radius) { if (x > 0 && x < tex.width && y > 0 && y < tex.height) { //int alpha = (255 - (int)(distSquared / radius * 255)); //col.a = (byte)alpha; data[x + y * tex.width] = col; } } } } } }
public void CompareBurstWithManagedAccess() { var arr = new Unity.Collections.NativeArray <TestData>(100, Unity.Collections.Allocator.Persistent); var managedArr = new TestData[100]; { var sw = System.Diagnostics.Stopwatch.StartNew(); managedArr[50] = new TestData(); UnityEngine.Debug.Log("Managed ticks: " + sw.ElapsedTicks); sw.Restart(); } { var sw = System.Diagnostics.Stopwatch.StartNew(); new BurstAccess() { arr = arr, index = 50 }.Schedule().Complete(); UnityEngine.Debug.Log("Burst job ticks: " + sw.ElapsedTicks); sw.Restart(); } { var sw = System.Diagnostics.Stopwatch.StartNew(); BurstMethod(ref arr, 50); UnityEngine.Debug.Log("Burst ticks: " + sw.ElapsedTicks); sw.Restart(); } arr.Dispose(); }
public override void UpdateBehaviour() { // Re-assign the new texture to the minimap minimap.image = miniMapRenderTexture; // // ---- RESOURCES ---- \\ // EntityQuery entityQuery = entityManager.CreateEntityQuery(ComponentType.ReadWrite<Resources>()); // Resources resources = entityQuery.GetSingleton<Resources>(); // // entityQuery.SetSingleton<Resources>(res); // // Resource Text // resource1Text.text = resources.buildingMaterial.ToString(); // resource2Text.text = resources.food.ToString(); // resource3Text.text = resources.rareResource.ToString(); // ---- SELECTED PLAYERS ---- \\ if (selectionSystem.redrawSelectedUnits) { selectionSystem.redrawSelectedUnits = false; entities = selectedQuery.ToEntityArray(Unity.Collections.Allocator.Persistent); if (entities.Length > 0) { AddSelectedUnits(entities.Length); } entities.Dispose(); } }
// Retrace portals between corners and register if type of polygon changes public static int RetracePortals(UnityEngine.Experimental.AI.NavMeshQuery query, int startIndex, int endIndex, Unity.Collections.NativeSlice <UnityEngine.Experimental.AI.PolygonId> path, int n, Vector3 termPos, ref Unity.Collections.NativeArray <UnityEngine.Experimental.AI.NavMeshLocation> straightPath, ref Unity.Collections.NativeArray <StraightPathFlags> straightPathFlags, int maxStraightPath) { for (var k = startIndex; k < endIndex - 1; ++k) { var type1 = query.GetPolygonType(path[k]); var type2 = query.GetPolygonType(path[k + 1]); if (type1 != type2) { Vector3 l, r; var status = query.GetPortalPoints(path[k], path[k + 1], out l, out r); Unity.Mathematics.float3 cpa1, cpa2; GeometryUtils.SegmentSegmentCPA(out cpa1, out cpa2, l, r, straightPath[n - 1].position, termPos); straightPath[n] = query.CreateLocation(cpa1, path[k + 1]); straightPathFlags[n] = type2 == UnityEngine.Experimental.AI.NavMeshPolyTypes.OffMeshConnection ? StraightPathFlags.OffMeshConnection : 0; if (++n == maxStraightPath) { return(maxStraightPath); } } } straightPath[n] = query.CreateLocation(termPos, path[endIndex]); straightPathFlags[n] = query.GetPolygonType(path[endIndex]) == UnityEngine.Experimental.AI.NavMeshPolyTypes.OffMeshConnection ? StraightPathFlags.OffMeshConnection : 0; return(++n); }
public EntitiesGroup(int fromId, int toId, Unity.Collections.NativeArray <Entity> slice, bool copyMode) { this.fromId = fromId; this.toId = toId; this.Length = this.toId - this.fromId + 1; this.slice = slice; this.copyMode = copyMode; }
public static void RecycleWithIndex <T, TCopy>(ref Unity.Collections.NativeArray <T> item, TCopy copy) where TCopy : IArrayElementCopyWithIndex <T> where T : struct { for (int i = 0; i < item.Length; ++i) { copy.Recycle(i, ref item.GetRef(i)); } item.Dispose(); }
public static void Copy <T>(Unity.Collections.NativeArray <T> fromArr, ref Unity.Collections.NativeArray <T> arr) where T : struct { if (arr == null || arr.IsCreated == false) { arr = new Unity.Collections.NativeArray <T>(fromArr.Length, Unity.Collections.Allocator.Persistent, Unity.Collections.NativeArrayOptions.ClearMemory); } Unity.Collections.NativeArray <T> .Copy(fromArr, arr, fromArr.Length); }
public void AddRange <U>(Unity.Collections.NativeArray <U> items) where U : struct { var arrayLength = items.Length; this.EnsureCapacity(this.Count + arrayLength + 1); NativeArrayUtils.CopyCast <U, T>(in items, 0, this.innerArray.arr, this.Count, arrayLength); this.Count += arrayLength; /*for (var i = 0; i < arrayLength; i++) { * this.innerArray.arr[this.Count++] = items.arr[i]; * }*/ }
public static NativeBufferArray <T> Spawn(int length, bool realSize = false, Unity.Collections.Allocator allocator = Unity.Collections.Allocator.Persistent) { var arrSize = PoolArray <T> .GetSize(length); var arr = new Unity.Collections.NativeArray <T>(arrSize, allocator); var size = (realSize == true ? arr.Length : length); var buffer = new NativeBufferArray <T>(arr, length, realSize == true ? arr.Length : -1); NativeArrayUtils.Clear(buffer, 0, size); return(buffer); }
public static ref readonly T GetRefRead <T>(this Unity.Collections.NativeArray <T> array, int index) where T : struct { CheckArray(index, array.Length); unsafe { var ptr = array.GetUnsafeReadOnlyPtr(); #if UNITY_2020_1_OR_NEWER return(ref UnsafeUtility.ArrayElementAsRef <T>(ptr, index)); #else throw new Exception("UnsafeUtility.ArrayElementAsRef"); #endif } }
static StackObject *CombineDependencies_8(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); Unity.Collections.NativeArray <Unity.Jobs.JobHandle> @jobs = (Unity.Collections.NativeArray <Unity.Jobs.JobHandle>) typeof(Unity.Collections.NativeArray <Unity.Jobs.JobHandle>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = Unity.Jobs.JobHandle.CombineDependencies(@jobs); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
public static ref T GetRef <T>(this Unity.Collections.NativeArray <T> array, int index) where T : struct { if (index < 0 || index >= array.Length) { throw new ArgumentOutOfRangeException(nameof(index)); } unsafe { var ptr = array.GetUnsafePtr(); #if UNITY_2020_1_OR_NEWER return(ref UnsafeUtility.ArrayElementAsRef <T>(ptr, index)); #else throw new Exception("UnsafeUtility.ArrayElementAsRef"); #endif } }
public void RunTasks <TMod, TProcessor>(Unity.Collections.NativeArray <PathTask> tasks, ref BufferArray <Path> results) where TMod : struct, IPathModifier where TProcessor : struct, IPathfindingProcessor { ArrayUtils.Resize(tasks.Length, ref Pathfinding.results); Pathfinding.pathfinding = this; var job = new RunTasksJob <TMod, TProcessor>() { arr = tasks, }; for (int i = 0; i < tasks.Length; ++i) { var item = tasks[i]; if (item.burstEnabled == true) { job.Execute(i); item.isValid = false; tasks[i] = item; } } var jobHandle = job.Schedule(tasks.Length, 64); jobHandle.Complete(); for (int i = 0; i < tasks.Length; ++i) { var item = tasks[i]; if (item.burstEnabled == true) { item.isValid = true; tasks[i] = item; } } results = Pathfinding.results; /* * for (int i = 0; i < tasks.Count; ++i) { * * var task = tasks[i]; * task.result = this.CalculatePath(task.@from, task.to, task.constraint, task.pathCornersModifier); * tasks[i] = task; * * }*/ }
private void CopyReplacementAreaToBrush(float uvx, float uvy, out int startX, out int startY, out int blockWidth, out int blockHeight) { GetArea(uvx, uvy, out startX, out startY, out blockWidth, out blockHeight); // read into brushPixels Unity.Collections.NativeArray <Color32> pixels = replacementTexture.GetRawTextureData <Color32>(); int i = 0; for (int y = 0; y < blockHeight; y++) { for (int x = 0; x < blockWidth; x++) { brushPixels[i++] = pixels[(startY + y) * sourceTexture.width + startX + x]; } } }
internal PhysicsBridgePatch(Guid sourceId, Snapshot snapshot) { Id = sourceId; Time = snapshot.Time; TransformCount = snapshot.Transforms.Count; if (TransformCount > 0) { // copy transform to native array to reinterpret it to byte array without 'unsafe' code // todo: we should use native array in snapshot anyway. Unity.Collections.NativeArray <Snapshot.TransformInfo> transforms = new Unity.Collections.NativeArray <Snapshot.TransformInfo>(snapshot.Transforms.ToArray(), Unity.Collections.Allocator.Temp); NativeSlice <byte> blob = new NativeSlice <Snapshot.TransformInfo>(transforms).SliceConvert <byte>(); TransformsBLOB = blob.ToArray(); } }
static StackObject *InstanceIDToObjectList_11(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Collections.Generic.List <UnityEngine.Object> @objects = (System.Collections.Generic.List <UnityEngine.Object>) typeof(System.Collections.Generic.List <UnityEngine.Object>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); Unity.Collections.NativeArray <System.Int32> @instanceIDs = (Unity.Collections.NativeArray <System.Int32>) typeof(Unity.Collections.NativeArray <System.Int32>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); UnityEngine.Resources.InstanceIDToObjectList(@instanceIDs, @objects); return(__ret); }
public void SetSkinnedMeshRenderer(SkinnedMeshRenderer renderer, Transform parent) { Transform[] bonesTransform = new Transform[bones.Length]; for (int i = 0; i < bones.Length; i++) { bonesTransform[i] = parent.Find(bones[i]); } renderer.bones = bonesTransform; renderer.sharedMesh = mesh.CreateMesh(); renderer.sharedMesh.bindposes = bindposes; Unity.Collections.NativeArray <BoneWeight1> bw1 = new Unity.Collections.NativeArray <BoneWeight1>(boneIndexes.Length, Unity.Collections.Allocator.Temp); for (int j = 0; j < boneIndexes.Length; j++) { bw1[j] = new BoneWeight1 { boneIndex = boneIndexes[j], weight = boneWeigts[j] }; } renderer.sharedMesh.SetBoneWeights(new Unity.Collections.NativeArray <byte>(bonesPerVert, Unity.Collections.Allocator.Temp), bw1); renderer.rootBone = parent.Find(rootBone); renderer.localBounds = new Bounds(boundsCenter, boundsExtend); renderer.sharedMesh.RecalculateBounds(); }
private void CubemapToBitmapLayout() { cam.RenderToCubemap(tex, 63); tex.SmoothEdges(50); Unity.Collections.NativeArray <Color32> rawData = OutTex.GetRawTextureData <Color32>(); int index = 0; for (int i = CubemapFaces.Length; i > 0; --i) { Color[] face = tex.GetPixels(CubemapFaces[i - 1]); for (int y = 0; y < tex.height; y++) { for (int x = 0; x < tex.width; x++) { // invert the input tex since origin is bottom left corner int faceIndex = ((tex.height - 1 - y) * tex.width + x); rawData[index++] = face[faceIndex]; } } } OutTex.Apply(); }
public DataBuffer(World world, ME.ECS.Collections.BufferArray <Entity> arr, int minIdx, int maxIdx) { var reg = (StructComponents <T>)world.currentState.structComponents.list.arr[WorldUtilities.GetAllComponentTypeId <T>()]; this.minIdx = minIdx; if (this.minIdx > maxIdx) { this.minIdx = 0; maxIdx = 0; } if (this.minIdx < 0) { this.minIdx = 0; } if (maxIdx >= reg.components.Length) { maxIdx = reg.components.Length - 1; } this.Length = maxIdx - this.minIdx; this.arr = new Unity.Collections.NativeArray <T>(reg.components.arr, Unity.Collections.Allocator.Persistent); this.data = new Unity.Collections.NativeSlice <T>(this.arr, this.minIdx, maxIdx); }
public static Texture2D CalculateColorTexture(QuantumCircuitFloat redCircuit, QuantumCircuitFloat greenCircuit, QuantumCircuitFloat blueCircuit, int width, int height, bool renormalize = false) { Texture2D texture = new Texture2D(width, height, TextureFormat.RGBA32, false); int widthLog = Mathf.CeilToInt(Mathf.Log(width) / Mathf.Log(2)); int heightLog = widthLog; int[] widthLines = MakeLinesInt(widthLog); int[] heightLines = widthLines; if (height != width) { heightLog = Mathf.CeilToInt(Mathf.Log(height) / Mathf.Log(2)); heightLines = MakeLinesInt(heightLog); } MicroQiskitSimulatorFloat simulator = new MicroQiskitSimulatorFloat(); float[] redProbs = simulator.GetProbabilities(redCircuit); float[] greenProbs = simulator.GetProbabilities(greenCircuit); float[] blueProbs = simulator.GetProbabilities(blueCircuit); float normalizationRed = 0; float normalizationGreen = 0; float normalizationBlue = 0; if (!renormalize && redCircuit.OriginalSum > 0 && greenCircuit.OriginalSum > 0 && blueCircuit.OriginalSum > 0) { normalizationRed = redCircuit.OriginalSum; normalizationGreen = greenCircuit.OriginalSum; normalizationBlue = blueCircuit.OriginalSum; } else { for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { int pos = widthLines[i] * height + heightLines[j]; if (redProbs[pos] > normalizationRed) { normalizationRed = redProbs[pos]; } if (greenProbs[pos] > normalizationGreen) { normalizationGreen = greenProbs[pos]; } if (blueProbs[pos] > normalizationBlue) { normalizationBlue = blueProbs[pos]; } } } normalizationRed = 1.0f / normalizationRed; normalizationGreen = 1.0f / normalizationGreen; normalizationBlue = 1.0f / normalizationBlue; } Unity.Collections.NativeArray <Color32> data = texture.GetRawTextureData <Color32>(); //TODO set blocks of color float redValue; float greenValue; float blueValue; //Color color = new Color(); int posX = 0; for (int x = 0; x < width; x++) { posX = widthLines[x] * height; for (int y = 0; y < height; y++) { int index = posX + heightLines[y]; redValue = (redProbs[index] * normalizationRed); greenValue = (greenProbs[index] * normalizationGreen); blueValue = (blueProbs[index] * normalizationBlue); //color.r = redValue; //color.g = greenValue; //color.b = blueValue; texture.SetPixel(x, y, new Color(redValue, greenValue, blueValue)); } } texture.Apply(); return(texture); }
public static LambdaJobChunkDescription WithFilter(this LambdaJobChunkDescription description, [AllowDynamicValue] Unity.Collections.NativeArray <Entity> entities) => description;
public static ForEachLambdaJobDescriptionJCS WithFilter(this ForEachLambdaJobDescriptionJCS description, [AllowDynamicValue] Unity.Collections.NativeArray <Entity> entities) => description;
private static void FixSeams(Mesh source, Mesh output, List <List <int> > submeshes, List <Ring> rings, List <Insertion> insertions, P3dCoord coord) { output.bindposes = source.bindposes; output.bounds = source.bounds; output.subMeshCount = source.subMeshCount; output.indexFormat = source.indexFormat; if (source.vertexCount + insertions.Count >= 65535) { output.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32; } var weights = new List <BoneWeight>(); source.GetBoneWeights(weights); var colors = new List <Color32>(); source.GetColors(colors); var normals = new List <Vector3>(); source.GetNormals(normals); var tangents = new List <Vector4>(); source.GetTangents(tangents); var coords0 = new List <Vector4>(); source.GetUVs(0, coords0); var coords1 = new List <Vector4>(); source.GetUVs(1, coords1); var coords2 = new List <Vector4>(); source.GetUVs(2, coords2); var coords3 = new List <Vector4>(); source.GetUVs(3, coords3); var positions = new List <Vector3>(); source.GetVertices(positions); #if UNITY_2019_1_OR_NEWER var boneVertices = new List <byte>(source.GetBonesPerVertex()); var boneWeights = new List <BoneWeight1>(source.GetAllBoneWeights()); var boneIndices = new List <int>(); if (boneVertices.Count > 0) { var total = 0; foreach (var count in boneVertices) { boneIndices.Add(total); total += count; } weights.Clear(); } #endif foreach (var insertion in insertions) { #if UNITY_2019_1_OR_NEWER if (boneVertices.Count > 0) { var index = boneIndices[insertion.Index]; var count = boneVertices[insertion.Index]; boneVertices.Add(count); for (var i = 0; i < count; i++) { boneWeights.Add(boneWeights[index + i]); } } #endif if (weights.Count > 0) { weights.Add(weights[insertion.Index]); } if (colors.Count > 0) { colors.Add(colors[insertion.Index]); } if (normals.Count > 0) { normals.Add(normals[insertion.Index]); } if (tangents.Count > 0) { tangents.Add(tangents[insertion.Index]); } if (coords0.Count > 0) { AddCoord(coords0, insertion, coord == P3dCoord.First); } if (coords1.Count > 0) { AddCoord(coords1, insertion, coord == P3dCoord.Second); } if (coords2.Count > 0) { AddCoord(coords2, insertion, coord == P3dCoord.Third); } if (coords3.Count > 0) { AddCoord(coords3, insertion, coord == P3dCoord.Fourth); } positions.Add(positions[insertion.Index]); } output.SetVertices(positions); if (weights.Count > 0) { output.boneWeights = weights.ToArray(); } #if UNITY_2019_1_OR_NEWER if (boneVertices.Count > 0) { var na1 = new Unity.Collections.NativeArray <byte>(boneVertices.ToArray(), Unity.Collections.Allocator.Temp); var na2 = new Unity.Collections.NativeArray <BoneWeight1>(boneWeights.ToArray(), Unity.Collections.Allocator.Temp); output.SetBoneWeights(na1, na2); na2.Dispose(); na1.Dispose(); } #endif output.SetColors(colors); output.SetNormals(normals); output.SetTangents(tangents); output.SetUVs(0, coords0); output.SetUVs(1, coords1); output.SetUVs(2, coords2); output.SetUVs(3, coords3); var deltaVertices = new List <Vector3>(); var deltaNormals = new List <Vector3>(); var deltaTangents = new List <Vector3>(); if (source.blendShapeCount > 0) { var tempDeltaVertices = new Vector3[source.vertexCount]; var tempDeltaNormals = new Vector3[source.vertexCount]; var tempDeltaTangents = new Vector3[source.vertexCount]; for (var i = 0; i < source.blendShapeCount; i++) { var shapeName = source.GetBlendShapeName(i); var frameCount = source.GetBlendShapeFrameCount(i); for (var j = 0; j < frameCount; j++) { source.GetBlendShapeFrameVertices(i, j, tempDeltaVertices, tempDeltaNormals, tempDeltaTangents); deltaVertices.Clear(); deltaNormals.Clear(); deltaTangents.Clear(); deltaVertices.AddRange(tempDeltaVertices); deltaNormals.AddRange(tempDeltaNormals); deltaTangents.AddRange(tempDeltaTangents); foreach (var insertion in insertions) { deltaVertices.Add(deltaVertices[insertion.Index]); deltaNormals.Add(deltaNormals[insertion.Index]); deltaTangents.Add(deltaTangents[insertion.Index]); } output.AddBlendShapeFrame(shapeName, source.GetBlendShapeFrameWeight(i, j), deltaVertices.ToArray(), deltaNormals.ToArray(), deltaTangents.ToArray()); } } } for (var i = 0; i < submeshes.Count; i++) { output.SetTriangles(submeshes[i], i); } }
public static void BurstMethod(ref Unity.Collections.NativeArray <TestData> arr, int index) { arr[index] = new TestData(); }
unsafe public static void EmitFrameMetaData <T>(Guid id, int tag, Unity.Collections.NativeArray <T> data) where T : struct { Internal_EmitFrameMetaData_Native(id.ToByteArray(), tag, (IntPtr)data.GetUnsafeReadOnlyPtr(), data.Length, UnsafeUtility.SizeOf <T>()); }