RavEngine
Loading...
Searching...
No Matches
RavEngine::PhysicsBodyComponent Class Reference
Inheritance diagram for RavEngine::PhysicsBodyComponent:
[legend]
Collaboration diagram for RavEngine::PhysicsBodyComponent:
[legend]

Classes

struct  ColliderHandle
 

Public Member Functions

auto getScene () const
 
 PhysicsBodyComponent (Entity owner)
 
void Destroy ()
 
template<typename T , typename ... A>
ColliderHandle EmplaceCollider (A &&... args)
 
template<typename T >
void DestroyCollider (ColliderHandle handle)
 
void OnDestroyDetatchCollider (RavEngine::PhysicsCollider &collider)
 
void AddReceiver (decltype(receivers)::value_type &obj)
 
void RemoveReceiver (decltype(receivers)::value_type &obj)
 
void RemoveReceiver (PhysicsCallback *)
 
std::pair< vector3, quaternion > getDynamicsWorldPose () const
 
void setDynamicsWorldPose (const vector3 &worldpos, const quaternion &worldrot) const
 
void SetGravityEnabled (bool)
 
bool GetGravityEnabled () const
 
void SetSleepNotificationsEnabled (bool)
 
bool GetSleepNotificationsEnabled () const
 
void SetSimulationEnabled (bool)
 
bool GetSimulationEnabled () const
 
void OnColliderEnter (PhysicsBodyComponent &other, const ContactPairPoint *contactPoints, size_t numContactPoints)
 
void OnColliderPersist (PhysicsBodyComponent &other, const ContactPairPoint *contactPoints, size_t numContactPoints)
 
void OnColliderExit (PhysicsBodyComponent &other, const ContactPairPoint *contactPoints, size_t numContactPoints)
 
void OnTriggerEnter (PhysicsBodyComponent &other)
 
void OnTriggerExit (PhysicsBodyComponent &other)
 
bool GetWantsContactData () const
 
void SetWantsContactData (bool state)
 
void DebugDraw (RavEngine::DebugDrawer &dbg, const RavEngine::Transform &tr) const
 
- Public Member Functions inherited from RavEngine::ComponentWithOwner
 ComponentWithOwner (const decltype(owner) o)
 
Entity GetOwner () const
 

Public Attributes

physx::PxRigidActor * rigidActor = nullptr
 
physx::PxU32 filterGroup = -1
 
physx::PxU32 filterMask = -1
 
- Public Attributes inherited from RavEngine::IDebugRenderable
bool debugEnabled = false
 
color_t debug_color = 0xFFFFFFFF
 
- Public Attributes inherited from RavEngine::Queryable< types >
constexpr q_qt_def
 

Protected Member Functions

void CompleteConstruction ()
 
template<typename T >
void LockWrite (const T &func)
 
template<typename T >
void LockRead (const T &func) const
 

Protected Attributes

UnorderedSet< std::shared_ptr< PhysicsCallback > > receivers
 
Colony< std::shared_ptr< PhysicsCollider > > colliders
 
bool setPoseNeedsSync = false
 
bool wantsContactData = false
 
- Protected Attributes inherited from RavEngine::ComponentWithOwner
Entity owner
 

Friends

class PhysicsLinkSystemRead
 
class PhysicsLinkSystemWrite
 

Additional Inherited Members

- Public Types inherited from RavEngine::Queryable< types >
typedef std::array< ctti_t, ntypes > arraytype
 
- Static Public Member Functions inherited from RavEngine::Queryable< types >
static constexpr const arraytype & GetQueryTypes ()
 
- Static Public Attributes inherited from RavEngine::Queryable< types >
static constexpr std::size_t ntypes = sizeof ... (types)
 

Member Function Documentation

◆ AddReceiver()

void RavEngine::PhysicsBodyComponent::AddReceiver ( decltype(receivers)::value_type &  obj)

Add a recipient for collision events. Must implement IPhysicsActor.

Parameters
objthe interface implementer to recieve the events

◆ DebugDraw()

void RavEngine::PhysicsBodyComponent::DebugDraw ( RavEngine::DebugDrawer &  dbg,
const RavEngine::Transform &  transform 
) const
inlinevirtual

Draw a wireframe shape representing the boundary of this object

Parameters
colorthe hex color to use to draw, in format 0xRRGGBBAA

Implements RavEngine::IDebugRenderable.

◆ getDynamicsWorldPose()

