Exemple #1
0
    public void NotifyObjectMove(IUKSpatialObject o, Vector3 oldPosition)
    {
        Profiler.BeginSample("NotifyObjectMove");

        var size = Vector3.one * o.SpatialRadius() * 2f;
        var b0 = ExtendBountToCells(new Bounds(oldPosition, size));
        var b1 = ExtendBountToCells(new Bounds(o.SpatialPosition(), size));

        var dc = Vector3.Distance(b0.center, b1.center);
        var ds = Vector3.Distance(b0.size, b1.size);

        if (dc < Mathf.Epsilon && ds < Mathf.Epsilon) {
            Profiler.EndSample();
            return;
        }

        foreach(var h in EnumHashsOfBounds(new Bounds(oldPosition, Vector3.one * o.SpatialRadius() * 2f))) {
            EnsureHash(h);
            var l = spatialHashTable[h];
            l.Remove(o);
        }

        AddObject(o);

        Profiler.EndSample();
    }
Exemple #2
0
    public void AddObject(IUKSpatialObject o)
    {
        Profiler.BeginSample("AddObject");

        foreach(var h in EnumHashsOfBounds(o.SpatialBounds())) {
            EnsureHash(h);
            var l = spatialHashTable[h];
            if (!l.ContainsKey(o)) l.Add(o, h);
        }

        Profiler.EndSample();
    }
Exemple #3
0
    public void AddObject(IUKSpatialObject o)
    {
        Profiler.BeginSample("AddObject");

        int index = CalculateIndex(o.SpatialPosition());
        if (index >= 0) {
            EnsureIndex(index);
            var l = grid[index];
            if (!l.ContainsKey(o)) l.Add(o, index);
        } else {
            if (!overlap.ContainsKey(o)) overlap.Add(o, -1);
        }

        Profiler.EndSample();
    }
Exemple #4
0
    public void NotifyObjectMove(IUKSpatialObject o, Vector3 oldPosition)
    {
        Profiler.BeginSample("NotifyObjectMove");

        int oldIndex = CalculateIndex(oldPosition);
        int newIndex = CalculateIndex(o.SpatialPosition());
        if (oldIndex == newIndex) {
            Profiler.EndSample();
            return;
        }

        if (oldIndex >= 0) {
            EnsureIndex(oldIndex);
            var l = grid[oldIndex];
            l.Remove(o);
        } else {
            overlap.Remove(o);
        }

        AddObject(o);

        Profiler.EndSample();
    }
Exemple #5
0
    public void RemoveObject(IUKSpatialObject o)
    {
        Profiler.BeginSample("RemoveObject");

        foreach(var h in EnumHashsOfBounds(o.SpatialBounds())) {
            EnsureHash(h);
            var l = spatialHashTable[h];
            l.Remove(o);
        }

        Profiler.EndSample();
    }
 public void RemoveObject(IUKSpatialObject o)
 {
     Objects.Remove(o);
 }
 public void NotifyObjectMove(IUKSpatialObject o, Vector3 oldPosition)
 {
 }
 public void AddObject(IUKSpatialObject o)
 {
     Objects.Add(o);
 }
Exemple #9
0
    public void RemoveObject(IUKSpatialObject o)
    {
        Profiler.BeginSample("RemoveObject");

        int index = CalculateIndex(o.SpatialPosition());
        if (index >= 0) {
            EnsureIndex(index);
            var l = grid[index];
            l.Remove(o);
        } else {
            overlap.Remove(o);
        }

        Profiler.EndSample();
    }