コード例 #1
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
        /// <summary>
        /// Performs a sweep into the scene using a box and returns the closest found hit, if any.
        /// </summary>
        /// <param name="box">Box to sweep through the scene.</param>
        /// <param name="rotation">Orientation of the box.</param>
        /// <param name="unitDir">Unit direction towards which to perform the sweep.</param>
        /// <param name="hit">Information recorded about a hit. Only valid if method returns true.</param>
        /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.
        ///                     </param>
        /// <param name="max">Maximum distance at which to perform the query. Hits past this distance will not be detected.
        ///                   </param>
        /// <returns>True if something was hit, false otherwise.</returns>
        public static bool BoxCast(AABox box, Quaternion rotation, Vector3 unitDir, out PhysicsQueryHit hit,
            ulong layer = ulong.MaxValue, float max = float.MaxValue)
        {
            ScriptPhysicsQueryHit scriptHit = new ScriptPhysicsQueryHit();
            if(Internal_BoxCast(ref box, ref rotation, ref unitDir, out scriptHit, layer, max))
            {
                ConvertPhysicsQueryHit(ref scriptHit, out hit);
                return true;
            }

            hit = new PhysicsQueryHit();
            return false;
        }
コード例 #2
0
        /// <summary>Initializes the struct with default values.</summary>
        public static PhysicsQueryHit Default()
        {
            PhysicsQueryHit value = new PhysicsQueryHit();

            value.point       = new Vector3();
            value.normal      = new Vector3();
            value.uv          = new Vector2();
            value.distance    = 0f;
            value.triangleIdx = 0;
            value.collider    = null;

            return(value);
        }
コード例 #3
0
ファイル: Collider.cs プロジェクト: Ruu/BansheeEngine
        /// <summary>
        /// Checks does the ray hit this collider. 
        /// </summary>
        /// <param name="origin">Origin of the ray to check.</param>
        /// <param name="unitDir">Unit direction of the ray to check.</param>
        /// <param name="hit">Information about the hit. Valid only if the method returns true.</param>
        /// <param name="maxDist">Maximum distance from the ray origin to search for hits.</param>
        /// <returns>True if the ray has hit the collider.</returns>
        public bool Raycast(Vector3 origin, Vector3 unitDir, out PhysicsQueryHit hit, float maxDist = float.MaxValue)
        {
            hit = new PhysicsQueryHit();

            if (native == null)
                return false;

            ScriptPhysicsQueryHit scriptHit;
            bool wasHit = native.Raycast(origin, unitDir, out scriptHit, maxDist);

            hit.collider = scriptHit.collider.Component;
            hit.distance = scriptHit.distance;
            hit.normal = scriptHit.normal;
            hit.point = scriptHit.point;
            hit.triangleIdx = scriptHit.triangleIdx;
            hit.uv = scriptHit.uv;

            return wasHit;
        }
コード例 #4
0
ファイル: Collider.cs プロジェクト: Ruu/BansheeEngine
 /// <summary>
 /// Checks does the ray hit this collider. 
 /// </summary>
 /// <param name="ray">Ray to check.</param>
 /// <param name="hit">Information about the hit. Valid only if the method returns true.</param>
 /// <param name="maxDist">Maximum distance from the ray origin to search for hits.</param>
 /// <returns>True if the ray has hit the collider.</returns>
 public bool Raycast(Ray ray, out PhysicsQueryHit hit, float maxDist)
 {
     return Raycast(ray.origin, ray.direction, out hit, maxDist);
 }
