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 bool mIsSensor;
46};
47
51{
56};
57
62{
63public:
65 virtual ~ContactListener() = default;
66
76 virtual ValidateResult OnContactValidate(const Body &inBody1, const Body &inBody2, RVec3Arg inBaseOffset, const CollideShapeResult &inCollisionResult) { return ValidateResult::AcceptAllContactsForThisBodyPair; }
77
86 virtual void OnContactAdded(const Body &inBody1, const Body &inBody2, const ContactManifold &inManifold, ContactSettings &ioSettings) { /* Do nothing */ }
87
96 virtual void OnContactPersisted(const Body &inBody1, const Body &inBody2, const ContactManifold &inManifold, ContactSettings &ioSettings) { /* Do nothing */ }
97
105 virtual void OnContactRemoved(const SubShapeIDPair &inSubShapePair) { /* Do nothing */ }
106};
107
ValidateResult
Definition: ContactListener.h:51
@ 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:309
#define JPH_NAMESPACE_END
Definition: Core.h:240
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:234
Definition: Body.h:33
Class that contains all information of two colliding shapes.
Definition: CollideShape.h:19
Definition: ContactListener.h:62
virtual ~ContactListener()=default
Ensure virtual destructor.
virtual void OnContactPersisted(const Body &inBody1, const Body &inBody2, const ContactManifold &inManifold, ContactSettings &ioSettings)
Definition: ContactListener.h:96
virtual ValidateResult OnContactValidate(const Body &inBody1, const Body &inBody2, RVec3Arg inBaseOffset, const CollideShapeResult &inCollisionResult)
Definition: ContactListener.h:76
virtual void OnContactAdded(const Body &inBody1, const Body &inBody2, const ContactManifold &inManifold, ContactSettings &ioSettings)
Definition: ContactListener.h:86
virtual void OnContactRemoved(const SubShapeIDPair &inSubShapePair)
Definition: ContactListener.h:105
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)
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:45
float mCombinedFriction
Combined friction for the body pair (usually calculated by sCombineFriction)
Definition: ContactListener.h:43
float mCombinedRestitution
Combined restitution for the body pair (usually calculated by sCombineRestitution)
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