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
12
14
17{
18public:
20
22 ObjectLayer mLayer = 0;
23
25 float mMass = 80.0f;
26
28 float mFriction = 0.2f;
29
31 float mGravityFactor = 1.0f;
32
35};
36
42{
43public:
45
52 Character(const CharacterSettings *inSettings, RVec3Arg inPosition, QuatArg inRotation, uint64 inUserData, PhysicsSystem *inSystem);
53
55 virtual ~Character() override;
56
58 void AddToPhysicsSystem(EActivation inActivationMode = EActivation::Activate, bool inLockBodies = true);
59
61 void RemoveFromPhysicsSystem(bool inLockBodies = true);
62
64 void Activate(bool inLockBodies = true);
65
69 void PostSimulation(float inMaxSeparationDistance, bool inLockBodies = true);
70
72 void SetLinearAndAngularVelocity(Vec3Arg inLinearVelocity, Vec3Arg inAngularVelocity, bool inLockBodies = true);
73
75 Vec3 GetLinearVelocity(bool inLockBodies = true) const;
76
78 void SetLinearVelocity(Vec3Arg inLinearVelocity, bool inLockBodies = true);
79
81 void AddLinearVelocity(Vec3Arg inLinearVelocity, bool inLockBodies = true);
82
84 void AddImpulse(Vec3Arg inImpulse, bool inLockBodies = true);
85
87 BodyID GetBodyID() const { return mBodyID; }
88
90 void GetPositionAndRotation(RVec3 &outPosition, Quat &outRotation, bool inLockBodies = true) const;
91
93 void SetPositionAndRotation(RVec3Arg inPosition, QuatArg inRotation, EActivation inActivationMode = EActivation::Activate, bool inLockBodies = true) const;
94
96 RVec3 GetPosition(bool inLockBodies = true) const;
97
99 void SetPosition(RVec3Arg inPosition, EActivation inActivationMode = EActivation::Activate, bool inLockBodies = true);
100
102 Quat GetRotation(bool inLockBodies = true) const;
103
105 void SetRotation(QuatArg inRotation, EActivation inActivationMode = EActivation::Activate, bool inLockBodies = true);
106
108 RVec3 GetCenterOfMassPosition(bool inLockBodies = true) const;
109
111 RMat44 GetWorldTransform(bool inLockBodies = true) const;
112
114 ObjectLayer GetLayer() const { return mLayer; }
115
117 void SetLayer(ObjectLayer inLayer, bool inLockBodies = true);
118
121 bool SetShape(const Shape *inShape, float inMaxPenetrationDepth, bool inLockBodies = true);
122
124 TransformedShape GetTransformedShape(bool inLockBodies = true) const;
125
135 void CheckCollision(RVec3Arg inPosition, QuatArg inRotation, Vec3Arg inMovementDirection, float inMaxSeparationDistance, const Shape *inShape, RVec3Arg inBaseOffset, CollideShapeCollector &ioCollector, bool inLockBodies = true) const;
136
137private:
139 void CheckCollision(RMat44Arg inCenterOfMassTransform, Vec3Arg inMovementDirection, float inMaxSeparationDistance, const Shape *inShape, RVec3Arg inBaseOffset, CollideShapeCollector &ioCollector, bool inLockBodies) const;
140
142 void CheckCollision(const Shape *inShape, float inMaxSeparationDistance, RVec3Arg inBaseOffset, CollideShapeCollector &ioCollector, bool inLockBodies) const;
143
145 BodyID mBodyID;
146
148 ObjectLayer mLayer;
149};
150
EAllowedDOFs
Enum used in BodyCreationSettings and MotionProperties to indicate which degrees of freedom a body ha...
Definition AllowedDOFs.h:11
@ TranslationY
Body can move in world space Y axis.
@ TranslationZ
Body can move in world space Z axis.
@ TranslationX
Body can move in world space X axis.
#define JPH_EXPORT
Definition Core.h:271
std::uint64_t uint64
Definition Core.h:485
#define JPH_NAMESPACE_END
Definition Core.h:414
#define JPH_NAMESPACE_BEGIN
Definition Core.h:408
EActivation
Enum used by AddBody to determine if the body needs to be initially active.
Definition EActivation.h:11
@ Activate
Activate the body, making it part of the simulation.
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition Memory.h:31
uint16 ObjectLayer
Definition ObjectLayer.h:16
ID of a body. This is a way of reasoning about bodies in a multithreaded simulation while avoiding ra...
Definition BodyID.h:13
Base class for character class.
Definition CharacterBase.h:54
Base class for configuration of a character.
Definition CharacterBase.h:21
Definition Character.h:42
BodyID GetBodyID() const
Get the body associated with this character.
Definition Character.h:87
ObjectLayer GetLayer() const
Get the layer of the character.
Definition Character.h:114
Contains the configuration of a character.
Definition Character.h:17
Virtual interface that allows collecting multiple collision results.
Definition CollisionCollector.h:45
Holds a 4x4 matrix of floats, but supports also operations on the 3x3 upper left part of the matrix.
Definition Mat44.h:13
Definition PhysicsSystem.h:30
Definition Quat.h:33
Base class for all shapes (collision volume of a body). Defines a virtual interface for collision det...
Definition Shape.h:186
Definition TransformedShape.h:26
Definition Vec3.h:17