UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ContactPoint.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc.All Rights Reserved.
2#pragma once
3
4#include "Chaos/Core.h"
5
6namespace Chaos
7{
16 {
17 Unknown,
22 };
23
24
28 template<typename T>
29 constexpr T InvalidPhi()
30 {
32 }
33
40 template<typename T>
42 {
43 public:
44 using FRealType = T;
45
46 // Shape-space contact points on the two bodies
48
49 // Shape-space contact normal on the second shape with direction that points away from shape 1
51
52 // Contact separation (negative for overlap)
54
55 // Face index of the shape we hit. Only valid for Heightfield and Trimesh contact points, otherwise INDEX_NONE
57
58 // Whether this is a vertex-plane contact, edge-edge contact etc.
60
67
68 template<typename U>
77
78 // Whether the contact point has been set up with contact data
79 bool IsSet() const
80 {
81 return (Phi != InvalidPhi<FRealType>());
82 }
83 };
84
85 // Explicit types of TContactPoint for float and double. We should use the float version whenever the contacts are in shape-relative
86 // space, which is most of the time (some collision functions may choose to generate world-space contacts which are later converted
87 // to local space, and they should therefore use the double version until the local-space conversion).
90
91
97 {
98 public:
99 union FFlags
100 {
101 FFlags() { Reset(); }
102
103 void Reset() { Bits = 0; }
104
105 struct
106 {
107 uint8 bDisabled : 1; // Whether the point was disabled by edge pruning etc
108 uint8 bWasRestored : 1; // Whether the point was retored from the previous frame due to lack of movement
109 uint8 bWasReplaced : 1; // @todo(chaos): remove this
110 uint8 bHasStaticFrictionAnchor : 1; // Whether our static friction anchor was recovered from a prior tick
111 uint8 bInitialContact : 1; // Whether this is a new contact this tick for handling initial penetration
112 };
114 };
115
117 : ContactPoint()
118 , Flags()
119 , TargetPhi(0)
120 , InitialPhi(0)
123 {}
124
133
134 FContactPointf ContactPoint; // Contact point results of low-level collision detection
135 FFlags Flags; // Various flags
136 FRealSingle TargetPhi; // Usually 0, but can be used to add padding or penetration (e.g., via a collision modifer)
137 FRealSingle InitialPhi; // Non-resolved initial penetration
138 FVec3f ShapeAnchorPoints[2]; // When static friction holds, the contact points on each shape when static friction contact was made
139 FVec3f InitialShapeContactPoints[2]; // ShapeContactPoints when the constraint was first initialized. Used to track reusablility
140 };
141
146 {
147 public:
148 // World-space contact point relative to each particle's center of mass
150
151 // World-space contact normal and tangents
155
156 // Errors to correct along each of the contact axes
160
161 // Target velocity along the normal direction
163 };
164
170 {
171 public:
177
178 FVec3f ShapeContactPoints[2]; // Contact anchor points for friction
179 FRealSingle InitialPhi; // Non-resolved initial penetration
180 };
181
183 {
184 public:
186 {
187 Reset();
188 }
189
190 void Reset()
191 {
192 NetPushOut = FVec3f(0);
193 NetImpulse = FVec3f(0);
194 bIsValid = false;
196 }
197
198 FVec3f NetPushOut; // Total pushout applied at this contact point
199 FVec3f NetImpulse; // Total impulse applied by this contact point
202 };
203
204}
@ INDEX_NONE
Definition CoreMiscDefines.h:150
FPlatformTypes::int8 int8
An 8-bit signed integer.
Definition Platform.h:1121
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition ContactPoint.h:183
FManifoldPointResult()
Definition ContactPoint.h:185
uint8 bInsideStaticFrictionCone
Definition ContactPoint.h:201
FVec3f NetImpulse
Definition ContactPoint.h:199
FVec3f NetPushOut
Definition ContactPoint.h:198
void Reset()
Definition ContactPoint.h:190
uint8 bIsValid
Definition ContactPoint.h:200
A single point in a contact manifold. Each Collision Constraint will have up to 4 of these.
Definition ContactPoint.h:97
FManifoldPoint(const FContactPointf &InContactPoint)
Definition ContactPoint.h:125
FRealSingle InitialPhi
Definition ContactPoint.h:137
FContactPointf ContactPoint
Definition ContactPoint.h:134
FRealSingle TargetPhi
Definition ContactPoint.h:136
FManifoldPoint()
Definition ContactPoint.h:116
FVec3f ShapeAnchorPoints[2]
Definition ContactPoint.h:138
FVec3f InitialShapeContactPoints[2]
Definition ContactPoint.h:139
FFlags Flags
Definition ContactPoint.h:135
The friction data for a manifold point This is the information that needs to be stored between ticks ...
Definition ContactPoint.h:170
FRealSingle InitialPhi
Definition ContactPoint.h:179
FSavedManifoldPoint(const FVec3f &InShapeContactPoint0, const FVec3f &InShapeContactPoint1, FRealSingle InInitialPhi)
Definition ContactPoint.h:172
FVec3f ShapeContactPoints[2]
Definition ContactPoint.h:178
Definition ContactPoint.h:146
FRealSingle ContactDeltaTangentV
Definition ContactPoint.h:159
FRealSingle ContactDeltaNormal
Definition ContactPoint.h:157
FVec3f RelativeContactPoints[2]
Definition ContactPoint.h:149
FVec3f ContactTangentU
Definition ContactPoint.h:153
FVec3f ContactTangentV
Definition ContactPoint.h:154
FVec3f ContactNormal
Definition ContactPoint.h:152
FRealSingle ContactDeltaTangentU
Definition ContactPoint.h:158
FRealSingle ContactTargetVelocityNormal
Definition ContactPoint.h:162
Definition ContactPoint.h:42
EContactPointType ContactType
Definition ContactPoint.h:59
T FRealType
Definition ContactPoint.h:44
TContactPoint(const TContactPoint< U > &Other)
Definition ContactPoint.h:69
TVec3< FRealType > ShapeContactNormal
Definition ContactPoint.h:50
bool IsSet() const
Definition ContactPoint.h:79
TContactPoint()
Definition ContactPoint.h:61
FRealType Phi
Definition ContactPoint.h:53
int32 FaceIndex
Definition ContactPoint.h:56
TVec3< FRealType > ShapeContactPoints[2]
Definition ContactPoint.h:47
Definition Vector.h:407
Definition Vector.h:1000
Definition SkeletalMeshComponent.h:307
TVector< FRealSingle, 3 > FVec3f
Definition Core.h:27
EContactPointType
Used in FContactPoint to indicate whether the contact is vertex-plane, edge-edge, etc.
Definition ContactPoint.h:16
float FRealSingle
Definition Real.h:14
TContactPoint< FReal > FContactPoint
Definition GJKContactPointSwept.h:11
constexpr T InvalidPhi()
Definition ContactPoint.h:29
Definition NumericLimits.h:41
Definition ContactPoint.h:100
uint8 bInitialContact
Definition ContactPoint.h:111
uint8 bHasStaticFrictionAnchor
Definition ContactPoint.h:110
uint8 Bits
Definition ContactPoint.h:113
FFlags()
Definition ContactPoint.h:101
uint8 bDisabled
Definition ContactPoint.h:107
uint8 bWasReplaced
Definition ContactPoint.h:109
uint8 bWasRestored
Definition ContactPoint.h:108
void Reset()
Definition ContactPoint.h:103