コード例 #1
0
 /// <summary>
 /// Recursive method which casts a ray against 'node' and moves down the
 /// hierarchy towards the terminal nodes and stores any hits between the
 /// ray and these nodes inside 'hitList'.
 /// </summary>
 private void RaycastAllRecurse(Ray ray, SphereTreeNode <T> node, List <SphereTreeNodeRayHit <T> > hitList)
 {
     // Is this a terminal node?
     if (!node.IsFlagBitSet(BVHNodeFlags.Terminal))
     {
         // This is not a terminal node. We will check if the ray intersects the node's
         // sphere and if it does, we will go further down the hierarchy. If it doesn't
         // then there is no need to go on because if the ray does not intersect the node,
         // it can't possibly intersect any of its children.
         if (SphereMath.Raycast(ray, node.Center, node.Radius))
         {
             List <SphereTreeNode <T> > children = node.Children;
             foreach (var child in children)
             {
                 RaycastAllRecurse(ray, child, hitList);
             }
         }
     }
     else
     {
         // This is a terminal node and if the ray intersects this node, we will add the
         // node hit information inside the hit list.
         float t;
         if (SphereMath.Raycast(ray, out t, node.Center, node.Radius))
         {
             var nodeHit = new SphereTreeNodeRayHit <T>(ray, node, t);
             hitList.Add(nodeHit);
         }
     }
 }
コード例 #2
0
        public static bool Raycast(Ray ray, out float t, Vector3 startPoint, Vector3 endPoint, SegmentEpsilon epsilon = new SegmentEpsilon())
        {
            if (CylinderMath.Raycast(ray, out t, startPoint, endPoint, epsilon.RaycastEps))
            {
                return(true);
            }

            if (SphereMath.Raycast(ray, out t, startPoint, epsilon.RaycastEps))
            {
                return(true);
            }
            return(SphereMath.Raycast(ray, out t, endPoint, epsilon.RaycastEps));
        }
コード例 #3
0
 public List <Vector3> GetRightUpExtents(Vector3 right, Vector3 up)
 {
     return(SphereMath.CalcRightUpExtents(_center, _radius, right, up));
 }
コード例 #4
0
 public bool ContainsPoint(Vector3 point)
 {
     return SphereMath.ContainsPoint(point, _center, _radius, _epsilon);
 }
コード例 #5
0
 public override bool Raycast(Ray ray, out float t)
 {
     return SphereMath.Raycast(ray, out t, _center, _radius, _epsilon);
 }