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

Base class for character class. More...

#include <CharacterBase.h>

Inheritance diagram for CharacterBase:
RefTarget< CharacterBase > NonCopyable Character CharacterVirtual

Public Types

enum class  EGroundState { OnGround , OnSteepGround , NotSupported , InAir }
 

Public Member Functions

JPH_OVERRIDE_NEW_DELETE CharacterBase (const CharacterBaseSettings *inSettings, PhysicsSystem *inSystem)
 Constructor.
 
virtual ~CharacterBase ()=default
 Destructor.
 
void SetMaxSlopeAngle (float inMaxSlopeAngle)
 Set the maximum angle of slope that character can still walk on (radians)
 
float GetCosMaxSlopeAngle () const
 
void SetUp (Vec3Arg inUp)
 Set the up vector for the character.
 
Vec3 GetUp () const
 
bool IsSlopeTooSteep (Vec3Arg inNormal) const
 Check if the normal of the ground surface is too steep to walk on.
 
const ShapeGetShape () const
 Get the current shape that the character is using.
 
- Public Member Functions inherited from RefTarget< CharacterBase >
 RefTarget ()=default
 Constructor.
 
 RefTarget (const RefTarget &)
 
 ~RefTarget ()
 assert no one is referencing us
 
void SetEmbedded () const
 
RefTargetoperator= (const RefTarget &)
 Assignment operator.
 
uint32 GetRefCount () const
 Get current refcount of this object.
 
void AddRef () const
 Add or release a reference to this object.
 
void Release () const
 
- Public Member Functions inherited from NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
void operator= (const NonCopyable &)=delete
 

Static Public Member Functions

static const char * sToString (EGroundState inState)
 Debug function to convert enum values to string.
 
- Static Public Member Functions inherited from RefTarget< CharacterBase >
static int sInternalGetRefCountOffset ()
 INTERNAL HELPER FUNCTION USED BY SERIALIZATION.
 

Properties of the ground this character is standing on

PhysicsSystemmSystem
 
RefConst< ShapemShape
 
Vec3 mUp
 
Plane mSupportingVolume
 
float mCosMaxSlopeAngle
 
EGroundState mGroundState = EGroundState::InAir
 
BodyID mGroundBodyID
 
SubShapeID mGroundBodySubShapeID
 
RVec3 mGroundPosition = RVec3::sZero()
 
Vec3 mGroundNormal = Vec3::sZero()
 
Vec3 mGroundVelocity = Vec3::sZero()
 
RefConst< PhysicsMaterialmGroundMaterial = PhysicsMaterial::sDefault
 
uint64 mGroundUserData = 0
 
static constexpr float cNoMaxSlopeAngle = 0.9999f
 
EGroundState GetGroundState () const
 Current ground state.
 
bool IsSupported () const
 Returns true if the player is supported by normal or steep ground.
 
RVec3 GetGroundPosition () const
 Get the contact point with the ground.
 
Vec3 GetGroundNormal () const
 Get the contact normal with the ground.
 
Vec3 GetGroundVelocity () const
 Velocity in world space of ground.
 
const PhysicsMaterialGetGroundMaterial () const
 Material that the character is standing on.
 
BodyID GetGroundBodyID () const
 BodyID of the object the character is standing on. Note may have been removed!
 
SubShapeID GetGroundSubShapeID () const
 Sub part of the body that we're standing on.
 
uint64 GetGroundUserData () const
 User data value of the body that we're standing on.
 
virtual void SaveState (StateRecorder &inStream) const
 
virtual void RestoreState (StateRecorder &inStream)
 

Additional Inherited Members

- Protected Attributes inherited from RefTarget< CharacterBase >
atomic< uint32mRefCount
 Current reference count.
 
- Static Protected Attributes inherited from RefTarget< CharacterBase >
static constexpr uint32 cEmbedded
 A large value that gets added to the refcount to mark the object as embedded.
 

Detailed Description

Base class for character class.

Member Enumeration Documentation

◆ EGroundState

enum class CharacterBase::EGroundState
strong
Enumerator
OnGround 

Character is on the ground and can move freely.

OnSteepGround 

Character is on a slope that is too steep and can't climb up any further. The caller should start applying downward velocity if sliding from the slope is desired.

NotSupported 

Character is touching an object, but is not supported by it and should fall. The GetGroundXXX functions will return information about the touched object.

InAir 

Character is in the air and is not touching anything.

