UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ClusterUnionStressSolver.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Chaos/Core.h"
8
9namespace Chaos
10{
11 struct FClusterUnion;
12 //struct FPBDRigidClusteredParticleHandle;
13
14 // this compute stress throughout the structure of a cluster union and find the connections that would break under stress
16 {
17 public:
19
21 {
23 bool HasFailed() const { return (CompressionStressRatio >= 1.f) || (TensileStressRatio >= 1.f) || (ShearStressRatio >= 1.f); }
24 bool IsGreaterThan(float StressRatio) const { return GetMaxStressRatio() > StressRatio; }
25
26 // Stress ratios below 0 means the failure did not occured, over 1 the failure occured
30 };
31
39
43
44 const FResults& Solve();
45
46 private:
47 struct FNode
48 {
49 FNode()
50 : Particle(nullptr)
51 , Value(TNumericLimits<float>::Max())
52 , SumOfMassRatios(0)
53 , WeightedCenterOfMass(FVec3::ZeroVector)
54 {}
55
57 : Particle(ParticleIn)
58 , Value(TNumericLimits<float>::Max())
59 , SumOfMassRatios(0)
60 , WeightedCenterOfMass(FVec3::ZeroVector)
61 {}
62
63 FNodeId GetId() const { return Particle; }
64 bool IsRootNode() const;
65 FVec3 GetCenterOfMass() const { return WeightedCenterOfMass / SumOfMassRatios; }
66 void AddMassContribution(double MassRatio, const FVec3& CenterOfMass);
67
69
70 // this represent the value that will be used to evaluate the nodes from larger to smaller
71 float Value;
72
73 // a mass ratio is the ratio of the visited particle masses over the total mass of the cluster union
74 // this avoid getting in too large numbers as we accumulate over a large number of nodes
75 double SumOfMassRatios;
76
77 // this is the sum of the center of mass weighted by their associated mass ratio contribution ( see above )
78 // this allows us to compute the average center of mass at any point
79 FVec3 WeightedCenterOfMass;
80 };
81
82 void PrepareForSolve();
83 void CreateNodeFromClusterUnion();
84 void ComputeNodeValues();
85 void PropagateValue(const FNode& Node);
86 void EvaluateNodes();
87 void EvaluateNode(FNode& Node);
88 FConnectionEvalResult EvaluateConnectionStress(double Mass, const FVec3& CenterOfMass, float ConnectionArea, const FVec3& ConnectionCenter, const FVec3& ConnectionNormal);
89
90 private:
91 FClusterUnion& ClusterUnion;
92 TMap<FNodeId, FNode> NodesById;
93 TArray<FNodeId> RootNodeIds;
94 FResults Results;
95 };
96}
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
USkinnedMeshComponent float
Definition SkinnedMeshComponent.h:60
Definition UnrealString.h.inl:34
Definition SkeletalMeshComponent.h:307
TVector< FReal, 3 > FVec3
Definition Core.h:17
TPBDRigidClusteredParticleHandle< FReal, 3 > FPBDRigidClusteredParticleHandle
Definition ParticleHandleFwd.h:75
Definition ClusterUnionStressSolver.h:21
float GetMaxStressRatio() const
Definition ClusterUnionStressSolver.h:22
float ShearStressRatio
Definition ClusterUnionStressSolver.h:29
float CompressionStressRatio
Definition ClusterUnionStressSolver.h:27
bool IsGreaterThan(float StressRatio) const
Definition ClusterUnionStressSolver.h:24
bool HasFailed() const
Definition ClusterUnionStressSolver.h:23
float TensileStressRatio
Definition ClusterUnionStressSolver.h:28
Definition ClusterUnionStressSolver.h:33
FNodeId NodeA
Definition ClusterUnionStressSolver.h:34
FNodeId NodeB
Definition ClusterUnionStressSolver.h:35
FConnectionEvalResult ConnectionResult
Definition ClusterUnionStressSolver.h:36
Definition ClusterUnionStressSolver.h:16
FClusterUnionStressSolver(FClusterUnion &ClusterUnionIn)
Definition ClusterUnionStressSolver.h:40
TArray< FNodeEvalResult > FResults
Definition ClusterUnionStressSolver.h:38
const FPBDRigidClusteredParticleHandle * FNodeId
Definition ClusterUnionStressSolver.h:18
const FResults & Solve()
Definition ClusterUnionStressSolver.cpp:311
Definition ClusterUnionManager.h:86
static constexpr UE_FORCEINLINE_HINT T Max3(const T A, const T B, const T C)
Definition UnrealMathUtility.h:551
Definition NumericLimits.h:41