private IMyModule CalculateCellDensityFunction(ref Vector3I cell)
        {
            List<IMyModule> densFunctions = new List<IMyModule>();

            foreach (IMyAsteroidFieldDensityFunction func in m_densityFunctions)
                if (func.ExistsInCell(ref cell))
                    densFunctions.Add(func);

            if (densFunctions.Count == 0)
            {
                return null;
            }

            int functionsCount = densFunctions.Count;
            while (functionsCount != 1)
            {
                for (int i = 0; i < functionsCount / 2; ++i)
                    densFunctions[i] = new MyMax(densFunctions[i * 2], densFunctions[i * 2 + 1]);

                if (functionsCount % 2 == 1)
                    densFunctions[functionsCount - 1] = densFunctions[functionsCount / 2];

                functionsCount = functionsCount / 2 + functionsCount % 2;
            }

            return densFunctions[0];
        }
        protected IMyModule GetCellDensityFunctionFilled(BoundingBoxD bbox)
        {
            foreach (IMyAsteroidFieldDensityFunction func in m_densityFunctionsFilled)
                if (func.ExistsInCell(ref bbox))
                    tmpDensityFunctions.Add(func);

            if (tmpDensityFunctions.Count == 0)
            {
                return null;
            }

            int functionsCount = tmpDensityFunctions.Count;
            while (functionsCount > 1)
            {
                for (int i = 0; i < functionsCount / 2; ++i)
                    tmpDensityFunctions[i] = new MyMax(tmpDensityFunctions[i * 2], tmpDensityFunctions[i * 2 + 1]);

                if (functionsCount % 2 == 1)
                    tmpDensityFunctions[functionsCount - 1] = tmpDensityFunctions[functionsCount / 2];

                functionsCount = functionsCount / 2 + functionsCount % 2;
            }

            IMyModule ret = tmpDensityFunctions[0];

            tmpDensityFunctions.Clear();

            return ret;
        }