Beispiel #1
0
    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();
    }
Beispiel #2
0
        public void Build(NativeOctree <int> tree, NativeArray <OctElement <int> > elements)
        {
            BuildStopWatch.Restart();

            Job.WithCode(() =>
            {
                tree.ClearAndBulkInsert(elements);
            }).Run();

            BuildStopWatch.Stop();
            if (DebugLogging)
            {
                Debug.Log($"NativeOctree.ClearAndBulkInsert took {BuildStopWatch.Elapsed.TotalMilliseconds:N4}ms for {elements.Length} elements");
            }
        }
Beispiel #3
0
    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();
    }