Drag[en]gine Game Engine
1.21
|
World Collider Object. More...
#include <deCollider.h>
Public Types | |
enum | eResponseType { ertStatic , ertDynamic , ertKinematic } |
Collision Response Types. More... | |
typedef deTObjectReference< deCollider > | Ref |
Type holding strong reference. More... | |
Public Types inherited from deResource | |
typedef deTObjectReference< deResource > | Ref |
Type holding strong reference. More... | |
Public Types inherited from deObject | |
typedef deTObjectReference< deObject > | Ref |
Type holding strong reference. More... | |
Public Member Functions | |
Management | |
const decDVector & | GetPosition () const |
Central mass point position. More... | |
void | SetPosition (const decDVector &position) |
Set central mass point position. More... | |
const decQuaternion & | GetOrientation () const |
Orientation. More... | |
void | SetOrientation (const decQuaternion &orientation) |
Set orientation. More... | |
void | SetGeometry (const decDVector &position, const decQuaternion &orientation) |
Set position and orientation at the same time. More... | |
void | SetGeometry (const decDVector &position, const decQuaternion &orientation, const decVector &scale) |
const decVector & | GetScale () const |
Scale. More... | |
void | SetScale (const decVector &scale) |
Set scale. More... | |
const decVector & | GetLinearVelocity () const |
Linear velocity in m/s. More... | |
void | SetLinearVelocity (const decVector &linVelo) |
Set linear velocity in m/s. More... | |
const decVector & | GetAngularVelocity () const |
Angular velocity in degree/s. More... | |
void | SetAngularVelocity (const decVector &angVelo) |
Set angular velocity in degree/s. More... | |
float | GetMass () const |
Mass in kg. More... | |
void | SetMass (float mass) |
Set mass in kg. More... | |
const decVector & | GetGravity () const |
Gravity in m/s^2. More... | |
void | SetGravity (const decVector &gravity) |
Set gravity in m/s^2. More... | |
bool | GetEnabled () const |
Collider is enabled. More... | |
void | SetEnabled (bool enabled) |
Set if collider is enabled. More... | |
eResponseType | GetResponseType () const |
Collision response type. More... | |
void | SetResponseType (eResponseType responseType) |
Set Collision response type. More... | |
bool | GetUseLocalGravity () const |
Use local gravity instead of the world gravity. More... | |
void | SetUseLocalGravity (bool useLocalGravity) |
Set if local gravity is used instead of the world gravity. More... | |
float | GetForceFieldDirect () const |
Factor for direct type force fields. More... | |
void | SetForceFieldDirect (float factor) |
Set factor for direct type force fields. More... | |
float | GetForceFieldSurface () const |
Factor for surface type force fields. More... | |
void | SetForceFieldSurface (float factor) |
Set factor for surface type force fields. More... | |
float | GetForceFieldMass () const |
Factor for mass type force fields. More... | |
void | SetForceFieldMass (float factor) |
Set factor for mass type force fields. More... | |
float | GetForceFieldSpeed () const |
Factor for speed type force fields. More... | |
void | SetForceFieldSpeed (float factor) |
Set factor for speed type force fields. More... | |
const decCollisionFilter & | GetCollisionFilter () const |
Collision filter. More... | |
void | SetCollisionFilter (const decCollisionFilter &filter) |
Set collision filter. More... | |
Force and Impuls | |
void | ApplyImpuls (const decVector &impuls) |
Apply impuls at the center mass point. More... | |
void | ApplyImpulsAt (const decVector &impuls, const decVector &point) |
Apply impuls relative to the collider position. More... | |
void | ApplyTorqueImpuls (const decVector &torqueImpuls) |
Apply torque impuls at the center mass point. More... | |
void | ApplyForce (const decVector &force) |
Apply force at the center mass point. More... | |
void | ApplyForceAt (const decVector &force, const decVector &point) |
Apply force relative to the collider position. More... | |
void | ApplyTorque (const decVector &torque) |
Apply torque force at the center mass point. More... | |
Attachments | |
int | GetAttachmentCount () const |
Number of attachments. More... | |
deColliderAttachment * | GetAttachmentAt (int index) const |
Attachment at index. More... | |
bool | HasAttachmentWith (deResource *resource) const |
Resource is attached. More... | |
deColliderAttachment * | GetAttachmentWith (deResource *resource) const |
Attachment with resource or NULL if not attached. More... | |
void | AddAttachment (deColliderAttachment *attachment) |
Add attachment. More... | |
void | RemoveAttachment (deColliderAttachment *attachment) |
Remove attachment. More... | |
void | RemoveAllAttachments () |
Remove all attachments. More... | |
void | NotifyAttachmentChanged (int index) |
Notify peers attachment changed. More... | |
void | AttachmentsForceUpdate () |
Force update of all attachments. More... | |
Constraints | |
int | GetConstraintCount () const |
Number of constraints. More... | |
deColliderConstraint * | GetConstraintAt (int index) const |
Constraint at index. More... | |
int | IndexOfConstraint (deColliderConstraint *constraint) const |
Index of constraint or -1 if absent. More... | |
bool | HasConstraint (deColliderConstraint *constraint) const |
Constraint is present. More... | |
void | AddConstraint (deColliderConstraint *constraint) |
Add constraint. More... | |
void | RemoveConstraint (deColliderConstraint *constraint) |
Remove constraint. More... | |
void | RemoveAllConstraints () |
Remove all constraints. More... | |
void | NotifyConstraintChanged (int index) |
Notify peers constraint has changed. More... | |
Ignore colliders | |
int | GetIgnoreColliderCount () const |
Number of colliders to ignore. More... | |
deCollider * | GetIgnoreColliderAt (int index) const |
Collider to ignore at index. More... | |
bool | HasIgnoreCollider (deCollider *collider) const |
Collider to ignore is present. More... | |
void | AddIgnoreCollider (deCollider *collider) |
Add collider to ignore. More... | |
void | RemoveIgnoreCollider (deCollider *collider) |
Remove collider to ignore. More... | |
void | RemoveAllIgnoreColliders () |
Remove all colliders to ignore. More... | |
Post physics collision tests | |
int | GetCollisionTestCount () const |
Number of post physics collision tests. More... | |
deColliderCollisionTest * | GetCollisionTestAt (int index) const |
Post physics collision test at index. More... | |
int | IndexOfCollisionTest (deColliderCollisionTest *collisionTest) const |
Index of post physics collision test or -1 if not found. More... | |
bool | HasCollisionTest (deColliderCollisionTest *collisionTest) const |
Post physics collision test is present. More... | |
void | AddCollisionTest (deColliderCollisionTest *collisionTest) |
Adds post physics collision test. More... | |
void | RemoveCollisionTest (deColliderCollisionTest *collisionTest) |
Remove post physics collision test. More... | |
void | RemoveAllCollisionTests () |
Remove all post physics collision tests. More... | |
void | NotifyCollisionTestChanged (int index) |
Notify peers a post physics collision test changed. More... | |
void | NotifyCollisionTestEnableChanged (int index) |
Notify peers a post physics collision test enabled or disabled. More... | |
Collision Detection | |
bool | PointInside (const decDVector &point) |
Test if a point is located inside the collider. More... | |
void | RayHits (const decDVector &rayOrigin, const decVector &rayDirection, deBaseScriptingCollider *listener) |
Test ray for collision with the collider. More... | |
void | ColliderHits (deCollider *collider, deBaseScriptingCollider *listener) |
Test collider for collision with collider. More... | |
void | ColliderMoveHits (deCollider *collider, const decVector &displacement, deBaseScriptingCollider *listener) |
Test moving collider for collision with collider. More... | |
void | ColliderRotateHits (deCollider *collider, const decVector &rotation, deBaseScriptingCollider *listener) |
Test rotating collider for collision with collider. More... | |
void | ColliderMoveRotateHits (deCollider *collider, const decVector &displacement, const decVector &rotation, deBaseScriptingCollider *listener) |
Test moving and rotating collider for collision with collider. More... | |
System Peers | |
deBasePhysicsCollider * | GetPeerPhysics () const |
Physics system peer. More... | |
void | SetPeerPhysics (deBasePhysicsCollider *peer) |
Set physics system peer. More... | |
deBaseScriptingCollider * | GetPeerScripting () const |
Scripting system peer. More... | |
void | SetPeerScripting (deBaseScriptingCollider *peer) |
Set scripting system peer. More... | |
Visiting | |
virtual void | Visit (deColliderVisitor &visitor) |
Visit collider. More... | |
Public Member Functions inherited from deResource | |
deResourceManager * | GetResourceManager () const |
Resource manager or NULL if resource is leaking. More... | |
deEngine * | GetEngine () const |
Game engine object from resource manager. More... | |
deResource * | GetLLManagerPrev () const |
Previous resource in the resource manager linked list. More... | |
void | SetLLManagerPrev (deResource *resource) |
Set next resource in the resource manager linked list. More... | |
deResource * | GetLLManagerNext () const |
Next resource in the resource manager linked list. More... | |
void | SetLLManagerNext (deResource *resource) |
Set next resource in the resource manager linked list. More... | |
void | MarkLeaking () |
Marks the resource leaking. More... | |
deResource (deResourceManager *resourceManager) | |
Create resource. More... | |
Public Member Functions inherited from deObject | |
int | GetRefCount () const |
Reference count. More... | |
void | AddReference () |
Add reference increasing reference count by 1. More... | |
void | FreeReference () |
Decrease reference count by one and delete object if count reaches 0. More... | |
deObject () | |
Create object with reference count of 1. More... | |
Linked List | |
class | deColliderBone |
deWorld * | GetParentWorld () const |
Parent world or NULL. More... | |
void | SetParentWorld (deWorld *world) |
Set parent world or NULL. More... | |
deCollider * | GetLLWorldPrev () const |
Previous collider in the parent world linked list. More... | |
void | SetLLWorldPrev (deCollider *collider) |
Set next collider in the parent world linked list. More... | |
deCollider * | GetLLWorldNext () const |
Next collider in the parent world linked list. More... | |
void | SetLLWorldNext (deCollider *collider) |
Set next collider in the parent world linked list. More... | |
void | pNotifyCollisionVolumeChanged () |
void | pNotifyRigChanged () |
void | pNotifyComponentChanged () |
void | pNotifyBonePositionChanged (int index) |
void | pNotifyBoneOrientationChanged (int index) |
void | pNotifyBoneLinearVelocityChanged (int index) |
void | pNotifyBoneAngularVelocityChanged (int index) |
void | pNotifyBonePropertiesChanged (int index) |
void | pNotifyBoneDynamicChanged (int index) |
Constructors and Destructors | |
deCollider (deColliderManager *manager) | |
Create collider. More... | |
virtual | ~deCollider () |
Clean up collider. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from deResource | |
virtual | ~deResource () |
Clean up resource. More... | |
Protected Member Functions inherited from deObject | |
virtual | ~deObject () |
Clean up object. More... | |
World Collider Object.
Colliders are used by the physics module to provide collision detection and optional collision response. After the collision detection stage is done each Collider contains the new state of motion. The user can then update the game state depending on the changes. The scripting peer receives all relevant events during a collision detection run. A Collider can be defined as a couple of different types.
The Collider object itself can not be constructed. Create a new Collider object using one of deColliderVolume, deColliderRig or deColliderComponent classes.
ertNone causes no response to be send and hence does not notify you about a collision. This is used for static objects that only act as blockers or objects that do not wish to generate collision notification because they are activated by other objects.
ertPhysics causes a physical response to be calculated by the Physics Module. The Scripting Module is notified using its peer about the collision. You are responsible there to provide information about the surfaces getting in contact to allow the Physics Module to calculate a proper physical reaction to the collision.
ertCustom is used to generate your own collision responses. Upon collision the Scripting Module is notified. In the CollisionResponse function you are responsible for specifying the effect of the collision on the object.
typedef deTObjectReference<deCollider> deCollider::Ref |
Type holding strong reference.
deCollider::deCollider | ( | deColliderManager * | manager | ) |
Create collider.
|
protectedvirtual |
Clean up collider.
void deCollider::AddAttachment | ( | deColliderAttachment * | attachment | ) |
Add attachment.
deeInvalidParam | Resource is already attached. |
void deCollider::AddCollisionTest | ( | deColliderCollisionTest * | collisionTest | ) |
Adds post physics collision test.
void deCollider::AddConstraint | ( | deColliderConstraint * | constraint | ) |
Add constraint.
void deCollider::AddIgnoreCollider | ( | deCollider * | collider | ) |
Add collider to ignore.
deeInvalidParam | collider is present. |
void deCollider::ApplyForce | ( | const decVector & | force | ) |
Apply force at the center mass point.
This affects the total force and torque applied during the next debpWorld::DetectCollision only. Useful to apply continuous forces on an object. Has to be called every frame update.
Apply force relative to the collider position.
This affects the total force and torque applied during the next debpWorld::DetectCollision only. Useful to apply continuous forces on an object. Has to be called every frame update.
void deCollider::ApplyImpuls | ( | const decVector & | impuls | ) |
Apply impuls at the center mass point.
This affects linear and angular velocity. This is the best way way to apply impacts.
Apply impuls relative to the collider position.
This affects linear and angular velocity. This is the best way way to apply impacts.
void deCollider::ApplyTorque | ( | const decVector & | torque | ) |
Apply torque force at the center mass point.
This affects the total torque applied during the next debpWorld::DetectCollision only. Useful to apply continuous forces on an object. Has to be called every frame update.
void deCollider::ApplyTorqueImpuls | ( | const decVector & | torqueImpuls | ) |
Apply torque impuls at the center mass point.
This affects angular velocity. This is the best way way to apply impacts.
void deCollider::AttachmentsForceUpdate | ( | ) |
Force update of all attachments.
You have to call this if want to reset colliders and components to a predefined state like after warping or resetting objects. This requires an attachment update outside the regular physics simulation run by the physics module to prevent exploding behavior.
void deCollider::ColliderHits | ( | deCollider * | collider, |
deBaseScriptingCollider * | listener | ||
) |
Test collider for collision with collider.
For each collision deBaseScriptingCollider::CollisionResponse() of the listener set in the tested collider is called. To stop testing set deCollisionInfo::SetStopTesting() to true.
void deCollider::ColliderMoveHits | ( | deCollider * | collider, |
const decVector & | displacement, | ||
deBaseScriptingCollider * | listener | ||
) |
Test moving collider for collision with collider.
For each collision deBaseScriptingCollider::CollisionResponse() of the listener set in the tested collider is called. To stop testing set deCollisionInfo::SetStopTesting() to true.
void deCollider::ColliderMoveRotateHits | ( | deCollider * | collider, |
const decVector & | displacement, | ||
const decVector & | rotation, | ||
deBaseScriptingCollider * | listener | ||
) |
Test moving and rotating collider for collision with collider.
For each collision deBaseScriptingCollider::CollisionResponse() of the listener set in the tested collider is called. To stop testing set deCollisionInfo::SetStopTesting() to true.
void deCollider::ColliderRotateHits | ( | deCollider * | collider, |
const decVector & | rotation, | ||
deBaseScriptingCollider * | listener | ||
) |
Test rotating collider for collision with collider.
For each collision deBaseScriptingCollider::CollisionResponse() of the listener set in the tested collider is called. To stop testing set deCollisionInfo::SetStopTesting() to true.
|
inline |
Angular velocity in degree/s.
deColliderAttachment* deCollider::GetAttachmentAt | ( | int | index | ) | const |
Attachment at index.
deeOutOfBoundary | index is less than 0 or greater than or equal to GetAttachmentCount(). |
|
inline |
Number of attachments.
deColliderAttachment* deCollider::GetAttachmentWith | ( | deResource * | resource | ) | const |
Attachment with resource or NULL if not attached.
|
inline |
Collision filter.
deColliderCollisionTest* deCollider::GetCollisionTestAt | ( | int | index | ) | const |
Post physics collision test at index.
deeInvalidParam | index is less than 0. |
deeInvalidParam | index is greater or equal than GetCollisionTestCount()-1. |
int deCollider::GetCollisionTestCount | ( | ) | const |
Number of post physics collision tests.
deColliderConstraint* deCollider::GetConstraintAt | ( | int | index | ) | const |
Constraint at index.
deeOutOfBoundary | index is less than 0 or greater than or equal to GetConstraintCount(). |
|
inline |
Number of constraints.
|
inline |
Collider is enabled.
Only enabled colliders take part in collision detection and response. Disabled colliders though still update attachments and can be used in manual collision detection.
|
inline |
Factor for direct type force fields.
|
inline |
Factor for mass type force fields.
|
inline |
Factor for speed type force fields.
|
inline |
Factor for surface type force fields.
|
inline |
Gravity in m/s^2.
deCollider* deCollider::GetIgnoreColliderAt | ( | int | index | ) | const |
Collider to ignore at index.
deeInvalidParam | index is less than 0. |
deeInvalidParam | index is greater or equal than GetIgnoreColliderCount()-1. |
int deCollider::GetIgnoreColliderCount | ( | ) | const |
Number of colliders to ignore.
|
inline |
Linear velocity in m/s.
|
inline |
Next collider in the parent world linked list.
|
inline |
Previous collider in the parent world linked list.
|
inline |
Mass in kg.
|
inline |
Orientation.
|
inline |
Parent world or NULL.
|
inline |
Physics system peer.
|
inline |
Scripting system peer.
|
inline |
Central mass point position.
|
inline |
Collision response type.
|
inline |
Scale.
|
inline |
Use local gravity instead of the world gravity.
bool deCollider::HasAttachmentWith | ( | deResource * | resource | ) | const |
Resource is attached.
bool deCollider::HasCollisionTest | ( | deColliderCollisionTest * | collisionTest | ) | const |
Post physics collision test is present.
bool deCollider::HasConstraint | ( | deColliderConstraint * | constraint | ) | const |
Constraint is present.
bool deCollider::HasIgnoreCollider | ( | deCollider * | collider | ) | const |
Collider to ignore is present.
int deCollider::IndexOfCollisionTest | ( | deColliderCollisionTest * | collisionTest | ) | const |
Index of post physics collision test or -1 if not found.
int deCollider::IndexOfConstraint | ( | deColliderConstraint * | constraint | ) | const |
Index of constraint or -1 if absent.
void deCollider::NotifyAttachmentChanged | ( | int | index | ) |
Notify peers attachment changed.
You have to call this explicitly if you changed attachments.
void deCollider::NotifyCollisionTestChanged | ( | int | index | ) |
Notify peers a post physics collision test changed.
You have to call this explicitly if you changed post physics collision tests.
deeInvalidParam | index is less than 0 or greater than or equal to GetCollisionTestCount(). |
void deCollider::NotifyCollisionTestEnableChanged | ( | int | index | ) |
Notify peers a post physics collision test enabled or disabled.
You have to call this explicitly if you changed post physics collision tests enabled state.
deeInvalidParam | index is less than 0 or greater than or equal to GetCollisionTestCount(). |
void deCollider::NotifyConstraintChanged | ( | int | index | ) |
Notify peers constraint has changed.
You have to call this explicitly if you changed something on an constraint.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
bool deCollider::PointInside | ( | const decDVector & | point | ) |
Test if a point is located inside the collider.
void deCollider::RayHits | ( | const decDVector & | rayOrigin, |
const decVector & | rayDirection, | ||
deBaseScriptingCollider * | listener | ||
) |
Test ray for collision with the collider.
For each collision deBaseScriptingCollider::CollisionResponse() is called. To stop testing set deCollisionInfo::SetStopTesting() to true. The distance parameter in the collision response represents the actual distance to the ray origin along the ray direction.
void deCollider::RemoveAllAttachments | ( | ) |
Remove all attachments.
void deCollider::RemoveAllCollisionTests | ( | ) |
Remove all post physics collision tests.
void deCollider::RemoveAllConstraints | ( | ) |
Remove all constraints.
void deCollider::RemoveAllIgnoreColliders | ( | ) |
Remove all colliders to ignore.
void deCollider::RemoveAttachment | ( | deColliderAttachment * | attachment | ) |
Remove attachment.
deeInvalidParam | attachment is absent. |
void deCollider::RemoveCollisionTest | ( | deColliderCollisionTest * | collisionTest | ) |
Remove post physics collision test.
deeInvalidParam | collisionTest is absent. |
void deCollider::RemoveConstraint | ( | deColliderConstraint * | constraint | ) |
Remove constraint.
deeInvalidParam | constraint is absent. |
void deCollider::RemoveIgnoreCollider | ( | deCollider * | collider | ) |
Remove collider to ignore.
deeInvalidParam | collider is absent. |
void deCollider::SetAngularVelocity | ( | const decVector & | angVelo | ) |
Set angular velocity in degree/s.
void deCollider::SetCollisionFilter | ( | const decCollisionFilter & | filter | ) |
Set collision filter.
void deCollider::SetEnabled | ( | bool | enabled | ) |
Set if collider is enabled.
Only enabled colliders take part in collision detection and response. Disabled colliders though still update attachments and can be used in manual collision detection.
void deCollider::SetForceFieldDirect | ( | float | factor | ) |
Set factor for direct type force fields.
void deCollider::SetForceFieldMass | ( | float | factor | ) |
Set factor for mass type force fields.
void deCollider::SetForceFieldSpeed | ( | float | factor | ) |
Set factor for speed type force fields.
void deCollider::SetForceFieldSurface | ( | float | factor | ) |
Set factor for surface type force fields.
void deCollider::SetGeometry | ( | const decDVector & | position, |
const decQuaternion & | orientation | ||
) |
Set position and orientation at the same time.
Colliders are the only resources supporting attachments. Using SetPosition() and SetOrientation() causes attachments to be repositions immediately. If many resources are attached to the collider (perhaps even nested) this can reduce performance since attachments are potentially repositioned twice. This call ensures attachments are only repositioned once improving performance.
void deCollider::SetGeometry | ( | const decDVector & | position, |
const decQuaternion & | orientation, | ||
const decVector & | scale | ||
) |
void deCollider::SetGravity | ( | const decVector & | gravity | ) |
Set gravity in m/s^2.
void deCollider::SetLinearVelocity | ( | const decVector & | linVelo | ) |
Set linear velocity in m/s.
void deCollider::SetLLWorldNext | ( | deCollider * | collider | ) |
Set next collider in the parent world linked list.
void deCollider::SetLLWorldPrev | ( | deCollider * | collider | ) |
Set next collider in the parent world linked list.
void deCollider::SetMass | ( | float | mass | ) |
Set mass in kg.
void deCollider::SetOrientation | ( | const decQuaternion & | orientation | ) |
Set orientation.
void deCollider::SetParentWorld | ( | deWorld * | world | ) |
Set parent world or NULL.
void deCollider::SetPeerPhysics | ( | deBasePhysicsCollider * | peer | ) |
Set physics system peer.
void deCollider::SetPeerScripting | ( | deBaseScriptingCollider * | peer | ) |
Set scripting system peer.
void deCollider::SetPosition | ( | const decDVector & | position | ) |
Set central mass point position.
void deCollider::SetResponseType | ( | eResponseType | responseType | ) |
Set Collision response type.
void deCollider::SetScale | ( | const decVector & | scale | ) |
Set scale.
For deColliderComponent the scaling is used from the set deComponent in the first place. The collider scaling is applied on top of it. Hence if you use deColliderComponent with scaled components you do not have to set the scaling on the deColliderComponent. For deColliderVolume and deColliderRig using scaling is required.
void deCollider::SetUseLocalGravity | ( | bool | useLocalGravity | ) |
Set if local gravity is used instead of the world gravity.
|
virtual |
Visit collider.
Reimplemented in deColliderVolume, deColliderRig, and deColliderComponent.
|
friend |