Constructor & Destructor Documentation

◆ CharacterBase()

JPH_NAMESPACE_BEGIN CharacterBase::CharacterBase ( const CharacterBaseSettings inSettings,
PhysicsSystem inSystem 
)

Constructor.

◆ ~CharacterBase()

virtual CharacterBase::~CharacterBase ( )
virtualdefault

Destructor.

Member Function Documentation

◆ GetCosMaxSlopeAngle()

float CharacterBase::GetCosMaxSlopeAngle ( ) const
inline

◆ GetGroundBodyID()

BodyID CharacterBase::GetGroundBodyID ( ) const
inline

BodyID of the object the character is standing on. Note may have been removed!

◆ GetGroundMaterial()

const PhysicsMaterial * CharacterBase::GetGroundMaterial ( ) const
inline

Material that the character is standing on.

◆ GetGroundNormal()

Vec3 CharacterBase::GetGroundNormal ( ) const
inline

Get the contact normal with the ground.

◆ GetGroundPosition()

RVec3 CharacterBase::GetGroundPosition ( ) const
inline

Get the contact point with the ground.

◆ GetGroundState()

EGroundState CharacterBase::GetGroundState ( ) const
inline

Current ground state.

◆ GetGroundSubShapeID()

SubShapeID CharacterBase::GetGroundSubShapeID ( ) const
inline

Sub part of the body that we're standing on.

◆ GetGroundUserData()

uint64 CharacterBase::GetGroundUserData ( ) const
inline

User data value of the body that we're standing on.

◆ GetGroundVelocity()

Vec3 CharacterBase::GetGroundVelocity ( ) const
inline

Velocity in world space of ground.

◆ GetShape()

const Shape * CharacterBase::GetShape ( ) const
inline

Get the current shape that the character is using.

◆ GetUp()

Vec3 CharacterBase::GetUp ( ) const
inline

◆ IsSlopeTooSteep()

bool CharacterBase::IsSlopeTooSteep ( Vec3Arg  inNormal) const
inline

Check if the normal of the ground surface is too steep to walk on.

◆ IsSupported()

bool CharacterBase::IsSupported ( ) const
inline

Returns true if the player is supported by normal or steep ground.

◆ RestoreState()

void CharacterBase::RestoreState ( StateRecorder inStream)
virtual

Reimplemented in CharacterVirtual.

◆ SaveState()

void CharacterBase::SaveState ( StateRecorder inStream) const
virtual

Reimplemented in CharacterVirtual.

◆ SetMaxSlopeAngle()

void CharacterBase::SetMaxSlopeAngle ( float  inMaxSlopeAngle)
inline

Set the maximum angle of slope that character can still walk on (radians)

◆ SetUp()

void CharacterBase::SetUp ( Vec3Arg  inUp)
inline

Set the up vector for the character.

◆ sToString()

const char * CharacterBase::sToString ( EGroundState  inState)
static

Debug function to convert enum values to string.

Member Data Documentation

◆ cNoMaxSlopeAngle

constexpr float CharacterBase::cNoMaxSlopeAngle = 0.9999f
staticconstexprprotected

◆ mCosMaxSlopeAngle

float CharacterBase::mCosMaxSlopeAngle
protected

◆ mGroundBodyID

BodyID CharacterBase::mGroundBodyID
protected

◆ mGroundBodySubShapeID

SubShapeID CharacterBase::mGroundBodySubShapeID
protected

◆ mGroundMaterial

RefConst<PhysicsMaterial> CharacterBase::mGroundMaterial = PhysicsMaterial::sDefault
protected

◆ mGroundNormal

Vec3 CharacterBase::mGroundNormal = Vec3::sZero()
protected

◆ mGroundPosition

RVec3 CharacterBase::mGroundPosition = RVec3::sZero()
protected

◆ mGroundState

EGroundState CharacterBase::mGroundState = EGroundState::InAir
protected

◆ mGroundUserData

uint64 CharacterBase::mGroundUserData = 0
protected

◆ mGroundVelocity

Vec3 CharacterBase::mGroundVelocity = Vec3::sZero()
protected

◆ mShape

RefConst<Shape> CharacterBase::mShape
protected

◆ mSupportingVolume

Plane CharacterBase::mSupportingVolume
protected

◆ mSystem

PhysicsSystem* CharacterBase::mSystem
protected

◆ mUp

Vec3 CharacterBase::mUp
protected

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