Esempio n. 1
0
 public float CollideWithRay(Vector3 origin, Vector3 direction, float maxDistance, ref RaycastStats stats)
 {
     Matrix4x4.Invert(Transformation, out var invMatrix);
     origin    = Vector3.Transform(origin, invMatrix);
     direction = Vector3.TransformNormal(direction, invMatrix);
     return(new AABoundingBox(-HalfExtents, HalfExtents).CollideWithRay(origin, direction, maxDistance, ref stats));
 }
Esempio n. 2
0
 public float CollideWithRay(Vector3 origin, Vector3 direction, float maxDistance, ref RaycastStats stats)
 {
     stats.nbAABBTests += 1;
     return(CollideWithRay(origin, direction, maxDistance));
 }
Esempio n. 3
0
        public float CollideWithRay(Vector3 origin, Vector3 direction, float maxDistance)
        {
            RaycastStats stats = new RaycastStats();

            return(CollideWithRay(origin, direction, maxDistance, ref stats));
        }
Esempio n. 4
0
        public float CollideWithRay(Vector3 origin, Vector3 direction, float maxDistance, ref RaycastStats stats)
        {
            stats.nbNodeTests += 1;
            var dist = Box.CollideWithRay(origin, direction, maxDistance, ref stats);

            if (dist >= maxDistance)
            {
                return(maxDistance);
            }

            dist = maxDistance;
            if (Nodes != null)
            {
                foreach (var node in Nodes)
                {
                    dist = Math.Min(dist, node.CollideWithRay(origin, direction, dist, ref stats));
                }
            }
            if (Objects != null)
            {
                foreach (var obj in Objects)
                {
                    dist = Math.Min(dist, obj.CollideWithRay(origin, direction, dist, ref stats));
                }
            }
            return(dist);
        }