Quark Physics  1.0
2D Rigid and Soft Body Physics Engine
QRaycast Class Reference

QRaycast objects send a ray into the world and return collision results with body objects. You can create a constant raycast object that you can add to the world and update collision results at every physics step, or you can make instantaneous raycast calls at runtime using the QRaycast::RaycastTo static method. QWorld also provides methods for managing QRaycast objects. More...

#include <qraycast.h>

Classes

struct  Contact
 

Public Member Functions

 QRaycast (QVector position, QVector rayVector, bool enableContainingBodies=false)
 
vector< QRaycast::Contact > * GetContacts ()
 
QVector GetPosition ()
 
float GetRotation ()
 
QVector GetRayVector ()
 
bool GetEnabledContainingBodies ()
 
int GetCollidableLayersBit ()
 
QRaycastSetPosition (QVector value)
 
QRaycastSetRotation (float value)
 
QRaycastSetRayVector (QVector value)
 
QRaycastSetEnabledContainingBodies (bool value)
 
QRaycastSetCollidableLayersBit (int value)
 

Static Public Member Functions

static vector< QRaycast::ContactRaycastTo (QWorld *world, QVector rayPosition, QVector rayVector, int collidableLayers=1, bool enableContainingBodies=false)
 

Protected Member Functions

void UpdateContacts ()
 

Protected Attributes

int collidableLayersBit =1
 

Friends

class QWorld
 

Detailed Description

QRaycast objects send a ray into the world and return collision results with body objects. You can create a constant raycast object that you can add to the world and update collision results at every physics step, or you can make instantaneous raycast calls at runtime using the QRaycast::RaycastTo static method. QWorld also provides methods for managing QRaycast objects.

Constructor & Destructor Documentation

◆ QRaycast()

QRaycast::QRaycast ( QVector  position,
QVector  rayVector,
bool  enableContainingBodies = false 
)

Creates a raycast.

Parameters
positionThe position of the raycast.
rayVectorThe ray vector.
enableContainingBodiesDetermines whether a body should be ignored in raycast collisions if the ray position is inside the shape representing the body in the world. If set to true, these objects will be ignored in raycast collisions.

Member Function Documentation

◆ GetCollidableLayersBit()

int QRaycast::GetCollidableLayersBit ( )

Returns the bit mask that represents the layers in which the body object is present.

◆ GetContacts()

vector< QRaycast::Contact > * QRaycast::GetContacts ( )

Returns contact list of the raycast.

◆ GetEnabledContainingBodies()

bool QRaycast::GetEnabledContainingBodies ( )

Returns whether a body should be ignored in raycast collisions if the ray position is inside the shape representing the body in the world. If set to true, these objects will be ignored in raycast collisions.

◆ GetPosition()

QVector QRaycast::GetPosition ( )

Returns the position of the raycast.

◆ GetRayVector()

QVector QRaycast::GetRayVector ( )

Returns the ray vector of the raycast.

◆ GetRotation()

float QRaycast::GetRotation ( )

Returns the rotation of the raycast.

◆ RaycastTo()

vector< QRaycast::Contact > QRaycast::RaycastTo ( QWorld world,
QVector  rayPosition,
QVector  rayVector,
int  collidableLayers = 1,
bool  enableContainingBodies = false 
)
static

Sends a ray into the world with the given position and direction vector. Returns a collection of QRaycast::Contact containing collision information with body objects hit by the ray.

Parameters
worldThe world.
rayPositionThe position of the ray.
rayVectorThe vector of the ray.
collidableLayersThe target layer bits.
enableContainingBodiesDetermines whether a body should be ignored in raycast collisions if the ray position is inside the shape representing the body in the world. If set to true, these objects will be ignored in raycast collisions.
Returns
A collection of contacts as a result of the raycast operation.

◆ SetCollidableLayersBit()

QRaycast * QRaycast::SetCollidableLayersBit ( int  value)

Sets the bit mask that represents the collidable layers in which the body object is present.A raycast object can collide with other body objects present in the layers defined by the user.

Parameters
valueA bit mask value to set.

◆ SetEnabledContainingBodies()

QRaycast * QRaycast::SetEnabledContainingBodies ( bool  value)

Sets whether a body should be ignored in raycast collisions if the ray position is inside the shape representing the body in the world. If set to true, these objects will be ignored in raycast collisions.

Parameters
valueTrue or false.

◆ SetPosition()

QRaycast * QRaycast::SetPosition ( QVector  value)

Sets the position of the raycast

Parameters
valA position to set.

◆ SetRayVector()

QRaycast * QRaycast::SetRayVector ( QVector  value)

Sets the ray vector of the raycast

Parameters
valueA ray vector to set.

◆ SetRotation()

QRaycast * QRaycast::SetRotation ( float  value)

Sets the rotation of the raycast

Parameters
valueA rotation to set.

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