28 float mMaxStrength = 100.0f;
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;
42 float mHitReductionCosMaxAngle = 0.999f;
43 float mPenetrationRecoverySpeed = 1.0f;
230 Vec3 mStickToFloorStepDown { 0, -0.5f, 0 };
231 Vec3 mWalkStairsStepUp { 0, 0.4f, 0 };
232 float mWalkStairsMinStepForward { 0.02f };
233 float mWalkStairsStepForwardTest { 0.15f };
257 void UpdateGroundVelocity();
282 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;
288#ifdef JPH_DEBUG_RENDERER
289 static inline bool sDrawConstraints =
false;
290 static inline bool sDrawWalkStairs =
false;
291 static inline bool sDrawStickToFloor =
false;
313 bool mHadCollision =
false;
314 bool mWasDiscarded =
false;
315 bool mCanPushCharacter =
true;
326 struct ContactOrderingPredicate
328 inline bool operator () (
const Contact &
inLHS,
const Contact &
inRHS)
const
333 return inLHS.mSubShapeIDB.GetValue() <
inRHS.mSubShapeIDB.GetValue();
338 struct IgnoredContact
340 IgnoredContact() =
default;
347 using IgnoredContactList = std::vector<IgnoredContact, STLTempAllocator<IgnoredContact>>;
354 float mProjectedVelocity;
355 Vec3 mLinearVelocity;
357 bool mIsSteepSlope =
false;
360 using ConstraintList = std::vector<Constraint, STLTempAllocator<Constraint>>;
366 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) { }
374 TempContactList & mContacts;
376 float mHitReductionCosMaxAngle;
377 bool mMaxHitsExceeded =
false;
384 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) { }
393 const IgnoredContactList & mIgnoredContacts;
398 template <
class taCollector>
409 bool ValidateContact(
const Contact &
inContact)
const;
461 float mPredictiveContactDistance;
462 uint mMaxCollisionIterations;
463 uint mMaxConstraintIterations;
464 float mMinTimeRemaining;
465 float mCollisionTolerance;
466 float mCharacterPadding;
468 float mHitReductionCosMaxAngle;
469 float mPenetrationRecoverySpeed;
490 ContactList mActiveContacts;
493 float mLastDeltaTime = 1.0f / 60.0f;
496 mutable bool mMaxHitsExceeded =
false;
EBackFaceMode
How collision detection functions will treat back facing triangles.
Definition BackFaceMode.h:11
@ CollideWithBackFaces
Collide with back facing surfaces/triangles.
#define JPH_EXPORT
Definition Core.h:227
std::uint64_t uint64
Definition Core.h:443
unsigned int uint
Definition Core.h:439
#define JPH_NAMESPACE_END
Definition Core.h:367
#define JPH_NAMESPACE_BEGIN
Definition Core.h:361
constexpr float DegreesToRadians(float inV)
Convert a value from degrees to radians.
Definition Math.h:13
AllocateFunction Allocate
Definition Memory.cpp:59
#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
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:94
Base class for character class.
Definition CharacterBase.h:51
Base class for configuration of a character.
Definition CharacterBase.h:21
Definition CharacterVirtual.h:96
void SetUserData(uint64 inUserData)
Definition CharacterVirtual.h:176
float GetMass() const
Character mass (kg)
Definition CharacterVirtual.h:142
float GetPenetrationRecoverySpeed() const
This value governs how fast a penetration will be resolved, 0 = nothing is resolved,...
Definition CharacterVirtual.h:150
RVec3 GetPosition() const
Get the position of the character.
Definition CharacterVirtual.h:124
void SetLinearVelocity(Vec3Arg inLinearVelocity)
Set the linear velocity of the character (m / s)
Definition CharacterVirtual.h:121
const ContactList & GetActiveContacts() const
Access to the internal list of contacts that the character has found.
Definition CharacterVirtual.h:322
RMat44 GetWorldTransform() const
Calculate the world transform of the character.
Definition CharacterVirtual.h:136
std::vector< Contact, STLTempAllocator< Contact > > TempContactList
Definition CharacterVirtual.h:318
bool GetMaxHitsExceeded() const
Definition CharacterVirtual.h:168
void SetMaxStrength(float inMaxStrength)
Definition CharacterVirtual.h:147
float GetCharacterPadding() const
Character padding.
Definition CharacterVirtual.h:154
void SetMaxNumHits(uint inMaxHits)
Definition CharacterVirtual.h:158
uint GetMaxNumHits() const
Max num hits to collect in order to avoid excess of contact points collection.
Definition CharacterVirtual.h:157
float GetMaxStrength() const
Maximum force with which the character can push other bodies (N)
Definition CharacterVirtual.h:146
void SetShapeOffset(Vec3Arg inShapeOffset)
Definition CharacterVirtual.h:172
Array< Contact > ContactList
Definition CharacterVirtual.h:319
void SetMass(float inMass)
Definition CharacterVirtual.h:143
Vec3 GetLinearVelocity() const
Get the linear velocity of the character (m / s)
Definition CharacterVirtual.h:118
CharacterContactListener * GetListener() const
Get the current contact listener.
Definition CharacterVirtual.h:115
RMat44 GetCenterOfMassTransform() const
Calculates the transform for this character's center of mass.
Definition CharacterVirtual.h:139
CharacterVirtual(const CharacterVirtualSettings *inSettings, RVec3Arg inPosition, QuatArg inRotation, PhysicsSystem *inSystem)
Constructor without user data.
Definition CharacterVirtual.h:109
void SetRotation(QuatArg inRotation)
Set the rotation of the character.
Definition CharacterVirtual.h:133
void SetHitReductionCosMaxAngle(float inCosMaxAngle)
Definition CharacterVirtual.h:162
uint64 GetUserData() const
Access to the user data, can be used for anything by the application.
Definition CharacterVirtual.h:175
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:171
void SetPenetrationRecoverySpeed(float inSpeed)
Definition CharacterVirtual.h:151
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:161
void SetPosition(RVec3Arg inPosition)
Set the position of the character.
Definition CharacterVirtual.h:127
void SetListener(CharacterContactListener *inListener)
Set the contact listener.
Definition CharacterVirtual.h:112
Quat GetRotation() const
Get the rotation of the character.
Definition CharacterVirtual.h:130
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:903
JPH_INLINE Mat44 PreTranslated(Vec3Arg inTranslation) const
Pre multiply by translation matrix: result = this * Mat44::sTranslation(inTranslation)
Definition Mat44.inl:898
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:29
An infinite plane described by the formula X . Normal + Constant = 0.
Definition Plane.h:11
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:178
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
static JPH_INLINE Vec3 sZero()
Vector with all zeros.
Definition Vec3.inl:107
Settings struct with settings for ExtendedUpdate.
Definition CharacterVirtual.h:229