public void Length() { var array = new NativeArray2D <int>(length, width, Unity.Collections.Allocator.Temp); Assert.AreEqual(length * width, array.Length); array.Dispose(); }
protected override void OnDestroyManager() { if (IsInitialized) { ChunkMap.Dispose(); } _worldComponents.Dispose(); }
public void DisposeMakesArrayUnusable() { NativeArray2D <int> array = CreateArray(2, 3); array.Dispose(); int val; Assert.That(() => val = array[0, 0], Throws.Exception); }
public void Dispose() { output.Dispose(); input.Dispose(); inputSynapsesWeights.Dispose(); outputSynapsesWeights.Dispose(); hiddenLayerSynapsesWeights.Dispose(); hiddenLayerBias.Dispose(); secondHiddenLayerBias.Dispose(); }
public void Dispose() { var array = new NativeArray2D <int>(length, width, Unity.Collections.Allocator.Temp); Assert.IsTrue(array.IsCreated); array.Dispose(); Assert.Throws <System.ObjectDisposedException>(() => { array[0, 0] = 10; }); Assert.False(array.IsCreated); Assert.Throws <System.ObjectDisposedException>(() => { array.Dispose(); }); Assert.Throws <System.ObjectDisposedException>(() => { array.Dispose(default).Complete();
public void Execute() { var binaryIndex = new NativeArray2D <bool>(data.dataLengthX, data.dataLengthY, Allocator.Temp, NativeArrayOptions.UninitializedMemory); for (int y = 0; y < data.dataLengthY; y++) { for (int x = 0; x < data.dataLengthX; x++) { binaryIndex[x, y] = data.TestValue(x, y); } } for (int y = 0; y < contours.squaresLengthY; y++) { for (int x = 0; x < contours.squaresLengthX; x++) { byte square = 0; if (binaryIndex[x, y]) { square |= 1; } if (binaryIndex[x, y + 1]) { square |= 2; } if (binaryIndex[x + 1, y + 1]) { square |= 4; } if (binaryIndex[x + 1, y]) { square |= 8; } if (square == 5 || square == 10) { if (data.TestAverage(x, y)) { square |= 16; } } if (data.useInterpolation) { SetupCorners(x, y, square); } contours.SetSquare(x, y, square); } } binaryIndex.Dispose(); }
public void NativeArray2D_Performance_CopyTo() { NativeArray2D <int> array = new NativeArray2D <int>(width, height, Unity.Collections.Allocator.TempJob); int[,] dest = new int[width, height]; Measure.Method(() => { array.CopyTo(dest); }) .WarmupCount(1000) .MeasurementCount(1000) .Run(); array.Dispose(); }
public void NativeArray2D_Performance_BurstedWriteInParallelForBatchJob() { NativeArray2D <int> array = new NativeArray2D <int>(width, height, Unity.Collections.Allocator.TempJob); Measure.Method(() => { new BurstedWriteToArrayParallelForBatchJob { array = array }.ScheduleBatch(width * height, height).Complete(); }) .WarmupCount(1000) .MeasurementCount(1000) .Run(); array.Dispose(); }
public void NativeArray2D_Performance_WriteInJob() { NativeArray2D <int> array = new NativeArray2D <int>(width, height, Unity.Collections.Allocator.TempJob); int[,] dest = new int[width, height]; Measure.Method(() => { new WriteToArrayJob { array = array }.Schedule().Complete(); }) .WarmupCount(1000) .MeasurementCount(1000) .Run(); array.Dispose(); }
public void NativeArray2D_Performance_Write() { NativeArray2D <int> array = new NativeArray2D <int>(width, height, Unity.Collections.Allocator.TempJob); int[,] dest = new int[width, height]; Measure.Method(() => { for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { array[x, y] = x * y; } } }) .WarmupCount(1000) .MeasurementCount(1000) .Run(); array.Dispose(); }
public override void FreeBehaviour() { Grid.Dispose(); }
public void Dispose() { data.Dispose(); }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { //Writeable. NativeArray <PathFinding> pathfindingArray = chunk.GetNativeArray(pathFindingComponentHandle); BufferAccessor <PathNode> pathNodeBufferAccessor = chunk.GetBufferAccessor(pathNodeBufferHandle); //Read Only. NativeArray <CurrentTarget> currentTargetArray = chunk.GetNativeArray(currentTargetComponentHandle); NativeArray <Translation> translationArray = chunk.GetNativeArray(translationComponentHandle); NativeArray <Entity> entities = chunk.GetNativeArray(entityType); //Create a copy of the grid for this thread and chunk. NativeArray2D <MapNode> gridCopy = new NativeArray2D <MapNode>(gridRef.Length0, gridRef.Length1, Allocator.Temp, NativeArrayOptions.UninitializedMemory); UnsafeUtility.MemCpy(gridCopy.GetUnsafePtr(), gridRef.GetUnsafePtrReadOnly(), gridRef.Length * sizeof(MapNode)); for (int indexInChunk = 0; indexInChunk < chunk.Count; ++indexInChunk) { //Writable. PathFinding pathfinding = pathfindingArray[indexInChunk]; DynamicBuffer <PathNode> path = pathNodeBufferAccessor[indexInChunk]; //Read Only. Entity entity = entities[indexInChunk]; CurrentTarget currentTarget = currentTargetArray[indexInChunk]; Translation translation = translationArray[indexInChunk]; bool hasPath = chunk.Has(hasPathComponentHandle); if (!pathfinding.requestedPath) { //We only want to remove our has path component if we didn't request a new one, to avoid re-adding later in the job if we find a new path. if (pathfinding.completedPath) { pathfinding.completedPath = false; ecb.RemoveComponent <HasPathTag>(chunkIndex, entity); pathfindingArray[indexInChunk] = pathfinding; } continue; } path.Clear(); pathfinding.currentIndexOnPath = 0; pathfinding.completedPath = false; pathfinding.requestedPath = false; //Calculate the closest nodes to us and our target position. //Don't search for path if we're already at our target node. pathfinding.currentNode = FindNearestNode(translation.Value, gridCopy); pathfinding.targetNode = FindNearestNode(currentTarget.targetData.targetPos, gridCopy); if (pathfinding.targetNode.Equals(pathfinding.currentNode)) { pathfindingArray[indexInChunk] = pathfinding; continue; } CalculateGridH(gridCopy, ref pathfinding); bool pathfound = SearchForPath(pathfinding.currentNode, pathfinding.targetNode, gridCopy); if (pathfound) { ConstructPath(gridCopy, ref pathfinding, ref path); if (!hasPath) { ecb.AddComponent <HasPathTag>(chunkIndex, entity); } } else if (hasPath) { ecb.RemoveComponent <HasPathTag>(chunkIndex, entity); } pathfindingArray[indexInChunk] = pathfinding; } gridCopy.Dispose(); }
public void Dispose() { CostCellArray.Dispose(); }
public void Dispose() { squares.Dispose(); sides.Dispose(); }