Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
ContactListener.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
9
11
12class Body;
14
17
20{
21public:
24
28
36};
37
41{
42public:
45 float mInvMassScale1 = 1.0f;
46 float mInvInertiaScale1 = 1.0f;
47 float mInvMassScale2 = 1.0f;
48 float mInvInertiaScale2 = 1.0f;
49 bool mIsSensor;
52};
53
57{
62};
63
68{
69public:
71 virtual ~ContactListener() = default;
72
82 virtual ValidateResult OnContactValidate([[maybe_unused]] const Body &inBody1, [[maybe_unused]] const Body &inBody2, [[maybe_unused]] RVec3Arg inBaseOffset, [[maybe_unused]] const CollideShapeResult &inCollisionResult) { return ValidateResult::AcceptAllContactsForThisBodyPair; }
83
92 virtual void OnContactAdded([[maybe_unused]] const Body &inBody1, [[maybe_unused]] const Body &inBody2, [[maybe_unused]] const ContactManifold &inManifold, [[maybe_unused]] ContactSettings &ioSettings) { /* Do nothing */ }
93
102 virtual void OnContactPersisted([[maybe_unused]] const Body &inBody1, [[maybe_unused]] const Body &inBody2, [[maybe_unused]] const ContactManifold &inManifold, [[maybe_unused]] ContactSettings &ioSettings) { /* Do nothing */ }
103
111 virtual void OnContactRemoved([[maybe_unused]] const SubShapeIDPair &inSubShapePair) { /* Do nothing */ }
112};
113
ValidateResult
Definition: ContactListener.h:57
@ RejectAllContactsForThisBodyPair
Rejects this and any further contact points for this body pair.
@ RejectContact
Reject this contact only (but process any other contact manifolds for the same body pair)
@ AcceptAllContactsForThisBodyPair
Accept this and any further contact points for this body pair.
@ AcceptContact
Accept this contact only (and continue calling this callback for every contact manifold for the same ...
unsigned int uint
Definition: Core.h:439
#define JPH_NAMESPACE_END
Definition: Core.h:367
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
Definition: Body.h:35
Class that contains all information of two colliding shapes.
Definition: CollideShape.h:19
Definition: ContactListener.h:68
virtual ~ContactListener()=default
Ensure virtual destructor.
virtual void OnContactPersisted(const Body &inBody1, const Body &inBody2, const ContactManifold &inManifold, ContactSettings &ioSettings)
Definition: ContactListener.h:102
virtual ValidateResult OnContactValidate(const Body &inBody1, const Body &inBody2, RVec3Arg inBaseOffset, const CollideShapeResult &inCollisionResult)
Definition: ContactListener.h:82
virtual void OnContactAdded(const Body &inBody1, const Body &inBody2, const ContactManifold &inManifold, ContactSettings &ioSettings)
Definition: ContactListener.h:92
virtual void OnContactRemoved(const SubShapeIDPair &inSubShapePair)
Definition: ContactListener.h:111
Manifold class, describes the contact surface between two bodies.
Definition: ContactListener.h:20
RVec3 GetWorldSpaceContactPointOn1(uint inIndex) const
Access to the world space contact positions.
Definition: ContactListener.h:26
RVec3 GetWorldSpaceContactPointOn2(uint inIndex) const
Definition: ContactListener.h:27
ContactManifold SwapShapes() const
Swaps shape 1 and 2.
Definition: ContactListener.h:23
SubShapeID mSubShapeID2
Definition: ContactListener.h:33
RVec3 mBaseOffset
Offset to which all the contact points are relative.
Definition: ContactListener.h:29
ContactPoints mRelativeContactPointsOn2
Contact points on the surface of shape 2 relative to mBaseOffset. If there's no penetration,...
Definition: ContactListener.h:35
ContactPoints mRelativeContactPointsOn1
Contact points on the surface of shape 1 relative to mBaseOffset.
Definition: ContactListener.h:34
Vec3 mWorldSpaceNormal
Normal for this manifold, direction along which to move body 2 out of collision along the shortest pa...
Definition: ContactListener.h:30
SubShapeID mSubShapeID1
Sub shapes that formed this manifold (note that when multiple manifolds are combined because they're ...
Definition: ContactListener.h:32
float mPenetrationDepth
Penetration depth (move shape 2 by this distance to resolve the collision). If this value is negative...
Definition: ContactListener.h:31
Definition: ContactListener.h:41
bool mIsSensor
If the contact should be treated as a sensor vs body contact (no collision response)
Definition: ContactListener.h:49
float mInvMassScale2
Scale factor for the inverse mass of body 2 (0 = infinite mass, 1 = use original mass,...
Definition: ContactListener.h:47
Vec3 mRelativeLinearSurfaceVelocity
Relative linear surface velocity between the bodies (world space surface velocity of body 2 - world s...
Definition: ContactListener.h:50
Vec3 mRelativeAngularSurfaceVelocity
Relative angular surface velocity between the bodies (world space angular surface velocity of body 2 ...
Definition: ContactListener.h:51
float mInvInertiaScale2
Scale factor for the inverse inertia of body 2 (usually same as mInvMassScale2)
Definition: ContactListener.h:48
float mInvMassScale1
Scale factor for the inverse mass of body 1 (0 = infinite mass, 1 = use original mass,...
Definition: ContactListener.h:45
float mCombinedFriction
Combined friction for the body pair (see: PhysicsSystem::SetCombineFriction)
Definition: ContactListener.h:43
float mInvInertiaScale1
Scale factor for the inverse inertia of body 1 (usually same as mInvMassScale1)
Definition: ContactListener.h:46
float mCombinedRestitution
Combined restitution for the body pair (see: PhysicsSystem::SetCombineRestitution)
Definition: ContactListener.h:44
A sub shape id contains a path to an element (usually a triangle or other primitive type) of a compou...
Definition: SubShapeID.h:23
A pair of bodies and their sub shape ID's. Can be used as a key in a map to find a contact point.
Definition: SubShapeIDPair.h:15
Definition: Vec3.h:16
static JPH_INLINE Vec3 sZero()
Vector with all zeros.
Definition: Vec3.inl:107