using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace BansheeEngine
{
/** @addtogroup Physics
* @{
*/
///
/// Collider represents physics geometry that can be in multiple states: - Default: Static geometry that physics objects
/// can collide with. - Trigger: Static geometry that can't be collided with but will report touch events. - Dynamic:
/// Dynamic geometry that is a part of a Rigidbody. A set of colliders defines the shape of the parent rigidbody.
///
public partial class Collider : Component
{
private Collider(bool __dummy0) { }
protected Collider() { }
///
/// Enables/disables a collider as a trigger. A trigger will not be used for collisions (objects will pass through it),
/// but collision events will still be reported.
///
[ShowInInspector]
public bool Trigger
{
get { return Internal_getIsTrigger(mCachedPtr); }
set { Internal_setIsTrigger(mCachedPtr, value); }
}
///
/// Determines the mass of the collider. Only relevant if the collider is part of a rigidbody. Ultimately this will
/// determine the total mass, center of mass and inertia tensors of the parent rigidbody (if they're being calculated
/// automatically).
///
[ShowInInspector]
public float Mass
{
get { return Internal_getMass(mCachedPtr); }
set { Internal_setMass(mCachedPtr, value); }
}
///
/// Determines the physical material of the collider. The material determines how objects hitting the collider behave.
///
[ShowInInspector]
public RRef Material
{
get { return Internal_getMaterial(mCachedPtr); }
set { Internal_setMaterial(mCachedPtr, value); }
}
///
/// Determines how far apart do two shapes need to be away from each other before the physics runtime starts generating
/// repelling impulse for them. This distance will be the sum of contact offsets of the two interacting objects. If
/// objects are moving fast you can increase this value to start generating the impulse earlier and potentially prevent
/// the objects from interpenetrating. This value is in meters. Must be positive and greater than rest offset.
///
/// Also see setRestOffset().
///
[ShowInInspector]
public float ContactOffset
{
get { return Internal_getContactOffset(mCachedPtr); }
set { Internal_setContactOffset(mCachedPtr, value); }
}
///
/// Determines at what distance should two objects resting on one another come to an equilibrium. The value used in the
/// runtime will be the sum of rest offsets for both interacting objects. This value is in meters. Cannot be larger than
/// contact offset.
///
/// Also see setContactOffset().
///
[ShowInInspector]
public float RestOffset
{
get { return Internal_getRestOffset(mCachedPtr); }
set { Internal_setRestOffset(mCachedPtr, value); }
}
/// Determines the layer of the collider. Layer controls with which objects will the collider collide.
[ShowInInspector]
public ulong Layer
{
get { return Internal_getLayer(mCachedPtr); }
set { Internal_setLayer(mCachedPtr, value); }
}
/// Determines which (if any) collision events are reported.
[ShowInInspector]
public CollisionReportMode CollisionReportMode
{
get { return Internal_getCollisionReportMode(mCachedPtr); }
set { Internal_setCollisionReportMode(mCachedPtr, value); }
}
///
/// Triggered when some object starts interacting with the collider. Only triggered if proper collision report mode is
/// turned on.
///
public event Action OnCollisionBegin;
///
/// Triggered for every frame that an object remains interacting with a collider. Only triggered if proper collision
/// report mode is turned on.
///
public event Action OnCollisionStay;
///
/// Triggered when some object stops interacting with the collider. Only triggered if proper collision report mode is
/// turned on.
///
public event Action OnCollisionEnd;
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setIsTrigger(IntPtr thisPtr, bool value);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_getIsTrigger(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setMass(IntPtr thisPtr, float mass);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern float Internal_getMass(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setMaterial(IntPtr thisPtr, RRef material);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern RRef Internal_getMaterial(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setContactOffset(IntPtr thisPtr, float value);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern float Internal_getContactOffset(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setRestOffset(IntPtr thisPtr, float value);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern float Internal_getRestOffset(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setLayer(IntPtr thisPtr, ulong layer);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern ulong Internal_getLayer(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setCollisionReportMode(IntPtr thisPtr, CollisionReportMode mode);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern CollisionReportMode Internal_getCollisionReportMode(IntPtr thisPtr);
private void Internal_onCollisionBegin(ref CollisionData p0)
{
OnCollisionBegin?.Invoke(p0);
}
private void Internal_onCollisionStay(ref CollisionData p0)
{
OnCollisionStay?.Invoke(p0);
}
private void Internal_onCollisionEnd(ref CollisionData p0)
{
OnCollisionEnd?.Invoke(p0);
}
}
/** @} */
}