コード例 #5
0
ファイル: Physics.generated.cs プロジェクト: nanze81/bsf
 /// <summary>Performs a sweep into the scene using a box and returns the closest found hit, if any.</summary>
 /// <param name="box">Box to sweep through the scene.</param>
 /// <param name="rotation">Orientation of the box.</param>
 /// <param name="unitDir">Unit direction towards which to perform the sweep.</param>
 /// <param name="hit">Information recorded about a hit. Only valid if method returns true.</param>
 /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.</param>
 /// <param name="max">
 /// Maximum distance at which to perform the query. Hits past this distance will not be detected.
 /// </param>
 /// <returns>True if something was hit, false otherwise.</returns>
 public static bool BoxCast(AABox box, Quaternion rotation, Vector3 unitDir, out PhysicsQueryHit hit, ulong layer = 18446744073709551615, float max = 3.40282347E+38f)
 {
     return(Internal_boxCast(ref box, ref rotation, ref unitDir, out hit, layer, max));
 }
コード例 #6
0
ファイル: Physics.generated.cs プロジェクト: nanze81/bsf
 /// <summary>Performs a sweep into the scene using a capsule and returns the closest found hit, if any.</summary>
 /// <param name="capsule">Capsule to sweep through the scene.</param>
 /// <param name="rotation">Orientation of the capsule.</param>
 /// <param name="unitDir">Unit direction towards which to perform the sweep.</param>
 /// <param name="hit">Information recorded about a hit. Only valid if method returns true.</param>
 /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.</param>
 /// <param name="max">
 /// Maximum distance at which to perform the query. Hits past this distance will not be detected.
 /// </param>
 /// <returns>True if something was hit, false otherwise.</returns>
 public static bool CapsuleCast(Capsule capsule, Quaternion rotation, Vector3 unitDir, out PhysicsQueryHit hit, ulong layer = 18446744073709551615, float max = 3.40282347E+38f)
 {
     return(Internal_capsuleCast(ref capsule, ref rotation, ref unitDir, out hit, layer, max));
 }
コード例 #7
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
        /// <summary>
        /// Converts all provided physics query hit infos retrieved from native code into managed physics query hits.
        /// </summary>
        /// <param name="scriptHits">Native physics query hits.</param>
        /// <returns>Converted managed physics query hits.</returns>
        private static PhysicsQueryHit[] ConvertPhysicsQueryHits(ScriptPhysicsQueryHit[] scriptHits)
        {
            PhysicsQueryHit[] output = new PhysicsQueryHit[scriptHits.Length];

            for (int i = 0; i < scriptHits.Length; i++)
                ConvertPhysicsQueryHit(ref scriptHits[i], out output[i]);

            return output;
        }
コード例 #8
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
        /// <summary>
        /// Performs a sweep into the scene using a sphere and returns the closest found hit, if any.
        /// </summary>
        /// <param name="sphere">Sphere to sweep through the scene.</param>
        /// <param name="unitDir">Unit direction towards which to perform the sweep.</param>
        /// <param name="hit">Information recorded about a hit. Only valid if method returns true.</param>
        /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.
        ///                     </param>
        /// <param name="max">Maximum distance at which to perform the query. Hits past this distance will not be detected.
        ///                   </param>
        /// <returns>True if something was hit, false otherwise.</returns>
        public static bool SphereCast(Sphere sphere, Vector3 unitDir, out PhysicsQueryHit hit,
            ulong layer = ulong.MaxValue, float max = float.MaxValue)
        {
            ScriptPhysicsQueryHit scriptHit = new ScriptPhysicsQueryHit();
            if(Internal_SphereCast(ref sphere, ref unitDir, out scriptHit, layer, max))
            {
                ConvertPhysicsQueryHit(ref scriptHit, out hit);
                return true;
            }

            hit = new PhysicsQueryHit();
            return false;
        }
コード例 #9
0
ファイル: Physics.generated.cs プロジェクト: nanze81/bsf
 private static extern bool Internal_capsuleCast(ref Capsule capsule, ref Quaternion rotation, ref Vector3 unitDir, out PhysicsQueryHit hit, ulong layer, float max);
コード例 #10
0
ファイル: Physics.generated.cs プロジェクト: nanze81/bsf
 private static extern bool Internal_sphereCast(ref Sphere sphere, ref Vector3 unitDir, out PhysicsQueryHit hit, ulong layer, float max);
