예제 #1
0
        public static bool SphereCast(Fix64Vec3 start, Fix64 radius, Fix64Vec3 movement, int mask, ref PShapecastHit3D shapeCastHit3D)
        {
            if (!initialized)
            {
                Initialize();
            }

            if (movement.Length() < ParallelConstants.SMALLEST_RAYCAST_RANGE)
            {
                //Debug.Log("ShapeCast range too short");
                return(false);
            }

            Fix64Vec3 point    = Fix64Vec3.zero;
            Fix64Vec3 normal   = Fix64Vec3.zero;
            Fix64     fraction = Fix64.one;
            UInt16    bodyID   = 0;

            bool hit = NativeParallel3D.SphereCast(internalWorld.IntPointer, mask, start, radius, movement, ref point, ref normal, ref fraction, ref bodyID);

            if (hit)
            {
                shapeCastHit3D.point    = point;
                shapeCastHit3D.normal   = normal;
                shapeCastHit3D.fraction = fraction;

                if (bodyDictionary.ContainsKey(bodyID))
                {
                    shapeCastHit3D.rigidbody = bodyDictionary[bodyID].RigidBody;
                }
                else
                {
                    Debug.LogError($"Rigibody not found: {bodyID}");
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
 public static bool SphereCast(Fix64Vec3 start, Fix64 radius, Fix64Vec3 movement, ref PShapecastHit3D shapeCastHit3D)
 {
     return(SphereCast(start, radius, movement, -1, ref shapeCastHit3D));
 }