public InFrustumCheck CubeInFrustum(TerrainPatch patch)
        {
            //return InFrustumCheck.IN;
            int totalIn = 0;

            // Test all 6 sides against all 8 corners
            for (int s = 0; s < 6; s++)
            {
                int inCount = 8;
                int cIn     = 1;
                for (int c = 0; c < 8; c++)
                {
                    // test corner against all planes
                    if (FrustumModel[s, (int)PlaneData.A] * patch.BoundingBoxV[c].X + FrustumModel[s, (int)PlaneData.B] * patch.BoundingBoxV[c].Y + FrustumModel[s, (int)PlaneData.C] * patch.BoundingBoxV[c].Z + FrustumModel[s, (int)PlaneData.D] < 0)
                    {
                        cIn = 0;
                        inCount--;
                    }

                    // if all points where outside, return false
                    if (inCount == 0)
                    {
                        return(InFrustumCheck.OUT);
                    }

                    // check if all points where on the right side of the plane
                    totalIn += cIn;
                }
            }
            // if all points where inside, return true
            if (totalIn == 6)
            {
                return(InFrustumCheck.IN);
            }
            // at this point the cube must be partly inside
            return(InFrustumCheck.INTERSECT);
        }
        public InFrustumCheck CubeInFrustum(TerrainPatch patch)
        {
            //return InFrustumCheck.IN;
            int totalIn = 0;
            // Test all 6 sides against all 8 corners
            for (int s = 0; s < 6; s++)
            {
                int inCount = 8;
                int cIn = 1;
                for (int c = 0; c < 8; c++)
                {
                    // test corner against all planes
                    if (FrustumModel[s, (int)PlaneData.A] * patch.BoundingBoxV[c].X + FrustumModel[s, (int)PlaneData.B] * patch.BoundingBoxV[c].Y + FrustumModel[s, (int)PlaneData.C] * patch.BoundingBoxV[c].Z + FrustumModel[s, (int)PlaneData.D] < 0)
                    {
                        cIn = 0;
                        inCount--;
                    }

                    // if all points where outside, return false
                    if (inCount == 0) { return InFrustumCheck.OUT; }

                    // check if all points where on the right side of the plane
                    totalIn += cIn;
                }
            }
            // if all points where inside, return true
            if (totalIn == 6) { return InFrustumCheck.IN; }
            // at this point the cube must be partly inside
            return InFrustumCheck.INTERSECT;
        }