public void InsertTriggerDivideNonBurstBulk() { var values = GetValues(); var positions = new NativeArray <float3>(values.Length, Allocator.TempJob); var octree = new NativeOctree <int>(Bounds); positions.CopyFrom(values); NativeArray <OctElement <int> > elements = new NativeArray <OctElement <int> >(positions.Length, Allocator.Temp); for (int i = 0; i < positions.Length; i++) { elements[i] = new OctElement <int> { pos = positions[i], element = i }; } var s = Stopwatch.StartNew(); octree.ClearAndBulkInsert(elements); s.Stop(); Debug.Log(s.Elapsed.TotalMilliseconds); OctreeDrawer.Draw(octree); octree.Dispose(); positions.Dispose(); }
public void RangeQueryAfterBulk() { var values = GetValues(); NativeArray <OctElement <int> > elements = new NativeArray <OctElement <int> >(values.Length, Allocator.TempJob); for (int i = 0; i < values.Length; i++) { elements[i] = new OctElement <int> { pos = values[i], element = i }; } var octree = new NativeOctree <int>(Bounds); octree.ClearAndBulkInsert(elements); var queryJob = new OctreeJobs.RangeQueryJob <int> { Octree = octree, Bounds = new AABB { Center = 100, Extents = new float3(200, 1000, 200) }, Results = new NativeList <OctElement <int> >(1000, Allocator.TempJob) }; var s = Stopwatch.StartNew(); queryJob.Run(); s.Stop(); Debug.Log(s.Elapsed.TotalMilliseconds + " result: " + queryJob.Results.Length); OctreeDrawer.DrawWithResults(queryJob); octree.Dispose(); elements.Dispose(); queryJob.Results.Dispose(); }