public void InsertTriggerDivideNonBurstBulk() { var values = GetValues(); var positions = new NativeArray <float2>(values.Length, Allocator.TempJob); var quadTree = new NativeQuadTree <int>(Bounds); positions.CopyFrom(values); NativeArray <QuadElement <int> > elements = new NativeArray <QuadElement <int> >(positions.Length, Allocator.Temp); for (int i = 0; i < positions.Length; i++) { elements[i] = new QuadElement <int> { pos = positions[i], element = i }; } var s = Stopwatch.StartNew(); quadTree.ClearAndBulkInsert(elements); s.Stop(); Debug.Log(s.Elapsed.TotalMilliseconds); QuadTreeDrawer.Draw(quadTree); quadTree.Dispose(); positions.Dispose(); }
private void OnDestroy() { NativeQuadTreePathFinding.ClearAll(); if (_quadTree.IsCreated) { _quadTree.Dispose(); } }
public void RangeQueryAfterBulk() { var values = GetValues(); NativeArray <QuadElement <int> > elements = new NativeArray <QuadElement <int> >(values.Length, Allocator.TempJob); for (int i = 0; i < values.Length; i++) { elements[i] = new QuadElement <int> { pos = values[i], element = i }; } var quadTree = new NativeQuadTree <int>(Bounds); quadTree.ClearAndBulkInsert(elements); var queryJob = new QuadTreeJobs.RangeQueryJob <int> { QuadTree = quadTree, Bounds = new AABB2D(100, 140), Results = new NativeList <QuadElement <int> >(1000, Allocator.TempJob) }; var s = Stopwatch.StartNew(); queryJob.Run(); s.Stop(); Debug.Log(s.Elapsed.TotalMilliseconds + " result: " + queryJob.Results.Length); QuadTreeDrawer.DrawWithResults(queryJob); quadTree.Dispose(); elements.Dispose(); queryJob.Results.Dispose(); }