Exemplo n.º 1
0
        /// <summary>
        /// Attempts to add the new model.
        /// </summary>
        /// <param name="capi">The core client API</param>
        /// <param name="modeldata">The model to add</param>
        /// <param name="modelOrigin">The origin point of the model.</param>
        /// <param name="frustumCullSphere">The culling sphere.</param>
        /// <returns>The location of the model (and the data) in the pool.</returns>
        public ModelDataPoolLocation TryAdd(ICoreClientAPI capi, MeshData modeldata, Vec3i modelOrigin, Sphere frustumCullSphere)
        {
            if (poolLocations.Count >= MaxPartsPerPool)
            {
                return(null);
            }

            // Can't add a model data to far away from our baseposition, otherwise our floating point positions
            // become too inaccurate
            if (poolOrigin != null && modelOrigin.SquareDistanceTo(poolOrigin) > 5000 * 5000)
            {
                return(null);
            }

            if (CurrentFragmentation > 0.05f)
            {
                ModelDataPoolLocation location = TrySqueezeInbetween(capi, modeldata, modelOrigin, frustumCullSphere);
                if (location != null)
                {
                    return(location);
                }
            }

            return(TryAppend(capi, modeldata, modelOrigin, frustumCullSphere));
        }