std::pair< vector3, quaternion > PhysicsBodyComponent::getDynamicsWorldPose ( ) const
Returns
the PhysX dynamics pose.
Note
thread-safe (Locks internally).

◆ GetGravityEnabled()

bool RavEngine::PhysicsBodyComponent::GetGravityEnabled ( ) const
Returns
true if gravity is enabled

◆ GetSimulationEnabled()

bool RavEngine::PhysicsBodyComponent::GetSimulationEnabled ( ) const
Returns
true if simulation is enabled.

◆ GetSleepNotificationsEnabled()

bool RavEngine::PhysicsBodyComponent::GetSleepNotificationsEnabled ( ) const

Returns true if sleep / wake notifications are enabled.

◆ GetWantsContactData()

bool RavEngine::PhysicsBodyComponent::GetWantsContactData ( ) const
inline

Get if this body wants contact data

◆ OnColliderEnter()

void PhysicsBodyComponent::OnColliderEnter ( PhysicsBodyComponent &  other,
const ContactPairPoint *  contactPoints,
size_t  numContactPoints 
)

Invoked when a collider begins colliding with another body

Parameters
otherthe second body
contactPointsthe contact point data. Do not hold onto this pointer, because after this call, the pointer is invalid.
numContactPointsthe number of contact points. Set to 0 if wantsContactData is false.

◆ OnColliderExit()

void PhysicsBodyComponent::OnColliderExit ( PhysicsBodyComponent &  other,
const ContactPairPoint *  contactPoints,
size_t  numContactPoints 
)

Invoked when a collider has exited another collider

Parameters
otherthe second body
contactPointsthe contact point data. Do not hold onto this pointer, because after this call, the pointer is invalid.
numContactPointsthe number of contact points. Set to 0 if wantsContactData is false.

◆ OnColliderPersist()

void PhysicsBodyComponent::OnColliderPersist ( PhysicsBodyComponent &  other,
const ContactPairPoint *  contactPoints,
size_t  numContactPoints 
)

Invoked when a collider has collided with another body for multiple frames

Parameters
otherthe second body
contactPointsthe contact point data. Do not hold onto this pointer, because after this call, the pointer is invalid.
numContactPointsthe number of contact points. Set to 0 if wantsContactData is false.

◆ OnTriggerEnter()

void PhysicsBodyComponent::OnTriggerEnter ( PhysicsBodyComponent &  other)

Called by a PhysicsBodyComponent when it has entered another trigger. Override in subclasses. Note that triggers cannot fire events on other triggers.

Parameters
otherthe other component

◆ OnTriggerExit()

void PhysicsBodyComponent::OnTriggerExit ( PhysicsBodyComponent &  other)

Called by a PhysicsBodyComponent when it has exited another trigger. Override in subclasses. Note that triggers cannot fire events on other triggers.

Parameters
otherthe other component

◆ RemoveReceiver()

void RavEngine::PhysicsBodyComponent::RemoveReceiver ( decltype(receivers)::value_type &  obj)

Remove a recipient for collision events. Must implement IPhysicsActor On deallocation, objects automatically remove themselves.

Parameters
objthe object to remove

◆ setDynamicsWorldPose()

void PhysicsBodyComponent::setDynamicsWorldPose ( const vector3 &  worldpos,
const quaternion &  worldrot 
) const

Set the world space dynamics transform (via teleport)

Parameters
worldposworld-space position
worldrotworld-space rotation
Note
thread-safe (Locks internally).

◆ SetGravityEnabled()

void RavEngine::PhysicsBodyComponent::SetGravityEnabled ( bool  state)

Enable or disable gravity on this body

Parameters
statethe new state of gravity

◆ SetSimulationEnabled()

void RavEngine::PhysicsBodyComponent::SetSimulationEnabled ( bool  state)

Enable or disable simulation for this body.

Parameters
statethe new simulation status.
Note
If simulation is disbaled, all constraints are removed, all velocities and forces are cleared, and actor is set to sleep.

◆ SetSleepNotificationsEnabled()

void RavEngine::PhysicsBodyComponent::SetSleepNotificationsEnabled ( bool  state)

Sets whether or not onWake and onSleep events get called.

Parameters
statenew state for this property

◆ SetWantsContactData()

void RavEngine::PhysicsBodyComponent::SetWantsContactData ( bool  state)
inline

wantsContactData controls if the simulation calculates and extracts contact point information on collisions. Set to true to get contact point data. If set to false, OnCollider functions will have a dangling contactPoints pointer and numContactPoints will be 0.


The documentation for this class was generated from the following files: