Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
Character.h
Go to the documentation of this file.
1
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
3
// SPDX-License-Identifier: MIT
4
5
#pragma once
6
7
#include <
Jolt/Physics/Character/CharacterBase.h
>
8
#include <
Jolt/Physics/EActivation.h
>
9
10
JPH_NAMESPACE_BEGIN
11
13
class
JPH_EXPORT
CharacterSettings
:
public
CharacterBaseSettings
14
{
15
public
:
16
JPH_OVERRIDE_NEW_DELETE
17
19
ObjectLayer
mLayer = 0;
20
22
float
mMass = 80.0f;
23
25
float
mFriction = 0.2f;
26
28
float
mGravityFactor = 1.0f;
29
};
30
35
class
JPH_EXPORT
Character
:
public
CharacterBase
36
{
37
public
:
38
JPH_OVERRIDE_NEW_DELETE
39
46
Character
(
const
CharacterSettings
*inSettings,
RVec3Arg
inPosition,
QuatArg
inRotation,
uint64
inUserData,
PhysicsSystem
*inSystem);
47
49
virtual
~Character
()
override
;
50
52
void
AddToPhysicsSystem(
EActivation
inActivationMode =
EActivation::Activate
,
bool
inLockBodies =
true
);
53
55
void
RemoveFromPhysicsSystem(
bool
inLockBodies =
true
);
56
58
void
Activate
(
bool
inLockBodies =
true
);
59
63
void
PostSimulation(
float
inMaxSeparationDistance,
bool
inLockBodies =
true
);
64
66
void
SetLinearAndAngularVelocity(
Vec3Arg
inLinearVelocity,
Vec3Arg
inAngularVelocity,
bool
inLockBodies =
true
);
67
69
Vec3
GetLinearVelocity(
bool
inLockBodies =
true
)
const
;
70
72
void
SetLinearVelocity(
Vec3Arg
inLinearVelocity,
bool
inLockBodies =
true
);
73
75
void
AddLinearVelocity(
Vec3Arg
inLinearVelocity,
bool
inLockBodies =
true
);
76
78
void
AddImpulse(
Vec3Arg
inImpulse,
bool
inLockBodies =
true
);
79
81
BodyID
GetBodyID
()
const
{
return
mBodyID; }
82
84
void
GetPositionAndRotation(
RVec3
&outPosition,
Quat
&outRotation,
bool
inLockBodies =
true
)
const
;
85
87
void
SetPositionAndRotation(
RVec3Arg
inPosition,
QuatArg
inRotation,
EActivation
inActivationMode =
EActivation::Activate
,
bool
inLockBodies =
true
)
const
;
88
90
RVec3
GetPosition(
bool
inLockBodies =
true
)
const
;
91
93
void
SetPosition(
RVec3Arg
inPostion,
EActivation
inActivationMode =
EActivation::Activate
,
bool
inLockBodies =
true
);
94
96
Quat
GetRotation(
bool
inLockBodies =
true
)
const
;
97
99
void
SetRotation(
QuatArg
inRotation,
EActivation
inActivationMode =
EActivation::Activate
,
bool
inLockBodies =
true
);
100
102
RVec3
GetCenterOfMassPosition(
bool
inLockBodies =
true
)
const
;
103
105
RMat44
GetWorldTransform(
bool
inLockBodies =
true
)
const
;
106
108
void
SetLayer(
ObjectLayer
inLayer,
bool
inLockBodies =
true
);
109
112
bool
SetShape(
const
Shape
*inShape,
float
inMaxPenetrationDepth,
bool
inLockBodies =
true
);
113
123
void
CheckCollision(
RVec3Arg
inPosition,
QuatArg
inRotation,
Vec3Arg
inMovementDirection,
float
inMaxSeparationDistance,
const
Shape
*inShape,
RVec3Arg
inBaseOffset,
CollideShapeCollector
&ioCollector,
bool
inLockBodies =
true
)
const
;
124
125
private
:
127
void
CheckCollision(
RMat44Arg
inCenterOfMassTransform,
Vec3Arg
inMovementDirection,
float
inMaxSeparationDistance,
const
Shape
*inShape,
RVec3Arg
inBaseOffset,
CollideShapeCollector
&ioCollector,
bool
inLockBodies)
const
;
128
130
void
CheckCollision(
const
Shape
*inShape,
float
inMaxSeparationDistance,
RVec3Arg
inBaseOffset,
CollideShapeCollector
&ioCollector,
bool
inLockBodies)
const
;
131
133
BodyID
mBodyID;
134
136
ObjectLayer
mLayer;
137
};
138
139
JPH_NAMESPACE_END
CharacterBase.h
JPH_EXPORT
#define JPH_EXPORT
Definition
Core.h:214
uint64
std::uint64_t uint64
Definition
Core.h:430
JPH_NAMESPACE_END
#define JPH_NAMESPACE_END
Definition
Core.h:354
JPH_NAMESPACE_BEGIN
#define JPH_NAMESPACE_BEGIN
Definition
Core.h:348
EActivation.h
EActivation
EActivation
Enum used by AddBody to determine if the body needs to be initially active.
Definition
EActivation.h:11
EActivation::Activate
@ Activate
Activate the body, making it part of the simulation.
JPH_OVERRIDE_NEW_DELETE
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition
Memory.h:29
ObjectLayer
uint16 ObjectLayer
Definition
ObjectLayer.h:16
BodyID
ID of a body. This is a way of reasoning about bodies in a multithreaded simulation while avoiding ra...
Definition
BodyID.h:13
CharacterBase
Base class for character class.
Definition
CharacterBase.h:51
CharacterBaseSettings
Base class for configuration of a character.
Definition
CharacterBase.h:21
Character
Definition
Character.h:36
Character::GetBodyID
BodyID GetBodyID() const
Get the body associated with this character.
Definition
Character.h:81
CharacterSettings
Contains the configuration of a character.
Definition
Character.h:14
CollisionCollector
Virtual interface that allows collecting multiple collision results.
Definition
CollisionCollector.h:45
Mat44
Holds a 4x4 matrix of floats, but supports also operations on the 3x3 upper left part of the matrix.
Definition
Mat44.h:13
PhysicsSystem
Definition
PhysicsSystem.h:28
Quat
Definition
Quat.h:33
Shape
Base class for all shapes (collision volume of a body). Defines a virtual interface for collision det...
Definition
Shape.h:174
Vec3
Definition
Vec3.h:16
Jolt
Physics
Character
Character.h
Generated by
1.10.0