コード例 #11
0
ファイル: Physics.generated.cs プロジェクト: nanze81/bsf
 private static extern bool Internal_boxCast(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, out PhysicsQueryHit hit, ulong layer, float max);
コード例 #12
0
ファイル: Physics.generated.cs プロジェクト: nanze81/bsf
 private static extern bool Internal_rayCast0(ref Vector3 origin, ref Vector3 unitDir, out PhysicsQueryHit hit, ulong layer, float max);
コード例 #13
0
ファイル: Physics.generated.cs プロジェクト: nanze81/bsf
 private static extern bool Internal_rayCast(ref Ray ray, out PhysicsQueryHit hit, ulong layer, float max);
コード例 #14
0
ファイル: Physics.generated.cs プロジェクト: nanze81/bsf
 /// <summary>Performs a sweep into the scene using a convex mesh and returns the closest found hit, if any.</summary>
 /// <param name="mesh">Mesh to sweep through the scene. Must be convex.</param>
 /// <param name="position">Starting position of the mesh.</param>
 /// <param name="rotation">Orientation of the mesh.</param>
 /// <param name="unitDir">Unit direction towards which to perform the sweep.</param>
 /// <param name="hit">Information recorded about a hit. Only valid if method returns true.</param>
 /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.</param>
 /// <param name="max">
 /// Maximum distance at which to perform the query. Hits past this distance will not be detected.
 /// </param>
 /// <returns>True if something was hit, false otherwise.</returns>
 public static bool ConvexCast(RRef <PhysicsMesh> mesh, Vector3 position, Quaternion rotation, Vector3 unitDir, out PhysicsQueryHit hit, ulong layer = 18446744073709551615, float max = 3.40282347E+38f)
 {
     return(Internal_convexCast(mesh, ref position, ref rotation, ref unitDir, out hit, layer, max));
 }
コード例 #15
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
        /// <summary>
        /// Performs a sweep into the scene using a convex mesh and returns the closest found hit, if any.
        /// </summary>
        /// <param name="mesh">Mesh to sweep through the scene. Must be convex.</param>
        /// <param name="position">Starting position of the mesh.</param>
        /// <param name="rotation">Orientation of the mesh.</param>
        /// <param name="unitDir">Unit direction towards which to perform the sweep.</param>
        /// <param name="hit">Information recorded about a hit. Only valid if method returns true.</param>
        /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.
        ///                     </param>
        /// <param name="max">Maximum distance at which to perform the query. Hits past this distance will not be detected.
        ///                   </param>
        /// <returns>True if something was hit, false otherwise.</returns>
        public static bool ConvexCast(PhysicsMesh mesh, Vector3 position, Quaternion rotation,
            Vector3 unitDir, out PhysicsQueryHit hit, ulong layer = ulong.MaxValue, float max = float.MaxValue)
        {
            IntPtr meshPtr = IntPtr.Zero;
            if (mesh != null)
                meshPtr = mesh.GetCachedPtr();

            ScriptPhysicsQueryHit scriptHit = new ScriptPhysicsQueryHit();
            if(Internal_ConvexCast(meshPtr, ref position, ref rotation, ref unitDir, out scriptHit, layer, max))
            {
                ConvertPhysicsQueryHit(ref scriptHit, out hit);
                return true;
            }

            hit = new PhysicsQueryHit();
            return false;
        }
コード例 #16
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
 /// <summary>
 /// Casts a ray into the scene and returns the closest found hit, if any.
 /// </summary>
 /// <param name="ray">Ray to cast into the scene.</param>
 /// <param name="hit">Information recorded about a hit. Only valid if method returns true.</param>
 /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.
 ///                     </param>
 /// <param name="max">Maximum distance at which to perform the query. Hits past this distance will not be detected.
 ///                   </param>
 /// <returns>True if something was hit, false otherwise.</returns>
 public static bool RayCast(Ray ray, out PhysicsQueryHit hit, ulong layer = ulong.MaxValue, float max = float.MaxValue)
 {
     return RayCast(ray.origin, ray.direction, out hit, layer, max);
 }
