示例#1
0
        public SparseVoxelTree(Point3 Min, Point3 Max, int Voxel)
        {
            Bounds       = new IntegerBoundingBox(Min, Max);
            Bounds.Max.X = Bounds.Min.X + NextPowerOfTwo(Bounds.Width);
            Bounds.Max.Y = Bounds.Min.Y + NextPowerOfTwo(Bounds.Height);
            Bounds.Max.Z = Bounds.Min.Z + NextPowerOfTwo(Bounds.Depth);

            Mid = new Point3(Min.X + Bounds.Width / 2, Min.Y + Bounds.Height / 2, Min.Z + Bounds.Depth / 2);

            this.Voxel = Voxel;

            if (Bounds.Width == 2 && Bounds.Height == 2 && Bounds.Depth == 2)
            {
                RawBuffer = new int[2, 2, 2];

                for (var x = 0; x < 2; ++x)
                {
                    for (var y = 0; y < 2; ++y)
                    {
                        for (var z = 0; z < 2; ++z)
                        {
                            RawBuffer[x, y, z] = Voxel;
                        }
                    }
                }
            }
        }
示例#2
0
 public bool Intersects(IntegerBoundingBox Other)
 {
     if (Min.X > Other.Max.X || Max.X <= Other.Min.X)
     {
         return(false);
     }
     if (Min.Y > Other.Max.Y || Max.Y <= Other.Min.Y)
     {
         return(false);
     }
     if (Min.Z > Other.Max.Z || Max.Z <= Other.Min.Z)
     {
         return(false);
     }
     return(true);
 }