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/Collision/ObjectLayer.h
>
9
#include <
Jolt/Physics/Collision/TransformedShape.h
>
10
#include <
Jolt/Physics/EActivation.h
>
11
12
JPH_NAMESPACE_BEGIN
13
15
class
JPH_EXPORT
CharacterSettings
:
public
CharacterBaseSettings
16
{
17
public
:
18
JPH_OVERRIDE_NEW_DELETE
19
21
ObjectLayer
mLayer = 0;
22
24
float
mMass = 80.0f;
25
27
float
mFriction = 0.2f;
28
30
float
mGravityFactor = 1.0f;
31
};
32
37
class
JPH_EXPORT
Character
:
public
CharacterBase
38
{
39
public
:
40
JPH_OVERRIDE_NEW_DELETE
41
48
Character
(
const
CharacterSettings
*inSettings,
RVec3Arg
inPosition,
QuatArg
inRotation,
uint64
inUserData,
PhysicsSystem
*inSystem);
49
51
virtual
~Character
()
override
;
52
54
void
AddToPhysicsSystem(
EActivation
inActivationMode =
EActivation::Activate
,
bool
inLockBodies =
true
);
55
57
void
RemoveFromPhysicsSystem(
bool
inLockBodies =
true
);
58
60
void
Activate
(
bool
inLockBodies =
true
);
61
65
void
PostSimulation(
float
inMaxSeparationDistance,
bool
inLockBodies =
true
);
66
68
void
SetLinearAndAngularVelocity(
Vec3Arg
inLinearVelocity,
Vec3Arg
inAngularVelocity,
bool
inLockBodies =
true
);
69
71
Vec3
GetLinearVelocity(
bool
inLockBodies =
true
)
const
;
72
74
void
SetLinearVelocity(
Vec3Arg
inLinearVelocity,
bool
inLockBodies =
true
);
75
77
void
AddLinearVelocity(
Vec3Arg
inLinearVelocity,
bool
inLockBodies =
true
);
78
80
void
AddImpulse(
Vec3Arg
inImpulse,
bool
inLockBodies =
true
);
81
83
BodyID
GetBodyID
()
const
{
return
mBodyID; }
84
86
void
GetPositionAndRotation(
RVec3
&outPosition,
Quat
&outRotation,
bool
inLockBodies =
true
)
const
;
87
89
void
SetPositionAndRotation(
RVec3Arg
inPosition,
QuatArg
inRotation,
EActivation
inActivationMode =
EActivation::Activate
,
bool
inLockBodies =
true
)
const
;
90
92
RVec3
GetPosition(
bool
inLockBodies =
true
)
const
;
93
95
void
SetPosition(
RVec3Arg
inPostion,
EActivation
inActivationMode =
EActivation::Activate
,
bool
inLockBodies =
true
);
96
98
Quat
GetRotation(
bool
inLockBodies =
true
)
const
;
99
101
void
SetRotation(
QuatArg
inRotation,
EActivation
inActivationMode =
EActivation::Activate
,
bool
inLockBodies =
true
);
102
104
RVec3
GetCenterOfMassPosition(
bool
inLockBodies =
true
)
const
;
105
107
RMat44
GetWorldTransform(
bool
inLockBodies =
true
)
const
;
108
110
ObjectLayer
GetLayer
()
const
{
return
mLayer; }
111
113
void
SetLayer(
ObjectLayer
inLayer,
bool
inLockBodies =
true
);
114
117
bool
SetShape(
const
Shape
*inShape,
float
inMaxPenetrationDepth,
bool
inLockBodies =
true
);
118
120
TransformedShape
GetTransformedShape(
bool
inLockBodies =
true
)
const
;
121
131
void
CheckCollision(
RVec3Arg
inPosition,
QuatArg
inRotation,
Vec3Arg
inMovementDirection,
float
inMaxSeparationDistance,
const
Shape
*inShape,
RVec3Arg
inBaseOffset,
CollideShapeCollector
&ioCollector,
bool
inLockBodies =
true
)
const
;
132
133
private
:
135
void
CheckCollision(
RMat44Arg
inCenterOfMassTransform,
Vec3Arg
inMovementDirection,
float
inMaxSeparationDistance,
const
Shape
*inShape,
RVec3Arg
inBaseOffset,
CollideShapeCollector
&ioCollector,
bool
inLockBodies)
const
;
136
138
void
CheckCollision(
const
Shape
*inShape,
float
inMaxSeparationDistance,
RVec3Arg
inBaseOffset,
CollideShapeCollector
&ioCollector,
bool
inLockBodies)
const
;
139
141
BodyID
mBodyID;
142
144
ObjectLayer
mLayer;
145
};
146
147
JPH_NAMESPACE_END
CharacterBase.h
JPH_EXPORT
#define JPH_EXPORT
Definition
Core.h:236
uint64
std::uint64_t uint64
Definition
Core.h:457
JPH_NAMESPACE_END
#define JPH_NAMESPACE_END
Definition
Core.h:379
JPH_NAMESPACE_BEGIN
#define JPH_NAMESPACE_BEGIN
Definition
Core.h:373
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:31
ObjectLayer.h
ObjectLayer
uint16 ObjectLayer
Definition
ObjectLayer.h:16
TransformedShape.h
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:54
CharacterBaseSettings
Base class for configuration of a character.
Definition
CharacterBase.h:21
Character
Definition
Character.h:38
Character::GetBodyID
BodyID GetBodyID() const
Get the body associated with this character.
Definition
Character.h:83
Character::GetLayer
ObjectLayer GetLayer() const
Get the layer of the character.
Definition
Character.h:110
CharacterSettings
Contains the configuration of a character.
Definition
Character.h:16
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:29
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:186
TransformedShape
Definition
TransformedShape.h:26
Vec3
Definition
Vec3.h:17
Jolt
Physics
Character
Character.h
Generated by
1.9.8