Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
CollideShape.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
14
16
19{
20public:
22
24 CollideShapeResult() = default;
25
27 CollideShapeResult(Vec3Arg inContactPointOn1, Vec3Arg inContactPointOn2, Vec3Arg inPenetrationAxis, float inPenetrationDepth, const SubShapeID &inSubShapeID1, const SubShapeID &inSubShapeID2, const BodyID &inBodyID2) :
28 mContactPointOn1(inContactPointOn1),
29 mContactPointOn2(inContactPointOn2),
30 mPenetrationAxis(inPenetrationAxis),
31 mPenetrationDepth(inPenetrationDepth),
32 mSubShapeID1(inSubShapeID1),
33 mSubShapeID2(inSubShapeID2),
34 mBodyID2(inBodyID2)
35 {
36 }
37
39 inline float GetEarlyOutFraction() const { return -mPenetrationDepth; }
40
43 {
44 CollideShapeResult result;
51 result.mBodyID2 = mBodyID2;
52 result.mShape2Face = mShape1Face;
53 result.mShape1Face = mShape2Face;
54 return result;
55 }
56
58
68};
69
72{
73public:
75
77 EActiveEdgeMode mActiveEdgeMode = EActiveEdgeMode::CollideOnlyWithActive;
78
80 ECollectFacesMode mCollectFacesMode = ECollectFacesMode::NoFaces;
81
84
87
90};
91
94{
95public:
97
100
102 EBackFaceMode mBackFaceMode = EBackFaceMode::IgnoreBackFaces;
103};
104
EActiveEdgeMode
Definition: ActiveEdgeMode.h:12
EBackFaceMode
How collision detection functions will treat back facing triangles.
Definition: BackFaceMode.h:11
ECollectFacesMode
Whether or not to collect faces, used by CastShape and CollideShape.
Definition: CollectFacesMode.h:11
#define JPH_NAMESPACE_END
Definition: Core.h:367
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition: Memory.h:29
JPH_NAMESPACE_BEGIN constexpr float cDefaultCollisionTolerance
If objects are closer than this distance, they are considered to be colliding (used for GJK) (unit: m...
Definition: PhysicsSettings.h:10
constexpr float cDefaultPenetrationTolerance
A factor that determines the accuracy of the penetration depth calculation. If the change of the squa...
Definition: PhysicsSettings.h:13
ID of a body. This is a way of reasoning about bodies in a multithreaded simulation while avoiding ra...
Definition: BodyID.h:13
Settings to be passed with a collision query.
Definition: CollideShape.h:72
float mCollisionTolerance
If objects are closer than this distance, they are considered to be colliding (used for GJK) (unit: m...
Definition: CollideShape.h:83
ECollectFacesMode mCollectFacesMode
If colliding faces should be collected or only the collision point.
Definition: CollideShape.h:80
float mPenetrationTolerance
A factor that determines the accuracy of the penetration depth calculation. If the change of the squa...
Definition: CollideShape.h:86
JPH_OVERRIDE_NEW_DELETE EActiveEdgeMode mActiveEdgeMode
How active edges (edges that a moving object should bump into) are handled.
Definition: CollideShape.h:77
Vec3 mActiveEdgeMovementDirection
When mActiveEdgeMode is CollideOnlyWithActive a movement direction can be provided....
Definition: CollideShape.h:89
Class that contains all information of two colliding shapes.
Definition: CollideShape.h:19
SubShapeID mSubShapeID1
Sub shape ID that identifies the face on shape 1.
Definition: CollideShape.h:63
BodyID mBodyID2
BodyID to which shape 2 belongs to.
Definition: CollideShape.h:65
Vec3 mContactPointOn2
Contact point on the surface of shape 2 (in world space or relative to base offset)....
Definition: CollideShape.h:60
Vec3 mPenetrationAxis
Direction to move shape 2 out of collision along the shortest path (magnitude is meaningless,...
Definition: CollideShape.h:61
Vec3 mContactPointOn1
Contact point on the surface of shape 1 (in world space or relative to base offset)
Definition: CollideShape.h:59
JPH_OVERRIDE_NEW_DELETE CollideShapeResult()=default
Default constructor.
CollideShapeResult Reversed() const
Reverses the hit result, swapping contact point 1 with contact point 2 etc.
Definition: CollideShape.h:42
CollideShapeResult(Vec3Arg inContactPointOn1, Vec3Arg inContactPointOn2, Vec3Arg inPenetrationAxis, float inPenetrationDepth, const SubShapeID &inSubShapeID1, const SubShapeID &inSubShapeID2, const BodyID &inBodyID2)
Constructor.
Definition: CollideShape.h:27
float mPenetrationDepth
Penetration depth (move shape 2 by this distance to resolve the collision)
Definition: CollideShape.h:62
Face mShape1Face
Colliding face on shape 1 (optional result, in world space or relative to base offset)
Definition: CollideShape.h:66
SubShapeID mSubShapeID2
Sub shape ID that identifies the face on shape 2.
Definition: CollideShape.h:64
float GetEarlyOutFraction() const
Function required by the CollisionCollector. A smaller fraction is considered to be a 'better hit'....
Definition: CollideShape.h:39
Face mShape2Face
Colliding face on shape 2 (optional result, in world space or relative to base offset)
Definition: CollideShape.h:67
Settings to be passed with a collision query.
Definition: CollideShape.h:94
JPH_OVERRIDE_NEW_DELETE float mMaxSeparationDistance
When > 0 contacts in the vicinity of the query shape can be found. All nearest contacts that are not ...
Definition: CollideShape.h:99
EBackFaceMode mBackFaceMode
How backfacing triangles should be treated.
Definition: CollideShape.h:102
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: Vec3.h:16
static JPH_INLINE Vec3 sZero()
Vector with all zeros.
Definition: Vec3.inl:107