Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
CharacterVirtual.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
13
15
17
20{
21public:
23
25 float mMass = 70.0f;
26
28 float mMaxStrength = 100.0f;
29
31 Vec3 mShapeOffset = Vec3::sZero();
32
34 EBackFaceMode mBackFaceMode = EBackFaceMode::CollideWithBackFaces;
35 float mPredictiveContactDistance = 0.1f;
36 uint mMaxCollisionIterations = 5;
37 uint mMaxConstraintIterations = 15;
38 float mMinTimeRemaining = 1.0e-4f;
39 float mCollisionTolerance = 1.0e-3f;
40 float mCharacterPadding = 0.02f;
41 uint mMaxNumHits = 256;
42 float mHitReductionCosMaxAngle = 0.999f;
43 float mPenetrationRecoverySpeed = 1.0f;
44};
45
48{
49public:
50 bool mCanPushCharacter = true;
51 bool mCanReceiveImpulses = true;
52};
53
56{
57public:
59 virtual ~CharacterContactListener() = default;
60
63 virtual void OnAdjustBodyVelocity(const CharacterVirtual *inCharacter, const Body &inBody2, Vec3 &ioLinearVelocity, Vec3 &ioAngularVelocity) { /* Do nothing, the linear and angular velocity are already filled in */ }
64
66 virtual bool OnContactValidate(const CharacterVirtual *inCharacter, const BodyID &inBodyID2, const SubShapeID &inSubShapeID2) { return true; }
67
75 virtual void OnContactAdded(const CharacterVirtual *inCharacter, const BodyID &inBodyID2, const SubShapeID &inSubShapeID2, RVec3Arg inContactPosition, Vec3Arg inContactNormal, CharacterContactSettings &ioSettings) { /* Default do nothing */ }
76
87 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) { /* Default do nothing */ }
88};
89
96{
97public:
99
105 CharacterVirtual(const CharacterVirtualSettings *inSettings, RVec3Arg inPosition, QuatArg inRotation, PhysicsSystem *inSystem);
106
108 void SetListener(CharacterContactListener *inListener) { mListener = inListener; }
109
111 CharacterContactListener * GetListener() const { return mListener; }
112
114 Vec3 GetLinearVelocity() const { return mLinearVelocity; }
115
117 void SetLinearVelocity(Vec3Arg inLinearVelocity) { mLinearVelocity = inLinearVelocity; }
118
120 RVec3 GetPosition() const { return mPosition; }
121
123 void SetPosition(RVec3Arg inPosition) { mPosition = inPosition; }
124
126 Quat GetRotation() const { return mRotation; }
127
129 void SetRotation(QuatArg inRotation) { mRotation = inRotation; }
130
132 RMat44 GetWorldTransform() const { return RMat44::sRotationTranslation(mRotation, mPosition); }
133
135 RMat44 GetCenterOfMassTransform() const { return GetCenterOfMassTransform(mPosition, mRotation, mShape); }
136
138 float GetMass() const { return mMass; }
139 void SetMass(float inMass) { mMass = inMass; }
140
142 float GetMaxStrength() const { return mMaxStrength; }
143 void SetMaxStrength(float inMaxStrength) { mMaxStrength = inMaxStrength; }
144
146 float GetPenetrationRecoverySpeed() const { return mPenetrationRecoverySpeed; }
147 void SetPenetrationRecoverySpeed(float inSpeed) { mPenetrationRecoverySpeed = inSpeed; }
148
150 float GetCharacterPadding() const { return mCharacterPadding; }
151
153 uint GetMaxNumHits() const { return mMaxNumHits; }
154 void SetMaxNumHits(uint inMaxHits) { mMaxNumHits = inMaxHits; }
155
157 float GetHitReductionCosMaxAngle() const { return mHitReductionCosMaxAngle; }
158 void SetHitReductionCosMaxAngle(float inCosMaxAngle) { mHitReductionCosMaxAngle = inCosMaxAngle; }
159
164 bool GetMaxHitsExceeded() const { return mMaxHitsExceeded; }
165
167 Vec3 GetShapeOffset() const { return mShapeOffset; }
168 void SetShapeOffset(Vec3Arg inShapeOffset) { mShapeOffset = inShapeOffset; }
169
174 Vec3 CancelVelocityTowardsSteepSlopes(Vec3Arg inDesiredVelocity) const;
175
186 void Update(float inDeltaTime, Vec3Arg inGravity, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter, TempAllocator &inAllocator);
187
191 bool CanWalkStairs(Vec3Arg inLinearVelocity) const;
192
205 bool WalkStairs(float inDeltaTime, Vec3Arg inStepUp, Vec3Arg inStepForward, Vec3Arg inStepForwardTest, Vec3Arg inStepDownExtra, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter, TempAllocator &inAllocator);
206
217 bool StickToFloor(Vec3Arg inStepDown, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter, TempAllocator &inAllocator);
218
221 {
222 Vec3 mStickToFloorStepDown { 0, -0.5f, 0 };
223 Vec3 mWalkStairsStepUp { 0, 0.4f, 0 };
224 float mWalkStairsMinStepForward { 0.02f };
225 float mWalkStairsStepForwardTest { 0.15f };
226 float mWalkStairsCosAngleForwardContact { Cos(DegreesToRadians(75.0f)) };
227 Vec3 mWalkStairsStepDownExtra { Vec3::sZero() };
228 };
229
242 void ExtendedUpdate(float inDeltaTime, Vec3Arg inGravity, const ExtendedUpdateSettings &inSettings, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter, TempAllocator &inAllocator);
243
245 void RefreshContacts(const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter, TempAllocator &inAllocator);
246
249 void UpdateGroundVelocity();
250
260 bool SetShape(const Shape *inShape, float inMaxPenetrationDepth, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter, TempAllocator &inAllocator);
261
274 void CheckCollision(RVec3Arg inPosition, QuatArg inRotation, Vec3Arg inMovementDirection, float inMaxSeparationDistance, const Shape *inShape, RVec3Arg inBaseOffset, CollideShapeCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter) const;
275
276 // Saving / restoring state for replay
277 virtual void SaveState(StateRecorder &inStream) const override;
278 virtual void RestoreState(StateRecorder &inStream) override;
279
280#ifdef JPH_DEBUG_RENDERER
281 static inline bool sDrawConstraints = false;
282 static inline bool sDrawWalkStairs = false;
283 static inline bool sDrawStickToFloor = false;
284#endif
285
286 // Encapsulates a collision contact
287 struct Contact
288 {
289 // Saving / restoring state for replay
290 void SaveState(StateRecorder &inStream) const;
291 void RestoreState(StateRecorder &inStream);
292
297 float mDistance;
298 float mFraction;
304 bool mHadCollision = false;
305 bool mWasDiscarded = false;
306 bool mCanPushCharacter = true;
307 };
308
309 using TempContactList = std::vector<Contact, STLTempAllocator<Contact>>;
311
313 const ContactList & GetActiveContacts() const { return mActiveContacts; }
314
315private:
316 // Sorting predicate for making contact order deterministic
317 struct ContactOrderingPredicate
318 {
319 inline bool operator () (const Contact &inLHS, const Contact &inRHS) const
320 {
321 if (inLHS.mBodyB != inRHS.mBodyB)
322 return inLHS.mBodyB < inRHS.mBodyB;
323
324 return inLHS.mSubShapeIDB.GetValue() < inRHS.mSubShapeIDB.GetValue();
325 }
326 };
327
328 // A contact that needs to be ignored
329 struct IgnoredContact
330 {
331 IgnoredContact() = default;
332 IgnoredContact(const BodyID &inBodyID, const SubShapeID &inSubShapeID) : mBodyID(inBodyID), mSubShapeID(inSubShapeID) { }
333
334 BodyID mBodyID;
335 SubShapeID mSubShapeID;
336 };
337
338 using IgnoredContactList = std::vector<IgnoredContact, STLTempAllocator<IgnoredContact>>;
339
340 // A constraint that limits the movement of the character
341 struct Constraint
342 {
343 Contact * mContact;
344 float mTOI;
345 float mProjectedVelocity;
346 Vec3 mLinearVelocity;
347 Plane mPlane;
348 bool mIsSteepSlope = false;
349 };
350
351 using ConstraintList = std::vector<Constraint, STLTempAllocator<Constraint>>;
352
353 // Collision collector that collects hits for CollideShape
354 class ContactCollector : public CollideShapeCollector
355 {
356 public:
357 ContactCollector(PhysicsSystem *inSystem, const CharacterVirtual *inCharacter, uint inMaxHits, float inHitReductionCosMaxAngle, Vec3Arg inUp, RVec3Arg inBaseOffset, TempContactList &outContacts) : mBaseOffset(inBaseOffset), mUp(inUp), mSystem(inSystem), mCharacter(inCharacter), mContacts(outContacts), mMaxHits(inMaxHits), mHitReductionCosMaxAngle(inHitReductionCosMaxAngle) { }
358
359 virtual void AddHit(const CollideShapeResult &inResult) override;
360
361 RVec3 mBaseOffset;
362 Vec3 mUp;
363 PhysicsSystem * mSystem;
364 const CharacterVirtual * mCharacter;
365 TempContactList & mContacts;
366 uint mMaxHits;
367 float mHitReductionCosMaxAngle;
368 bool mMaxHitsExceeded = false;
369 };
370
371 // A collision collector that collects hits for CastShape
372 class ContactCastCollector : public CastShapeCollector
373 {
374 public:
375 ContactCastCollector(PhysicsSystem *inSystem, const CharacterVirtual *inCharacter, Vec3Arg inDisplacement, Vec3Arg inUp, const IgnoredContactList &inIgnoredContacts, RVec3Arg inBaseOffset, Contact &outContact) : mBaseOffset(inBaseOffset), mDisplacement(inDisplacement), mUp(inUp), mSystem(inSystem), mCharacter(inCharacter), mIgnoredContacts(inIgnoredContacts), mContact(outContact) { }
376
377 virtual void AddHit(const ShapeCastResult &inResult) override;
378
379 RVec3 mBaseOffset;
380 Vec3 mDisplacement;
381 Vec3 mUp;
382 PhysicsSystem * mSystem;
383 const CharacterVirtual * mCharacter;
384 const IgnoredContactList & mIgnoredContacts;
385 Contact & mContact;
386 };
387
388 // Helper function to convert a Jolt collision result into a contact
389 template <class taCollector>
390 inline static void sFillContactProperties(const CharacterVirtual *inCharacter, Contact &outContact, const Body &inBody, Vec3Arg inUp, RVec3Arg inBaseOffset, const taCollector &inCollector, const CollideShapeResult &inResult);
391
392 // Move the shape from ioPosition and try to displace it by inVelocity * inDeltaTime, this will try to slide the shape along the world geometry
393 void MoveShape(RVec3 &ioPosition, Vec3Arg inVelocity, float inDeltaTime, ContactList *outActiveContacts, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter, TempAllocator &inAllocator
394 #ifdef JPH_DEBUG_RENDERER
395 , bool inDrawConstraints = false
396 #endif // JPH_DEBUG_RENDERER
397 ) const;
398
399 // Ask the callback if inContact is a valid contact point
400 bool ValidateContact(const Contact &inContact) const;
401
402 // Tests the shape for collision around inPosition
403 void GetContactsAtPosition(RVec3Arg inPosition, Vec3Arg inMovementDirection, const Shape *inShape, TempContactList &outContacts, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter) const;
404
405 // Remove penetrating contacts with the same body that have conflicting normals, leaving these will make the character mover get stuck
406 void RemoveConflictingContacts(TempContactList &ioContacts, IgnoredContactList &outIgnoredContacts) const;
407
408 // Convert contacts into constraints. The character is assumed to start at the origin and the constraints are planes around the origin that confine the movement of the character.
409 void DetermineConstraints(TempContactList &inContacts, float inDeltaTime, ConstraintList &outConstraints) const;
410
411 // Use the constraints to solve the displacement of the character. This will slide the character on the planes around the origin for as far as possible.
412 void SolveConstraints(Vec3Arg inVelocity, float inDeltaTime, float inTimeRemaining, ConstraintList &ioConstraints, IgnoredContactList &ioIgnoredContacts, float &outTimeSimulated, Vec3 &outDisplacement, TempAllocator &inAllocator
413 #ifdef JPH_DEBUG_RENDERER
414 , bool inDrawConstraints = false
415 #endif // JPH_DEBUG_RENDERER
416 ) const;
417
418 // Get the velocity of a body adjusted by the contact listener
419 void GetAdjustedBodyVelocity(const Body& inBody, Vec3 &outLinearVelocity, Vec3 &outAngularVelocity) const;
420
421 // Calculate the ground velocity of the character assuming it's standing on an object with specified linear and angular velocity and with specified center of mass.
422 // Note that we don't just take the point velocity because a point on an object with angular velocity traces an arc,
423 // so if you just take point velocity * delta time you get an error that accumulates over time
424 Vec3 CalculateCharacterGroundVelocity(RVec3Arg inCenterOfMass, Vec3Arg inLinearVelocity, Vec3Arg inAngularVelocity, float inDeltaTime) const;
425
426 // Handle contact with physics object that we're colliding against
427 bool HandleContact(Vec3Arg inVelocity, Constraint &ioConstraint, float inDeltaTime) const;
428
429 // Does a swept test of the shape from inPosition with displacement inDisplacement, returns true if there was a collision
430 bool GetFirstContactForSweep(RVec3Arg inPosition, Vec3Arg inDisplacement, Contact &outContact, const IgnoredContactList &inIgnoredContacts, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter) const;
431
432 // Store contacts so that we have proper ground information
433 void StoreActiveContacts(const TempContactList &inContacts, TempAllocator &inAllocator);
434
435 // This function will determine which contacts are touching the character and will calculate the one that is supporting us
436 void UpdateSupportingContact(bool inSkipContactVelocityCheck, TempAllocator &inAllocator);
437
439 void MoveToContact(RVec3Arg inPosition, const Contact &inContact, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter, TempAllocator &inAllocator);
440
441 // This function returns the actual center of mass of the shape, not corrected for the character padding
442 inline RMat44 GetCenterOfMassTransform(RVec3Arg inPosition, QuatArg inRotation, const Shape *inShape) const
443 {
444 return RMat44::sRotationTranslation(inRotation, inPosition).PreTranslated(mShapeOffset + inShape->GetCenterOfMass()).PostTranslated(mCharacterPadding * mUp);
445 }
446
447 // Our main listener for contacts
448 CharacterContactListener * mListener = nullptr;
449
450 // Movement settings
451 EBackFaceMode mBackFaceMode; // When colliding with back faces, the character will not be able to move through back facing triangles. Use this if you have triangles that need to collide on both sides.
452 float mPredictiveContactDistance; // How far to scan outside of the shape for predictive contacts. A value of 0 will most likely cause the character to get stuck as it properly calculate a sliding direction anymore. A value that's too high will cause ghost collisions.
453 uint mMaxCollisionIterations; // Max amount of collision loops
454 uint mMaxConstraintIterations; // How often to try stepping in the constraint solving
455 float mMinTimeRemaining; // Early out condition: If this much time is left to simulate we are done
456 float mCollisionTolerance; // How far we're willing to penetrate geometry
457 float mCharacterPadding; // How far we try to stay away from the geometry, this ensures that the sweep will hit as little as possible lowering the collision cost and reducing the risk of getting stuck
458 uint mMaxNumHits; // Max num hits to collect in order to avoid excess of contact points collection
459 float mHitReductionCosMaxAngle; // Cos(angle) where angle is the maximum angle between two hits contact normals that are allowed to be merged during hit reduction. Default is around 2.5 degrees. Set to -1 to turn off.
460 float mPenetrationRecoverySpeed; // This value governs how fast a penetration will be resolved, 0 = nothing is resolved, 1 = everything in one update
461
462 // Character mass (kg)
463 float mMass;
464
465 // Maximum force with which the character can push other bodies (N)
466 float mMaxStrength;
467
468 // An extra offset applied to the shape in local space. This allows applying an extra offset to the shape in local space.
469 Vec3 mShapeOffset = Vec3::sZero();
470
471 // Current position (of the base, not the center of mass)
472 RVec3 mPosition = RVec3::sZero();
473
474 // Current rotation (of the base, not of the center of mass)
475 Quat mRotation = Quat::sIdentity();
476
477 // Current linear velocity
478 Vec3 mLinearVelocity = Vec3::sZero();
479
480 // List of contacts that were active in the last frame
481 ContactList mActiveContacts;
482
483 // Remembers the delta time of the last update
484 float mLastDeltaTime = 1.0f / 60.0f;
485
486 // Remember if we exceeded the maximum number of hits and had to remove similar contacts
487 mutable bool mMaxHitsExceeded = false;
488};
489
EBackFaceMode
How collision detection functions will treat back facing triangles.
Definition: BackFaceMode.h:11
#define JPH_EXPORT
Definition: Core.h:214
std::uint64_t uint64
Definition: Core.h:430
unsigned int uint
Definition: Core.h:426
#define JPH_NAMESPACE_END
Definition: Core.h:354
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:348
constexpr float DegreesToRadians(float inV)
Convert a value from degrees to radians.
Definition: Math.h:13
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition: Memory.h:29
EMotionType
Motion type of a physics body.
Definition: MotionType.h:11
std::vector< T, STLAllocator< T > > Array
Definition: STLAllocator.h:81
JPH_INLINE float Cos(float inX)
Cosine of x (input in radians)
Definition: Trigonometry.h:20
Class function to filter out bodies, returns true if test should collide with body.
Definition: BodyFilter.h:16
Definition: Body.h:35
ID of a body. This is a way of reasoning about bodies in a multithreaded simulation while avoiding ra...
Definition: BodyID.h:13
Filter class for broadphase layers.
Definition: BroadPhaseLayer.h:89
Base class for character class.
Definition: CharacterBase.h:51
Base class for configuration of a character.
Definition: CharacterBase.h:21
This class receives callbacks when a virtual character hits something.
Definition: CharacterVirtual.h:56
virtual void OnContactAdded(const CharacterVirtual *inCharacter, const BodyID &inBodyID2, const SubShapeID &inSubShapeID2, RVec3Arg inContactPosition, Vec3Arg inContactNormal, CharacterContactSettings &ioSettings)
Definition: CharacterVirtual.h:75
virtual ~CharacterContactListener()=default
Destructor.
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.
Definition: CharacterVirtual.h:66
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)
Definition: CharacterVirtual.h:87
virtual void OnAdjustBodyVelocity(const CharacterVirtual *inCharacter, const Body &inBody2, Vec3 &ioLinearVelocity, Vec3 &ioAngularVelocity)
Definition: CharacterVirtual.h:63
This class contains settings that allow you to override the behavior of a character's collision respo...
Definition: CharacterVirtual.h:48
bool mCanPushCharacter
True when the object can push the virtual character.
Definition: CharacterVirtual.h:50
bool mCanReceiveImpulses
True when the virtual character can apply impulses (push) the body.
Definition: CharacterVirtual.h:51
Definition: CharacterVirtual.h:96
float GetMass() const
Character mass (kg)
Definition: CharacterVirtual.h:138
float GetPenetrationRecoverySpeed() const
This value governs how fast a penetration will be resolved, 0 = nothing is resolved,...
Definition: CharacterVirtual.h:146
RVec3 GetPosition() const
Get the position of the character.
Definition: CharacterVirtual.h:120
void SetLinearVelocity(Vec3Arg inLinearVelocity)
Set the linear velocity of the character (m / s)
Definition: CharacterVirtual.h:117
const ContactList & GetActiveContacts() const
Access to the internal list of contacts that the character has found.
Definition: CharacterVirtual.h:313
RMat44 GetWorldTransform() const
Calculate the world transform of the character.
Definition: CharacterVirtual.h:132
bool GetMaxHitsExceeded() const
Definition: CharacterVirtual.h:164
void SetMaxStrength(float inMaxStrength)
Definition: CharacterVirtual.h:143
float GetCharacterPadding() const
Character padding.
Definition: CharacterVirtual.h:150
void SetMaxNumHits(uint inMaxHits)
Definition: CharacterVirtual.h:154
uint GetMaxNumHits() const
Max num hits to collect in order to avoid excess of contact points collection.
Definition: CharacterVirtual.h:153
float GetMaxStrength() const
Maximum force with which the character can push other bodies (N)
Definition: CharacterVirtual.h:142
void SetShapeOffset(Vec3Arg inShapeOffset)
Definition: CharacterVirtual.h:168
std::vector< Contact, STLTempAllocator< Contact > > TempContactList
Definition: CharacterVirtual.h:309
Array< Contact > ContactList
Definition: CharacterVirtual.h:310
void SetMass(float inMass)
Definition: CharacterVirtual.h:139
Vec3 GetLinearVelocity() const
Get the linear velocity of the character (m / s)
Definition: CharacterVirtual.h:114
CharacterContactListener * GetListener() const
Get the current contact listener.
Definition: CharacterVirtual.h:111
RMat44 GetCenterOfMassTransform() const
Calculates the transform for this character's center of mass.
Definition: CharacterVirtual.h:135
void SetRotation(QuatArg inRotation)
Set the rotation of the character.
Definition: CharacterVirtual.h:129
void SetHitReductionCosMaxAngle(float inCosMaxAngle)
Definition: CharacterVirtual.h:158
Vec3 GetShapeOffset() const
An extra offset applied to the shape in local space. This allows applying an extra offset to the shap...
Definition: CharacterVirtual.h:167
void SetPenetrationRecoverySpeed(float inSpeed)
Definition: CharacterVirtual.h:147
float GetHitReductionCosMaxAngle() const
Cos(angle) where angle is the maximum angle between two hits contact normals that are allowed to be m...
Definition: CharacterVirtual.h:157
void SetPosition(RVec3Arg inPosition)
Set the position of the character.
Definition: CharacterVirtual.h:123
void SetListener(CharacterContactListener *inListener)
Set the contact listener.
Definition: CharacterVirtual.h:108
Quat GetRotation() const
Get the rotation of the character.
Definition: CharacterVirtual.h:126
Contains the configuration of a character.
Definition: CharacterVirtual.h:20
Class that contains all information of two colliding shapes.
Definition: CollideShape.h:19
Virtual interface that allows collecting multiple collision results.
Definition: CollisionCollector.h:45
Base class for all physics constraints. A constraint removes one or more degrees of freedom for a rig...
Definition: Constraint.h:103
Holds a 4x4 matrix of floats, but supports also operations on the 3x3 upper left part of the matrix.
Definition: Mat44.h:13
JPH_INLINE Mat44 PostTranslated(Vec3Arg inTranslation) const
Post multiply by translation matrix: result = Mat44::sTranslation(inTranslation) * this (i....
Definition: Mat44.inl:896
JPH_INLINE Mat44 PreTranslated(Vec3Arg inTranslation) const
Pre multiply by translation matrix: result = this * Mat44::sTranslation(inTranslation)
Definition: Mat44.inl:891
static JPH_INLINE Mat44 sRotationTranslation(QuatArg inR, Vec3Arg inT)
Get matrix that rotates and translates.
Definition: Mat44.inl:149
Filter class for object layers.
Definition: ObjectLayer.h:28
Definition: PhysicsMaterial.h:23
Definition: PhysicsSystem.h:28
An infinite plane described by the formula X . Normal + Constant = 0.
Definition: Plane.h:11
Definition: Quat.h:33
static JPH_INLINE Quat sIdentity()
Definition: Quat.h:103
Result of a shape cast test.
Definition: ShapeCast.h:111
Filter class.
Definition: ShapeFilter.h:17
Base class for all shapes (collision volume of a body). Defines a virtual interface for collision det...
Definition: Shape.h:174
virtual Vec3 GetCenterOfMass() const
All shapes are centered around their center of mass. This function returns the center of mass positio...
Definition: Shape.h:199
Definition: StateRecorder.h:48
A sub shape id contains a path to an element (usually a triangle or other primitive type) of a compou...
Definition: SubShapeID.h:23
Definition: TempAllocator.h:16
Definition: Vec3.h:16
static JPH_INLINE Vec3 sZero()
Vector with all zeros.
Definition: Vec3.inl:107
Definition: CharacterVirtual.h:288
EMotionType mMotionTypeB
Motion type of B, used to determine the priority of the contact.
Definition: CharacterVirtual.h:301
Vec3 mContactNormal
Contact normal, pointing towards the character.
Definition: CharacterVirtual.h:295
const PhysicsMaterial * mMaterial
Material of B.
Definition: CharacterVirtual.h:303
float mFraction
Fraction along the path where this contact takes place.
Definition: CharacterVirtual.h:298
uint64 mUserData
User data of B.
Definition: CharacterVirtual.h:302
BodyID mBodyB
ID of body we're colliding with.
Definition: CharacterVirtual.h:299
SubShapeID mSubShapeIDB
Sub shape ID of body we're colliding with.
Definition: CharacterVirtual.h:300
Vec3 mLinearVelocity
Velocity of the contact point.
Definition: CharacterVirtual.h:294
float mDistance
Distance to the contact <= 0 means that it is an actual contact, > 0 means predictive.
Definition: CharacterVirtual.h:297
Vec3 mSurfaceNormal
Surface normal of the contact.
Definition: CharacterVirtual.h:296
RVec3 mPosition
Position where the character makes contact.
Definition: CharacterVirtual.h:293
Settings struct with settings for ExtendedUpdate.
Definition: CharacterVirtual.h:221