Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
CharacterContactListener Class Reference

This class receives callbacks when a virtual character hits something. More...

#include <CharacterVirtual.h>

Public Member Functions

virtual ~CharacterContactListener ()=default
 Destructor.
 
virtual void OnAdjustBodyVelocity (const CharacterVirtual *inCharacter, const Body &inBody2, Vec3 &ioLinearVelocity, Vec3 &ioAngularVelocity)
 
virtual bool OnContactValidate (const CharacterVirtual *inCharacter, const BodyID &inBodyID2, const SubShapeID &inSubShapeID2)
 Checks if a character can collide with specified body. Return true if the contact is valid.
 
virtual bool OnCharacterContactValidate (const CharacterVirtual *inCharacter, const CharacterVirtual *inOtherCharacter, const SubShapeID &inSubShapeID2)
 Same as OnContactValidate but when colliding with a CharacterVirtual.
 
virtual void OnContactAdded (const CharacterVirtual *inCharacter, const BodyID &inBodyID2, const SubShapeID &inSubShapeID2, RVec3Arg inContactPosition, Vec3Arg inContactNormal, CharacterContactSettings &ioSettings)
 
virtual void OnCharacterContactAdded (const CharacterVirtual *inCharacter, const CharacterVirtual *inOtherCharacter, const SubShapeID &inSubShapeID2, RVec3Arg inContactPosition, Vec3Arg inContactNormal, CharacterContactSettings &ioSettings)
 Same as OnContactAdded but when colliding with a CharacterVirtual.
 
virtual void OnContactSolve (const CharacterVirtual *inCharacter, const BodyID &inBodyID2, const SubShapeID &inSubShapeID2, RVec3Arg inContactPosition, Vec3Arg inContactNormal, Vec3Arg inContactVelocity, const PhysicsMaterial *inContactMaterial, Vec3Arg inCharacterVelocity, Vec3 &ioNewCharacterVelocity)
 
virtual void OnCharacterContactSolve (const CharacterVirtual *inCharacter, const CharacterVirtual *inOtherCharacter, const SubShapeID &inSubShapeID2, RVec3Arg inContactPosition, Vec3Arg inContactNormal, Vec3Arg inContactVelocity, const PhysicsMaterial *inContactMaterial, Vec3Arg inCharacterVelocity, Vec3 &ioNewCharacterVelocity)
 Same as OnContactSolve but when colliding with a CharacterVirtual.
 

Detailed Description

This class receives callbacks when a virtual character hits something.

Constructor & Destructor Documentation

◆ ~CharacterContactListener()

virtual CharacterContactListener::~CharacterContactListener ( )
virtualdefault

Destructor.

Member Function Documentation

◆ OnAdjustBodyVelocity()

virtual void CharacterContactListener::OnAdjustBodyVelocity ( const CharacterVirtual inCharacter,
const Body inBody2,
Vec3 ioLinearVelocity,
Vec3 ioAngularVelocity 
)
inlinevirtual

Callback to adjust the velocity of a body as seen by the character. Can be adjusted to e.g. implement a conveyor belt or an inertial dampener system of a sci-fi space ship. Note that inBody2 is locked during the callback so you can read its properties freely.

◆ OnCharacterContactAdded()

virtual void CharacterContactListener::OnCharacterContactAdded ( const CharacterVirtual inCharacter,
const CharacterVirtual inOtherCharacter,
const SubShapeID inSubShapeID2,
RVec3Arg  inContactPosition,
Vec3Arg  inContactNormal,
CharacterContactSettings ioSettings 
)
inlinevirtual

Same as OnContactAdded but when colliding with a CharacterVirtual.

◆ OnCharacterContactSolve()

virtual void CharacterContactListener::OnCharacterContactSolve ( const CharacterVirtual inCharacter,
const CharacterVirtual inOtherCharacter,
const SubShapeID inSubShapeID2,
RVec3Arg  inContactPosition,
Vec3Arg  inContactNormal,
Vec3Arg  inContactVelocity,
const PhysicsMaterial inContactMaterial,
Vec3Arg  inCharacterVelocity,
Vec3 ioNewCharacterVelocity 
)
inlinevirtual

Same as OnContactSolve but when colliding with a CharacterVirtual.

◆ OnCharacterContactValidate()

virtual bool CharacterContactListener::OnCharacterContactValidate ( const CharacterVirtual inCharacter,
const CharacterVirtual inOtherCharacter,
const SubShapeID inSubShapeID2 
)
inlinevirtual

Same as OnContactValidate but when colliding with a CharacterVirtual.

◆ OnContactAdded()

virtual void CharacterContactListener::OnContactAdded ( const CharacterVirtual inCharacter,
const BodyID inBodyID2,
const SubShapeID inSubShapeID2,
RVec3Arg  inContactPosition,
Vec3Arg  inContactNormal,
CharacterContactSettings ioSettings 
)
inlinevirtual

Called whenever the character collides with a body.

Parameters
inCharacterCharacter that is being solved
inBodyID2Body ID of body that is being hit
inSubShapeID2Sub shape ID of shape that is being hit
inContactPositionWorld space contact position
inContactNormalWorld space contact normal
ioSettingsSettings returned by the contact callback to indicate how the character should behave

◆ OnContactSolve()

virtual void CharacterContactListener::OnContactSolve ( const CharacterVirtual inCharacter,
const BodyID inBodyID2,
const SubShapeID inSubShapeID2,
RVec3Arg  inContactPosition,
Vec3Arg  inContactNormal,
Vec3Arg  inContactVelocity,
const PhysicsMaterial inContactMaterial,
Vec3Arg  inCharacterVelocity,
Vec3 ioNewCharacterVelocity 
)
inlinevirtual

Called whenever a contact is being used by the solver. Allows the listener to override the resulting character velocity (e.g. by preventing sliding along certain surfaces).

Parameters
inCharacterCharacter that is being solved
inBodyID2Body ID of body that is being hit
inSubShapeID2Sub shape ID of shape that is being hit
inContactPositionWorld space contact position
inContactNormalWorld space contact normal
inContactVelocityWorld space velocity of contact point (e.g. for a moving platform)
inContactMaterialMaterial of contact point
inCharacterVelocityWorld space velocity of the character prior to hitting this contact
ioNewCharacterVelocityContains the calculated world space velocity of the character after hitting this contact, this velocity slides along the surface of the contact. Can be modified by the listener to provide an alternative velocity.

◆ OnContactValidate()

virtual bool CharacterContactListener::OnContactValidate ( const CharacterVirtual inCharacter,
const BodyID inBodyID2,
const SubShapeID inSubShapeID2 
)
inlinevirtual

Checks if a character can collide with specified body. Return true if the contact is valid.


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