コード例 #1
0
ファイル: OctreeBranch.cs プロジェクト: Tamschi/MarsMiner
        protected virtual Cuboid FindDimensionsOfChild(OctreeNode <T> child)
        {
            Octant oct  = FindOctantOfChild(child);
            Cuboid dims = Parent.FindDimensionsOfChild(this);

            int size = dims.Width >> 1;

            return(new Cuboid(dims.X + oct.X * size, dims.Y + oct.Y * size, dims.Z + oct.Z * size, size));
        }
コード例 #2
0
ファイル: Cuboid.cs プロジェクト: Tamschi/MarsMiner
        public override bool Equals(object obj)
        {
            if (obj is Cuboid)
            {
                Cuboid cuboid = (Cuboid)obj;
                return(X == cuboid.X && Y == cuboid.Y && Z == cuboid.Z &&
                       Width == cuboid.Width && Height == cuboid.Height && Depth == cuboid.Depth);
            }

            return(false);
        }
コード例 #3
0
ファイル: Cuboid.cs プロジェクト: Tamschi/MarsMiner
        public Cuboid FindIntersection(Cuboid cuboid)
        {
            if (!IsIntersecting(cuboid))
            {
                throw new InvalidOperationException();
            }

            int left   = Math.Max(Left, cuboid.Left);
            int bottom = Math.Max(Bottom, cuboid.Bottom);
            int front  = Math.Max(Front, cuboid.Front);

            int right = Math.Min(Right, cuboid.Right);
            int top   = Math.Min(Top, cuboid.Top);
            int back  = Math.Min(Back, cuboid.Back);

            return(new Cuboid(left, bottom, front, right - left, top - bottom, back - front));
        }
コード例 #4
0
ファイル: OctreeBranch.cs プロジェクト: Tamschi/MarsMiner
        internal override void SetCuboid(int size, Cuboid cuboid, T value)
        {
            if (cuboid.IsIntersecting(size))
            {
                Cuboid i = cuboid.FindIntersection(size);
                if (i.X == 0 && i.Y == 0 && i.Z == 0 &&
                    i.Width == i.Height && i.Height == i.Depth && i.Depth == size && ShouldMerge())
                {
                    Merge(value);
                }
                else if (i.Volume != 0)
                {
                    int h = size >> 1;

                    foreach (Octant oct in Octant.All)
                    {
                        Cuboid sub = new Cuboid(i.X - oct.X * h, i.Y - oct.Y * h, i.Z - oct.Z * h,
                                                i.Width, i.Height, i.Depth);
                        this[oct].SetCuboid(h, sub, value);
                    }
                }
            }
        }
コード例 #5
0
 internal virtual void SetCuboid(int size, Cuboid cuboid, T value)
 {
     throw new NotImplementedException();
 }
コード例 #6
0
ファイル: Cuboid.cs プロジェクト: Tamschi/MarsMiner
 public bool IsIntersecting(Cuboid cuboid)
 {
     return(cuboid.Left <= Right && cuboid.Right >= Left &&
            cuboid.Bottom <= Top && cuboid.Top >= Bottom &&
            cuboid.Front <= Back && cuboid.Back >= Front);
 }