コード例 #1
0
            public bool Set(Boxl bounds, Point3l point, T value)
            {
                if (value.Equals(Value) && (Children == null || bounds.Size == Size3i.Unit))
                {
                    return(false);
                }
                else if (bounds.Size == Size3i.Unit)
                {
                    Value = value;
                    return(true);
                }
                else
                {
                    Split();

                    var center = bounds.Center;
                    int index  = 0;
                    index |= point.X < center.X ? 0 : 1;
                    index |= point.Y < center.Y ? 0 : 2;
                    index |= point.Z < center.Z ? 0 : 4;

                    bool sparse = Children[index].Set(Subbounds(index, bounds, bounds.Size / 2), point, value);

                    if (sparse)
                    {
                        return(Sparsen());
                    }
                    return(false);
                }
            }
コード例 #2
0
 public CompressedVoxelVolume(Boxl bounds)
 {
     Bounds       = bounds;
     Compressed   = new CompressedList <T>();
     Uncompressed = null;
     Fill(default(T));
 }
コード例 #3
0
            public bool Sparsen(Boxl bounds)
            {
                if (Children == null || bounds.Size == Size3i.Unit)
                {
                    return(true);
                }

                Size3l size = bounds.Size / 2;

                bool sparsen = true;

                sparsen &= Children[0].Sparsen(Subbounds(0, bounds, size));
                sparsen &= Children[1].Sparsen(Subbounds(1, bounds, size));
                sparsen &= Children[2].Sparsen(Subbounds(2, bounds, size));
                sparsen &= Children[3].Sparsen(Subbounds(3, bounds, size));
                sparsen &= Children[4].Sparsen(Subbounds(4, bounds, size));
                sparsen &= Children[5].Sparsen(Subbounds(5, bounds, size));
                sparsen &= Children[6].Sparsen(Subbounds(6, bounds, size));
                sparsen &= Children[7].Sparsen(Subbounds(7, bounds, size));

                if (sparsen)
                {
                    return(Sparsen());
                }

                return(false);
            }
コード例 #4
0
            private Boxl Subbounds(int index, Boxl bounds, Size3l size)
            {
                long x = (index & 1) == 0 ? 0 : size.Width;
                long y = (index & 2) == 0 ? 0 : size.Height;
                long z = (index & 4) == 0 ? 0 : size.Depth;

                return(new Boxl(bounds.X + x, bounds.Y + y, bounds.Z + z, size));
            }
コード例 #5
0
        public OctreeVoxelVolume(Boxl bounds)
        {
            Contract.Requires(Functions.IsPowerOf2(bounds.Width));
            Contract.Requires(Functions.IsPowerOf2(bounds.Height));
            Contract.Requires(Functions.IsPowerOf2(bounds.Depth));
            Contract.Requires(bounds.Width == bounds.Height && bounds.Height == bounds.Depth);

            Bounds = bounds;
        }
コード例 #6
0
            public T Get(Boxl bounds, Point3l point)
            {
                if (Children == null)
                {
                    return(Value);
                }
                else
                {
                    var center = bounds.Center;
                    int index  = 0;
                    index |= point.X < center.X ? 0 : 1;
                    index |= point.Y < center.Y ? 0 : 2;
                    index |= point.Z < center.Z ? 0 : 4;

                    return(Children[index].Get(Subbounds(index, bounds, bounds.Size / 2), point));
                }
            }
コード例 #7
0
ファイル: DenseVoxelVolume.cs プロジェクト: bonomali/Ibasa
 public DenseVoxelVolume(Boxl bounds)
 {
     Bounds = bounds;
     Volume = new T[Bounds.Width * Bounds.Height * Bounds.Depth];
 }