using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace BansheeEngine
{
/** @addtogroup Physics
* @{
*/
/// Provides global physics settings, factory methods for physics objects and scene queries.
[ShowInInspector]
public partial class Physics : ScriptObject
{
private Physics(bool __dummy0) { }
protected Physics() { }
/// Determines the global gravity value for all objects in the scene.
[ShowInInspector]
[NativeWrapper]
public static Vector3 Gravity
{
get
{
Vector3 temp;
Internal_getGravity(out temp);
return temp;
}
set { Internal_setGravity(ref value); }
}
/// Checks is the physics simulation update currently in progress.
[ShowInInspector]
[NativeWrapper]
public static bool IsUpdateInProgress
{
get { return Internal__isUpdateInProgress(); }
}
/// Casts a ray into the scene and returns the closest found hit, if any.
/// Ray to cast into the scene.
/// Information recorded about a hit. Only valid if method returns true.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
///
/// Maximum distance at which to perform the query. Hits past this distance will not be detected.
///
/// True if something was hit, false otherwise.
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);
}
/// Casts a ray into the scene and returns the closest found hit, if any.
/// Origin of the ray to cast into the scene.
/// Unit direction of the ray to cast into the scene.
/// Information recorded about a hit. Only valid if method returns true.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
///
/// Maximum distance at which to perform the query. Hits past this distance will not be detected.
///
/// True if something was hit, false otherwise.
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);
}
/// Performs a sweep into the scene using a box and returns the closest found hit, if any.
/// Box to sweep through the scene.
/// Orientation of the box.
/// Unit direction towards which to perform the sweep.
/// Information recorded about a hit. Only valid if method returns true.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
///
/// Maximum distance at which to perform the query. Hits past this distance will not be detected.
///
/// True if something was hit, false otherwise.
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);
}
/// Performs a sweep into the scene using a sphere and returns the closest found hit, if any.
/// Sphere to sweep through the scene.
/// Unit direction towards which to perform the sweep.
/// Information recorded about a hit. Only valid if method returns true.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
///
/// Maximum distance at which to perform the query. Hits past this distance will not be detected.
///
/// True if something was hit, false otherwise.
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);
}
/// Performs a sweep into the scene using a capsule and returns the closest found hit, if any.
/// Capsule to sweep through the scene.
/// Orientation of the capsule.
/// Unit direction towards which to perform the sweep.
/// Information recorded about a hit. Only valid if method returns true.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
///
/// Maximum distance at which to perform the query. Hits past this distance will not be detected.
///
/// True if something was hit, false otherwise.
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);
}
/// Performs a sweep into the scene using a convex mesh and returns the closest found hit, if any.
/// Mesh to sweep through the scene. Must be convex.
/// Starting position of the mesh.
/// Orientation of the mesh.
/// Unit direction towards which to perform the sweep.
/// Information recorded about a hit. Only valid if method returns true.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
///
/// Maximum distance at which to perform the query. Hits past this distance will not be detected.
///
/// True if something was hit, false otherwise.
public static bool ConvexCast(RRef 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);
}
/// Casts a ray into the scene and returns all found hits.
/// Ray to cast into the scene.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
///
/// Maximum distance at which to perform the query. Hits past this distance will not be detected.
///
/// List of all detected hits.
public static PhysicsQueryHit[] RayCastAll(Ray ray, ulong layer = 18446744073709551615, float max = 3.40282347E+38f)
{
return Internal_rayCastAll(ref ray, layer, max);
}
/// Casts a ray into the scene and returns all found hits.
/// Origin of the ray to cast into the scene.
/// Unit direction of the ray to cast into the scene.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
///
/// Maximum distance at which to perform the query. Hits past this distance will not be detected.
///
/// List of all detected hits.
public static PhysicsQueryHit[] RayCastAll(Vector3 origin, Vector3 unitDir, ulong layer = 18446744073709551615, float max = 3.40282347E+38f)
{
return Internal_rayCastAll0(ref origin, ref unitDir, layer, max);
}
/// Performs a sweep into the scene using a box and returns all found hits.
/// Box to sweep through the scene.
/// Orientation of the box.
/// Unit direction towards which to perform the sweep.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
///
/// Maximum distance at which to perform the query. Hits past this distance will not be detected.
///
/// List of all detected hits.
public static PhysicsQueryHit[] BoxCastAll(AABox box, Quaternion rotation, Vector3 unitDir, ulong layer = 18446744073709551615, float max = 3.40282347E+38f)
{
return Internal_boxCastAll(ref box, ref rotation, ref unitDir, layer, max);
}
/// Performs a sweep into the scene using a sphere and returns all found hits.
/// Sphere to sweep through the scene.
/// Unit direction towards which to perform the sweep.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
///
/// Maximum distance at which to perform the query. Hits past this distance will not be detected.
///
/// List of all detected hits.
public static PhysicsQueryHit[] SphereCastAll(Sphere sphere, Vector3 unitDir, ulong layer = 18446744073709551615, float max = 3.40282347E+38f)
{
return Internal_sphereCastAll(ref sphere, ref unitDir, layer, max);
}
/// Performs a sweep into the scene using a capsule and returns all found hits.
/// Capsule to sweep through the scene.
/// Orientation of the capsule.
/// Unit direction towards which to perform the sweep.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
///
/// Maximum distance at which to perform the query. Hits past this distance will not be detected.
///
/// List of all detected hits.
public static PhysicsQueryHit[] CapsuleCastAll(Capsule capsule, Quaternion rotation, Vector3 unitDir, ulong layer = 18446744073709551615, float max = 3.40282347E+38f)
{
return Internal_capsuleCastAll(ref capsule, ref rotation, ref unitDir, layer, max);
}
/// Performs a sweep into the scene using a convex mesh and returns all found hits.
/// Mesh to sweep through the scene. Must be convex.
/// Starting position of the mesh.
/// Orientation of the mesh.
/// Unit direction towards which to perform the sweep.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
///
/// Maximum distance at which to perform the query. Hits past this distance will not be detected.
///
/// List of all detected hits.
public static PhysicsQueryHit[] ConvexCastAll(RRef mesh, Vector3 position, Quaternion rotation, Vector3 unitDir, ulong layer = 18446744073709551615, float max = 3.40282347E+38f)
{
return Internal_convexCastAll(mesh, ref position, ref rotation, ref unitDir, layer, max);
}
///
/// Casts a ray into the scene and checks if it has hit anything. This can be significantly more efficient than other
/// types of cast* calls.
///
/// Ray to cast into the scene.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
///
/// Maximum distance at which to perform the query. Hits past this distance will not be detected.
///
/// True if something was hit, false otherwise.
public static bool RayCastAny(Ray ray, ulong layer = 18446744073709551615, float max = 3.40282347E+38f)
{
return Internal_rayCastAny(ref ray, layer, max);
}
///
/// Casts a ray into the scene and checks if it has hit anything. This can be significantly more efficient than other
/// types of cast* calls.
///
/// Origin of the ray to cast into the scene.
/// Unit direction of the ray to cast into the scene.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
///
/// Maximum distance at which to perform the query. Hits past this distance will not be detected.
///
/// True if something was hit, false otherwise.
public static bool RayCastAny(Vector3 origin, Vector3 unitDir, ulong layer = 18446744073709551615, float max = 3.40282347E+38f)
{
return Internal_rayCastAny0(ref origin, ref unitDir, layer, max);
}
///
/// Performs a sweep into the scene using a box and checks if it has hit anything. This can be significantly more
/// efficient than other types of cast* calls.
///
/// Box to sweep through the scene.
/// Orientation of the box.
/// Unit direction towards which to perform the sweep.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
///
/// Maximum distance at which to perform the query. Hits past this distance will not be detected.
///
/// True if something was hit, false otherwise.
public static bool BoxCastAny(AABox box, Quaternion rotation, Vector3 unitDir, ulong layer = 18446744073709551615, float max = 3.40282347E+38f)
{
return Internal_boxCastAny(ref box, ref rotation, ref unitDir, layer, max);
}
///
/// Performs a sweep into the scene using a sphere and checks if it has hit anything. This can be significantly more
/// efficient than other types of cast* calls.
///
/// Sphere to sweep through the scene.
/// Unit direction towards which to perform the sweep.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
///
/// Maximum distance at which to perform the query. Hits past this distance will not be detected.
///
/// True if something was hit, false otherwise.
public static bool SphereCastAny(Sphere sphere, Vector3 unitDir, ulong layer = 18446744073709551615, float max = 3.40282347E+38f)
{
return Internal_sphereCastAny(ref sphere, ref unitDir, layer, max);
}
///
/// Performs a sweep into the scene using a capsule and checks if it has hit anything. This can be significantly more
/// efficient than other types of cast* calls.
///
/// Capsule to sweep through the scene.
/// Orientation of the capsule.
/// Unit direction towards which to perform the sweep.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
///
/// Maximum distance at which to perform the query. Hits past this distance will not be detected.
///
/// True if something was hit, false otherwise.
public static bool CapsuleCastAny(Capsule capsule, Quaternion rotation, Vector3 unitDir, ulong layer = 18446744073709551615, float max = 3.40282347E+38f)
{
return Internal_capsuleCastAny(ref capsule, ref rotation, ref unitDir, layer, max);
}
///
/// 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.
///
/// Mesh to sweep through the scene. Must be convex.
/// Starting position of the mesh.
/// Orientation of the mesh.
/// Unit direction towards which to perform the sweep.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
///
/// Maximum distance at which to perform the query. Hits past this distance will not be detected.
///
/// True if something was hit, false otherwise.
public static bool ConvexCastAny(RRef mesh, Vector3 position, Quaternion rotation, Vector3 unitDir, ulong layer = 18446744073709551615, float max = 3.40282347E+38f)
{
return Internal_convexCastAny(mesh, ref position, ref rotation, ref unitDir, layer, max);
}
/// Returns a list of all colliders in the scene that overlap the provided box.
/// Box to check for overlap.
/// Orientation of the box.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
/// List of all colliders that overlap the box.
public static Collider[] BoxOverlap(AABox box, Quaternion rotation, ulong layer = 18446744073709551615)
{
return Internal_boxOverlap(ref box, ref rotation, layer);
}
/// Returns a list of all colliders in the scene that overlap the provided sphere.
/// Sphere to check for overlap.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
/// List of all colliders that overlap the sphere.
public static Collider[] SphereOverlap(Sphere sphere, ulong layer = 18446744073709551615)
{
return Internal_sphereOverlap(ref sphere, layer);
}
/// Returns a list of all colliders in the scene that overlap the provided capsule.
/// Capsule to check for overlap.
/// Orientation of the capsule.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
/// List of all colliders that overlap the capsule.
public static Collider[] CapsuleOverlap(Capsule capsule, Quaternion rotation, ulong layer = 18446744073709551615)
{
return Internal_capsuleOverlap(ref capsule, ref rotation, layer);
}
/// Returns a list of all colliders in the scene that overlap the provided convex mesh.
/// Mesh to check for overlap. Must be convex.
/// Position of the mesh.
/// Orientation of the mesh.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
/// List of all colliders that overlap the mesh.
public static Collider[] ConvexOverlap(RRef mesh, Vector3 position, Quaternion rotation, ulong layer = 18446744073709551615)
{
return Internal_convexOverlap(mesh, ref position, ref rotation, layer);
}
/// Checks if the provided box overlaps any other collider in the scene.
/// Box to check for overlap.
/// Orientation of the box.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
/// True if there is overlap with another object, false otherwise.
public static bool BoxOverlapAny(AABox box, Quaternion rotation, ulong layer = 18446744073709551615)
{
return Internal_boxOverlapAny(ref box, ref rotation, layer);
}
/// Checks if the provided sphere overlaps any other collider in the scene.
/// Sphere to check for overlap.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
/// True if there is overlap with another object, false otherwise.
public static bool SphereOverlapAny(Sphere sphere, ulong layer = 18446744073709551615)
{
return Internal_sphereOverlapAny(ref sphere, layer);
}
/// Checks if the provided capsule overlaps any other collider in the scene.
/// Capsule to check for overlap.
/// Orientation of the capsule.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
/// True if there is overlap with another object, false otherwise.
public static bool CapsuleOverlapAny(Capsule capsule, Quaternion rotation, ulong layer = 18446744073709551615)
{
return Internal_capsuleOverlapAny(ref capsule, ref rotation, layer);
}
/// Checks if the provided convex mesh overlaps any other collider in the scene.
/// Mesh to check for overlap. Must be convex.
/// Position of the mesh.
/// Orientation of the mesh.
/// Layers to consider for the query. This allows you to ignore certain groups of objects.
/// True if there is overlap with another object, false otherwise.
public static bool ConvexOverlapAny(RRef mesh, Vector3 position, Quaternion rotation, ulong layer = 18446744073709551615)
{
return Internal_convexOverlapAny(mesh, ref position, ref rotation, layer);
}
///
/// Adds a new physics region. Certain physics options require you to set up regions in which physics objects are allowed
/// to be in, and objects outside of these regions will not be handled by physics. You do not need to set up these
/// regions by default.
///
public static uint AddPhysicsRegion(AABox region)
{
return Internal_addBroadPhaseRegion(ref region);
}
/// Removes a physics region.
public static void RemovePhysicsRegion(uint handle)
{
Internal_removeBroadPhaseRegion(handle);
}
/// Removes all physics regions.
public static void ClearPhysicsRegions()
{
Internal_clearBroadPhaseRegions();
}
///
/// Enables or disables collision between two layers. Each physics object can be assigned a specific layer, and here you
/// can determine which layers can interact with each other.
///
public static void ToggleCollision(ulong groupA, ulong groupB, bool enabled)
{
Internal_toggleCollision(groupA, groupB, enabled);
}
/// Checks if two collision layers are allowed to interact.
public static bool IsCollisionEnabled(ulong groupA, ulong groupB)
{
return Internal_isCollisionEnabled(groupA, groupB);
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_rayCast(ref Ray ray, out PhysicsQueryHit hit, ulong layer, float max);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_rayCast0(ref Vector3 origin, ref Vector3 unitDir, out PhysicsQueryHit hit, ulong layer, float max);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_boxCast(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, out PhysicsQueryHit hit, ulong layer, float max);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_sphereCast(ref Sphere sphere, ref Vector3 unitDir, out PhysicsQueryHit hit, ulong layer, float max);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_capsuleCast(ref Capsule capsule, ref Quaternion rotation, ref Vector3 unitDir, out PhysicsQueryHit hit, ulong layer, float max);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_convexCast(RRef mesh, ref Vector3 position, ref Quaternion rotation, ref Vector3 unitDir, out PhysicsQueryHit hit, ulong layer, float max);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern PhysicsQueryHit[] Internal_rayCastAll(ref Ray ray, ulong layer, float max);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern PhysicsQueryHit[] Internal_rayCastAll0(ref Vector3 origin, ref Vector3 unitDir, ulong layer, float max);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern PhysicsQueryHit[] Internal_boxCastAll(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, ulong layer, float max);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern PhysicsQueryHit[] Internal_sphereCastAll(ref Sphere sphere, ref Vector3 unitDir, ulong layer, float max);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern PhysicsQueryHit[] Internal_capsuleCastAll(ref Capsule capsule, ref Quaternion rotation, ref Vector3 unitDir, ulong layer, float max);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern PhysicsQueryHit[] Internal_convexCastAll(RRef mesh, ref Vector3 position, ref Quaternion rotation, ref Vector3 unitDir, ulong layer, float max);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_rayCastAny(ref Ray ray, ulong layer, float max);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_rayCastAny0(ref Vector3 origin, ref Vector3 unitDir, ulong layer, float max);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_boxCastAny(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, ulong layer, float max);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_sphereCastAny(ref Sphere sphere, ref Vector3 unitDir, ulong layer, float max);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_capsuleCastAny(ref Capsule capsule, ref Quaternion rotation, ref Vector3 unitDir, ulong layer, float max);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_convexCastAny(RRef mesh, ref Vector3 position, ref Quaternion rotation, ref Vector3 unitDir, ulong layer, float max);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern Collider[] Internal_boxOverlap(ref AABox box, ref Quaternion rotation, ulong layer);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern Collider[] Internal_sphereOverlap(ref Sphere sphere, ulong layer);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern Collider[] Internal_capsuleOverlap(ref Capsule capsule, ref Quaternion rotation, ulong layer);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern Collider[] Internal_convexOverlap(RRef mesh, ref Vector3 position, ref Quaternion rotation, ulong layer);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_boxOverlapAny(ref AABox box, ref Quaternion rotation, ulong layer);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_sphereOverlapAny(ref Sphere sphere, ulong layer);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_capsuleOverlapAny(ref Capsule capsule, ref Quaternion rotation, ulong layer);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_convexOverlapAny(RRef mesh, ref Vector3 position, ref Quaternion rotation, ulong layer);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_getGravity(out Vector3 __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setGravity(ref Vector3 gravity);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern uint Internal_addBroadPhaseRegion(ref AABox region);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_removeBroadPhaseRegion(uint handle);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_clearBroadPhaseRegions();
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_toggleCollision(ulong groupA, ulong groupB, bool enabled);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_isCollisionEnabled(ulong groupA, ulong groupB);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal__isUpdateInProgress();
}
/** @} */
}