コード例 #17
0
ファイル: Physics.generated.cs プロジェクト: nanze81/bsf
 private static extern bool Internal_convexCast(RRef <PhysicsMesh> mesh, ref Vector3 position, ref Quaternion rotation, ref Vector3 unitDir, out PhysicsQueryHit hit, ulong layer, float max);
コード例 #18
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
        /// <summary>
        /// Converts a physics query hit info retrieved from native code into managed physics query hit.
        /// </summary>
        /// <param name="scriptHit">Native physics query hit info.</param>
        /// <param name="hit">Managed physics query hit info</param>
        private static void ConvertPhysicsQueryHit(ref ScriptPhysicsQueryHit scriptHit, out PhysicsQueryHit hit)
        {
            if (scriptHit.collider != null)
                hit.collider = scriptHit.collider.Component;
            else
                hit.collider = null;

            hit.distance = scriptHit.distance;
            hit.normal = scriptHit.normal;
            hit.point = scriptHit.point;
            hit.triangleIdx = scriptHit.triangleIdx;
            hit.uv = scriptHit.uv;
        }
コード例 #19
0
ファイル: Physics.generated.cs プロジェクト: nanze81/bsf
 /// <summary>Casts a ray into the scene and returns the closest found hit, if any.</summary>
 /// <param name="ray">Ray to cast into the scene.</param>
 /// <param name="hit">Information recorded about a hit. Only valid if method returns true.</param>
 /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.</param>
 /// <param name="max">
 /// Maximum distance at which to perform the query. Hits past this distance will not be detected.
 /// </param>
 /// <returns>True if something was hit, false otherwise.</returns>
 public static bool RayCast(Ray ray, out PhysicsQueryHit hit, ulong layer = 18446744073709551615, float max = 3.40282347E+38f)
 {
     return(Internal_rayCast(ref ray, out hit, layer, max));
 }
コード例 #20
0
ファイル: Physics.generated.cs プロジェクト: nanze81/bsf
 /// <summary>Casts a ray into the scene and returns the closest found hit, if any.</summary>
 /// <param name="origin">Origin of the ray to cast into the scene.</param>
 /// <param name="unitDir">Unit direction of the ray to cast into the scene.</param>
 /// <param name="hit">Information recorded about a hit. Only valid if method returns true.</param>
 /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.</param>
 /// <param name="max">
 /// Maximum distance at which to perform the query. Hits past this distance will not be detected.
 /// </param>
 /// <returns>True if something was hit, false otherwise.</returns>
 public static bool RayCast(Vector3 origin, Vector3 unitDir, out PhysicsQueryHit hit, ulong layer = 18446744073709551615, float max = 3.40282347E+38f)
 {
     return(Internal_rayCast0(ref origin, ref unitDir, out hit, layer, max));
 }
コード例 #21
0
ファイル: Physics.generated.cs プロジェクト: nanze81/bsf
 /// <summary>Performs a sweep into the scene using a sphere and returns the closest found hit, if any.</summary>
 /// <param name="sphere">Sphere to sweep through the scene.</param>
 /// <param name="unitDir">Unit direction towards which to perform the sweep.</param>
 /// <param name="hit">Information recorded about a hit. Only valid if method returns true.</param>
 /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.</param>
 /// <param name="max">
 /// Maximum distance at which to perform the query. Hits past this distance will not be detected.
 /// </param>
 /// <returns>True if something was hit, false otherwise.</returns>
 public static bool SphereCast(Sphere sphere, Vector3 unitDir, out PhysicsQueryHit hit, ulong layer = 18446744073709551615, float max = 3.40282347E+38f)
 {
     return(Internal_sphereCast(ref sphere, ref unitDir, out hit, layer, max));
 }