Exemplo n.º 1
0
        public override void IntersectBF(BoundingSphere ball, List <DirectDetectData> res)
        {
            Queue <AABBTreeNode> q = new Queue <AABBTreeNode>();

            q.Enqueue(this);
            while (q.Count > 0)
            {
                AABBTreeNode node = q.Dequeue();
                if (MathEx.AABBIntersects(ref node.aabb, ref ball))//(node.aAABB.Intersect(ref ball.Center, ref ball.Radius))
                {
                    if (node.children != null)
                    {
                        for (int i = 0; i < node.children.Length; i++)
                        {
                            q.Enqueue((AABBTreeNode)node.children[i]);
                        }
                    }
                    else
                    {
                        DirectDetectData data;
                        Triangle         face = (Triangle)node.faceData;
                        if (MathEx.BoundingSphereIntersects(ref ball, ref face, out data.Position, out data.Normal, out data.Depth))//(ball.Intersect(ref face, out data.vPos, out data.vNormal, out data.dDepth))
                        {
                            res.Add(data);
                        }
                    }
                }
            }
            q.Clear();
        }
Exemplo n.º 2
0
 public override void IntersectDF(ref LineSegment ra, List <DirectDetectData> res)
 {
     if (children != null)
     {
         if (MathEx.AABBIntersects(ref aabb, ref ra.Start, ref ra.End))//aAABB.Intersect(ra.vStart, ra.vEnd))
         {
             for (int i = 0; i < children.Length; i++)
             {
                 children[i].IntersectDF(ref ra, res);
             }
         }
     }
     else
     {
         //if (aAABB.Intersect(ra.vStart, ra.vEnd))
         //{
         Vector3  pos;
         Triangle face = (Triangle)faceData;
         if (face.RayTriCollision(out pos, ref ra.Start, ref ra.End))
         {
             res.Add(new DirectDetectData(pos, face.vN, 0));
         }
         //}
     }
 }
Exemplo n.º 3
0
 public override void IntersectDF(ref Triangle t, List <DirectDetectData> res)
 {
     if (MathEx.AABBIntersects(ref aabb, ref t))//aAABB.Intersect(ref t))
     {
         if (children != null)
         {
             for (int i = 0; i < children.Length; i++)
             {
                 children[i].IntersectDF(ref t, res);
             }
         }
         else
         {
             List <DirectDetectData> data;
             Triangle face = (Triangle)faceData;
             if (Triangle.TriangleIntersect(ref t, ref face, out data))
             {
                 for (int j = 0; j < data.Count; j++)
                 {
                     res.Add(data[j]);
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
 public override void IntersectDF(AABBTreeNode cdTree, List <DirectDetectData> res)
 {
     //if (aAABB.Intersect(cdTree.aAABB))
     if (children != null)
     {
         for (int i = 0; i < children.Length; i++)
         {
             AABBTreeNode ch = (AABBTreeNode)children[i];
             if (MathEx.AABBIntersects(ref cdTree.aabb, ref ch.aabb)) //(cdTree.aAABB.Intersect(ref ch.aAABB))
             {
                 cdTree.IntersectDF(ch, res);                         //相互遍历
             }
         }
     }
     else
     {
         Triangle t = (Triangle)faceData;
         cdTree.IntersectDF(ref t, res);
     }
 }
Exemplo n.º 5
0
 public override void SearchDF(ref BoundingBox aabb, List <Triangle> res)
 {
     if (MathEx.AABBIntersects(ref aabb, ref aabb))// aAABB.Intersect(ref aabb))
     {
         if (children != null)
         {
             for (int i = 0; i < children.Length; i++)
             {
                 children[i].SearchDF(ref aabb, res);
             }
         }
         else
         {
             Triangle t = (Triangle)faceData;
             //if (aabb.Intersect(ref t)) res.Add(t);
             if (MathEx.AABBIntersects(ref aabb, ref t))
             {
                 res.Add(t);
             }
         }
     }
 }
Exemplo n.º 6
0
        public override void IntersectDF(ref BoundingSphere ball, List <DirectDetectData> res)
        {
            if (MathEx.AABBIntersects(ref aabb, ref ball))// aAABB.Intersect(ref ball.Center, ref ball.Radius))
            {
                if (children != null)
                {
                    for (int i = 0; i < children.Length; i++)
                    {
                        children[i].IntersectDF(ref ball, res);
                    }
                }
                else
                {
                    DirectDetectData data;
                    Triangle         face = (Triangle)faceData;
                    if (MathEx.BoundingSphereIntersects(ref ball, ref face, out data.Position, out data.Normal, out data.Depth))//(ball.Intersect(ref face, out data.vPos, out data.vNormal, out data.dDepth))
                    {
                        res.Add(data);
                    }

                    //Simulation.PhysMT.testtest2++;
                }
            }
        }