Пример #1
0
 /// <summary>
 /// </summary>
 /// <param name="creationFunc">
 /// </param>
 /// <param name="maxBlockCapacity">
 /// </param>
 /// <param name="maxDepth">
 /// </param>
 public Octree(Action <T, OctreeBlock <T> > creationFunc, int maxBlockCapacity = 64, int maxDepth = 2)
 {
     this.maxDepth          = maxDepth;
     this._maxBlockCapacity = maxBlockCapacity;
     this._selectionContent = new SmartArray <T>(1024);
     this._creationFunc     = creationFunc;
 }
Пример #2
0
        /// <summary>
        /// </summary>
        /// <param name="frustumPlanes">
        /// </param>
        /// <param name="selection">
        /// </param>
        /// <param name="allowDuplicate">
        /// </param>
        public virtual void select(Array <Plane> frustumPlanes, SmartArray <T> selection, bool allowDuplicate = false)
        {
            if (BoundingBox.IsInFrustum(this._boundingVectors, frustumPlanes))
            {
                if (this.blocks != null)
                {
                    for (var index = 0; index < this.blocks.Length; index++)
                    {
                        var block = this.blocks[index];
                        block.select(frustumPlanes, selection, allowDuplicate);
                    }

                    return;
                }

                if (allowDuplicate)
                {
                    selection.Append(this.entries);
                }
                else
                {
                    selection.concatWithNoDuplicate(this.entries);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// </summary>
        /// <param name="sphereCenter">
        /// </param>
        /// <param name="sphereRadius">
        /// </param>
        /// <param name="selection">
        /// </param>
        /// <param name="allowDuplicate">
        /// </param>
        public virtual void intersects(Vector3 sphereCenter, double sphereRadius, SmartArray <T> selection, bool allowDuplicate = false)
        {
            if (BoundingBox.IntersectsSphere(this._minPoint, this._maxPoint, sphereCenter, sphereRadius))
            {
                if (this.blocks != null)
                {
                    for (var index = 0; index < this.blocks.Length; index++)
                    {
                        var block = this.blocks[index];
                        block.intersects(sphereCenter, sphereRadius, selection, allowDuplicate);
                    }

                    return;
                }

                if (allowDuplicate)
                {
                    selection.Append(this.entries);
                }
                else
                {
                    selection.concatWithNoDuplicate(this.entries);
                }
            }
        }
Пример #4
0
        /// <summary>
        /// </summary>
        /// <param name="ray">
        /// </param>
        /// <param name="selection">
        /// </param>
        public virtual void intersectsRay(Ray ray, SmartArray <T> selection)
        {
            if (ray.intersectsBoxMinMax(this._minPoint, this._maxPoint))
            {
                if (this.blocks != null)
                {
                    for (var index = 0; index < this.blocks.Length; index++)
                    {
                        var block = this.blocks[index];
                        block.intersectsRay(ray, selection);
                    }

                    return;
                }

                selection.concatWithNoDuplicate(this.entries);
            }
        }