UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
StrainModification.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Chaos/Core.h"
6#include "ParticleHandleFwd.h"
7
10
11namespace Chaos
12{
13 class FRigidClustering;
14 class FClusterUnionPhysicsProxy;
15 class FStrainModifierAccessor;
16 class FStrainedProxyModifier;
17 class FStrainedProxyIterator;
18 class FStrainedProxyRange;
19 class FStrainModifierAccessor;
20
22 {
25 CollisionStrain = 1 << 2
26 };
27
29 {
31
32 // Can be a root if proxy is a GC or the directly strained particle if the proxy is a cluster union
34
35 // true if the particle handle is actually a partial GC attached toa cluster union
36 bool bPartialDestruction = false;
37
39
40 bool IsPartialDestruction() const;
41
43 };
44
45 // FStrainedProxyModifier
46 //
47 // User-facing api for accessing the proxy of a strained cluster. Provides const access to the
48 // proxy and limited read/write access to its internal strain data.
50 {
51 public:
53 : RigidClustering(InRigidClustering)
54 , ProxyAndRoot(InProxyAndRoot)
55 , RestChildren(InitRestChildren(InProxyAndRoot.CastToGeometryCollectionProxy()))
56 { }
57
59 : RigidClustering(Other.RigidClustering)
60 , ProxyAndRoot(Other.ProxyAndRoot)
61 , RestChildren(Other.RestChildren)
62 { }
63
64 // Get the proxy that owns the strained cluster or clusters
66
67 // Get the original root handle from the geometry collection proxy
69
70 // Get the physics handle for the strained parent cluster or the strained particle directly if it's part of partial destruction
72
73 // Get the physics handle for the strained parent cluster
74 UE_DEPRECATED(5.4, "This has been replaced by GetParticleHandle and GetOriginalRootHandle for finer grain access to the underlying handles")
76
77 // Get the number of level-1 strainable entities (number of rest-children in the per-particle
78 // strain model, or number of rest-connections in the edge/area model).
80
81 // Get the number of breaking strains amongst the level-1 strainables
82 // If DoubleCount is true, then add N for each strain which is strong enough to
83 // break a connection N times.
85
86 // Go through the children and find the one with the largest ratio of applied strain vs internal strain and return this ratio
87 // @param FatigueThreshold if the applied strains are below the fatgue threshold, they will be ignored and the returned ratio will be 0
88 // @param StrainTypes type strain to account for ( collision and/or external )
90
91 // A helper debug method to pair w/ GetMaxBreakStrainRatio, where it will return the Max Applied Strain used for the Max Break Strain.
93
94 // Clear strains for all strained cluster children
96
97 // Adjust strain for all the strained children above the fatigue threshold so that their strain is large enough to break
98 // @param FatigueThreshold if the applied strains are below the fatgue threshold, they will be ignored
99 // @param StrainTypes type strain to account for ( collision and/or external )
101
102 private:
103
104 static CHAOS_API const TSet<int32>* InitRestChildren(FGeometryCollectionPhysicsProxy* Proxy);
105
106 FRigidClustering& RigidClustering;
107 FStrainedProxyAndRoot ProxyAndRoot;
108 const TSet<int32>* RestChildren;
109 };
110
111 // FStrainedProxyIterator
112 //
113 // Iterator produced by FStrainedProxyRange, for looping over proxies which are
114 // associated with rigid clusters which have been strained.
116 {
117 public:
123
125 : RigidClustering(Other.RigidClustering)
126 , ProxyAndRoots(Other.ProxyAndRoots)
127 , Index(Other.Index)
128 { }
129
134 {
135 return !operator==(Other);
136 }
137
138 private:
139 FRigidClustering& RigidClustering;
140 TArray<FStrainedProxyAndRoot>& ProxyAndRoots;
141 int32 Index;
142 };
143
144 // FStrainedProxyRange
145 //
146 // Provides an interface for use with ranged-for, for iterating over strained proxies.
147 // Constructor produces filtered array of proxies, and begin and end functions produce
148 // iterators which can modify strain related properties of the clusters associated
149 // with each proxy.
151 {
152 public:
154
156 : RigidClustering(Other.RigidClustering)
157 , ProxyAndRoots(Other.ProxyAndRoots)
158 { }
159
161 {
162 return FStrainedProxyIterator(RigidClustering, ProxyAndRoots, 0);
163 }
164
166 {
167 return FStrainedProxyIterator(RigidClustering, ProxyAndRoots, ProxyAndRoots.Num());
168 }
169
170 private:
171 FRigidClustering& RigidClustering;
172 TArray<FStrainedProxyAndRoot> ProxyAndRoots;
173 const TArray<FPBDRigidClusteredParticleHandle*>* StrainedParticles;
174 };
175
176 // FStrainModifierAccessor
177 //
178 // Provides access to strained proxies and clusters
180 {
181 public:
182
187
188 // Get an iterable range of unique geometry collection proxies which
189 // correspond to all strained clusters. Optionally, only include proxies
190 // for whom the strained parent is still the original root (ie, unbroken).
192
193 private:
194
195 FRigidClustering& RigidClustering;
196 const TArray<FPBDRigidClusteredParticleHandle*>* StrainedParticles;
197 };
198}
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
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 PBDRigidClustering.h:56
Definition StrainModification.h:180
FStrainModifierAccessor(FRigidClustering &InRigidClustering, const TArray< FPBDRigidClusteredParticleHandle * > *InStrainedParticles=nullptr)
Definition StrainModification.h:183
CHAOS_API FStrainedProxyRange GetStrainedProxies(bool bRootLevelOnly=true)
Definition StrainModification.cpp:310
Definition StrainModification.h:116
CHAOS_API FStrainedProxyModifier operator*()
Definition StrainModification.cpp:211
FStrainedProxyIterator(FRigidClustering &InRigidClustering, TArray< FStrainedProxyAndRoot > &InProxyAndRoots, int32 InIndex)
Definition StrainModification.h:118
bool operator!=(const FStrainedProxyIterator &Other) const
Definition StrainModification.h:133
CHAOS_API bool operator==(const FStrainedProxyIterator &Other) const
Definition StrainModification.cpp:222
FStrainedProxyIterator(const FStrainedProxyIterator &Other)
Definition StrainModification.h:124
CHAOS_API FStrainedProxyIterator & operator++()
Definition StrainModification.cpp:216
Definition StrainModification.h:50
FStrainedProxyModifier(const FStrainedProxyModifier &Other)
Definition StrainModification.h:58
CHAOS_API float GetStrainUsedForBreakRatio(const float FatigueThresholdPercent, const float FatigueThresholdMinimum, bool bRelative, const uint8 StrainTypes)
Definition StrainModification.cpp:138
const Chaos::FPBDRigidParticleHandle * GetRootHandle() const
Definition StrainModification.h:75
CHAOS_API const IPhysicsProxyBase * GetProxy() const
Definition StrainModification.cpp:41
CHAOS_API int32 GetNumBreakingStrains(bool bDoubleCount=true, const uint8 StrainTypes=EStrainTypes::ExternalStrain|EStrainTypes::CollisionStrain) const
Definition StrainModification.cpp:92
CHAOS_API const Chaos::FPBDRigidParticleHandle * GetParticleHandle() const
Definition StrainModification.cpp:55
FStrainedProxyModifier(FRigidClustering &InRigidClustering, FStrainedProxyAndRoot InProxyAndRoot)
Definition StrainModification.h:52
CHAOS_API int32 GetNumRestBreakables() const
Definition StrainModification.cpp:83
CHAOS_API float GetMaxBreakStrainRatio(const float FatigueThresholdPercent, const float FatigueThresholdMinimum, bool bRelative, const uint8 StrainTypes) const
Definition StrainModification.cpp:116
CHAOS_API void AdjustStrainForBreak(const float FatigueThresholdPercent, const float FatigueThresholdMinimum, const uint8 StrainTypes)
Definition StrainModification.cpp:165
CHAOS_API void ClearStrains()
Definition StrainModification.cpp:181
CHAOS_API const Chaos::FPBDRigidParticleHandle * GetOriginalRootHandle() const
Definition StrainModification.cpp:46
Definition StrainModification.h:151
FStrainedProxyIterator begin()
Definition StrainModification.h:160
FStrainedProxyIterator end()
Definition StrainModification.h:165
FStrainedProxyRange(const FStrainedProxyRange &Other)
Definition StrainModification.h:155
Definition ParticleHandle.h:987
Definition GeometryCollectionPhysicsProxy.h:143
Definition PhysicsProxyBase.h:97
Definition Array.h:670
Definition SkeletalMeshComponent.h:307
EStrainTypes
Definition StrainModification.h:22
@ ExternalStrain
Definition StrainModification.h:24
@ InternalStrain
Definition StrainModification.h:23
@ CollisionStrain
Definition StrainModification.h:25
U16 Index
Definition radfft.cpp:71
Definition StrainModification.h:29
bool operator==(const Chaos::FStrainedProxyAndRoot &Other) const
Definition StrainModification.cpp:34
bool IsPartialDestruction() const
Definition StrainModification.cpp:29
bool bPartialDestruction
Definition StrainModification.h:36
Chaos::FPBDRigidClusteredParticleHandle * ParticleHandle
Definition StrainModification.h:33
FGeometryCollectionPhysicsProxy * Proxy
Definition StrainModification.h:30
FGeometryCollectionPhysicsProxy * CastToGeometryCollectionProxy() const
Definition StrainModification.cpp:20