BEPUphysics.DataStructures.MeshBoundingBoxTree.GetOverlaps C# (CSharp) Метод

GetOverlaps() публичный Метод

Gets the triangles whose bounding boxes are overlapped by the query.
public GetOverlaps ( Microsoft.Xna.Framework.BoundingBox boundingBox, IList outputOverlappedElements ) : bool
boundingBox Microsoft.Xna.Framework.BoundingBox Shape to query against the tree.
outputOverlappedElements IList Indices of triangles in the index buffer with bounding boxes which are overlapped by the query.
Результат bool
        public bool GetOverlaps(BoundingBox boundingBox, IList<int> outputOverlappedElements)
        {
            if (root != null)
            {
                bool intersects;
                root.BoundingBox.Intersects(ref boundingBox, out intersects);
                if (intersects)
                    root.GetOverlaps(ref boundingBox, outputOverlappedElements);
            }
            return outputOverlappedElements.Count > 0;
        }

Same methods

MeshBoundingBoxTree::GetOverlaps ( BoundingFrustum boundingFrustum, IList outputOverlappedElements ) : bool
MeshBoundingBoxTree::GetOverlaps ( BoundingSphere boundingSphere, IList outputOverlappedElements ) : bool
MeshBoundingBoxTree::GetOverlaps ( Microsoft.Xna.Framework.Ray ray, IList outputOverlappedElements ) : bool
MeshBoundingBoxTree::GetOverlaps ( Microsoft.Xna.Framework.Ray ray, float maximumLength, IList outputOverlappedElements ) : bool

Usage Example

Пример #1
0
        ///<summary>
        /// Tests a ray against the triangle mesh.
        ///</summary>
        ///<param name="ray">Ray to test against the mesh.</param>
        /// <param name="maximumLength">Maximum length of the ray in units of the ray direction's length.</param>
        /// <param name="sidedness">Sidedness to apply to the mesh for the ray cast.</param>
        ///<param name="hits">Hit data for the ray, if any.</param>
        ///<returns>Whether or not the ray hit the mesh.</returns>
        public bool RayCast(Ray ray, float maximumLength, TriangleSidedness sidedness, IList <RayHit> hits)
        {
            var hitElements = Resources.GetIntList();

            tree.GetOverlaps(ray, maximumLength, hitElements);
            for (int i = 0; i < hitElements.Count; i++)
            {
                Vector3 v1, v2, v3;
                data.GetTriangle(hitElements[i], out v1, out v2, out v3);
                RayHit hit;
                if (Toolbox.FindRayTriangleIntersection(ref ray, maximumLength, sidedness, ref v1, ref v2, ref v3, out hit))
                {
                    hits.Add(hit);
                }
            }
            Resources.GiveBack(hitElements);
            return(hits.Count > 0);
        }