Exemplo n.º 1
0
        /// <summary>
        /// Checks if the provided convex mesh overlaps any other collider in the scene.
        /// </summary>
        /// <param name="mesh">Mesh to check for overlap. Must be convex.</param>
        /// <param name="position">Position of the mesh.</param>
        /// <param name="rotation">Orientation of the mesh.</param>
        /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.
        ///                     </param>
        /// <returns>True if there is overlap with another object, false otherwise.</returns>
        public static bool ConvexOverlapAny(PhysicsMesh mesh, Vector3 position, Quaternion rotation,
                                            ulong layer = ulong.MaxValue)
        {
            IntPtr meshPtr = IntPtr.Zero;

            if (mesh != null)
            {
                meshPtr = mesh.GetCachedPtr();
            }

            return(Internal_ConvexOverlapAny(meshPtr, ref position, ref rotation, layer));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Performs a sweep into the scene using a convex mesh and checks if it has hit anything. This can be significantly
        /// more efficient than other types of cast* calls.
        /// </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="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 ConvexCastAny(PhysicsMesh mesh, Vector3 position, Quaternion rotation,
                                         Vector3 unitDir, ulong layer = ulong.MaxValue, float max = float.MaxValue)
        {
            IntPtr meshPtr = IntPtr.Zero;

            if (mesh != null)
            {
                meshPtr = mesh.GetCachedPtr();
            }

            return(Internal_ConvexCastAny(meshPtr, ref position, ref rotation, ref unitDir, layer, max));
        }
Exemplo n.º 3
0
        /// <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);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Checks if the provided convex mesh overlaps any other collider in the scene.
        /// </summary>
        /// <param name="mesh">Mesh to check for overlap. Must be convex.</param>
        /// <param name="position">Position of the mesh.</param>
        /// <param name="rotation">Orientation of the mesh.</param>
        /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.
        ///                     </param>
        /// <returns>True if there is overlap with another object, false otherwise.</returns>
        public static bool ConvexOverlapAny(PhysicsMesh mesh, Vector3 position, Quaternion rotation,
            ulong layer = ulong.MaxValue)
        {
            IntPtr meshPtr = IntPtr.Zero;
            if (mesh != null)
                meshPtr = mesh.GetCachedPtr();

            return Internal_ConvexOverlapAny(meshPtr, ref position, ref rotation, layer);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Returns a list of all colliders in the scene that overlap the provided convex mesh.
        /// </summary>
        /// <param name="mesh">Mesh to check for overlap. Must be convex.</param>
        /// <param name="position">Position of the mesh.</param>
        /// <param name="rotation">Orientation of the mesh.</param>
        /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.
        ///                     </param>
        /// <returns>List of all colliders that overlap the mesh.</returns>
        public static Collider[] ConvexOverlap(PhysicsMesh mesh, Vector3 position, Quaternion rotation, 
            ulong layer = ulong.MaxValue)
        {
            IntPtr meshPtr = IntPtr.Zero;
            if (mesh != null)
                meshPtr = mesh.GetCachedPtr();

            return ConvertColliders(Internal_ConvexOverlap(meshPtr, ref position, ref rotation, layer));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Performs a sweep into the scene using a convex mesh and checks if it has hit anything. This can be significantly
        /// more efficient than other types of cast* calls.
        /// </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="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 ConvexCastAny(PhysicsMesh mesh, Vector3 position, Quaternion rotation,
            Vector3 unitDir, ulong layer = ulong.MaxValue, float max = float.MaxValue)
        {
            IntPtr meshPtr = IntPtr.Zero;
            if (mesh != null)
                meshPtr = mesh.GetCachedPtr();

            return Internal_ConvexCastAny(meshPtr, ref position, ref rotation, ref unitDir, layer, max);
        }
Exemplo n.º 7
0
        /// <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;
        }