Runtime/SpatialHash.cs
/// <summary>
/// Query system to find object in <paramref name="bounds"/>.
/// </summary>
Query system to find object in .
Query system to find object in .
public void Query(Bounds bounds, NativeList<T> resultList)
        {
            Assert.IsTrue(resultList.IsCreated);
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            AtomicSafetyHandle.CheckReadAndThrow(_safety);
#endif
            bounds.Clamp(_data -> WorldBounds);
            CalculStartEndIterationInternal(_data, bounds, out var start, out var end);
            var hashMapUnic  = new NativeHashMap<int, byte>(64, Allocator.Temp);
            var hashPosition = new int3(0F);
            for (int x = start.x; x < end.x; ++x)
            {
                hashPosition.x = x;
                for (int y = start.y; y < end.y; ++y)
                {
                    hashPosition.y = y;
                    for (int z = start.z; z < end.z; ++z)
                    {
                        hashPosition.z = z;
                        var hash = Hash(hashPosition);
                        if (_buckets.TryGetFirstValue(hash, out var item, out var it))
                            do
                                hashMapUnic.TryAdd(item, 0);
                            while (_buckets.TryGetNextValue(out item, ref it));
                    }
                }
            }
            ExtractValueFromHashMap(hashMapUnic, bounds, resultList);
        }
public void Query ( Bounds bounds , NativeList < T > resultList ) { Assert . IsTrue ( resultList . IsCreated ) ; if ENABLE_UNITY_COLLECTIONS_CHECKS AtomicSafetyHandle . CheckReadAndThrow ( _safety ) ; endif bounds . Clamp ( _data -> WorldBounds ) ; CalculStartEndIterationInternal ( _data , bounds , out var start , out var end ) ; var hashMapUnic = new NativeHashMap < int , byte > ( 64 , Allocator . Temp ) ; var hashPosition = new int3 ( 0F ) ; for ( int x = start . x ; x < end . x ; ++ x ) { hashPosition . x = x ; for ( int y = start . y ; y < end . y ; ++ y ) { hashPosition . y = y ; for ( int z = start . z ; z < end . z ; ++ z ) { hashPosition . z = z ; var hash = Hash ( hashPosition ) ; if ( _buckets . TryGetFirstValue ( hash , out var item , out var it ) ) do hashMapUnic . TryAdd ( item , 0 ) ; while ( _buckets . TryGetNextValue ( out item , ref it ) ) ; } } } ExtractValueFromHashMap ( hashMapUnic , bounds , resultList ) ; }
Query system to find object in .
Query system to find object in .
bounds
Bounds
resultList
NativeList<T>