UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ClothingSimulationInterface.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
5#include "Containers/Map.h"
6#include "CoreTypes.h"
7#include "Math/MathFwd.h"
8
9#define UE_API CLOTHINGSYSTEMRUNTIMEINTERFACE_API
10
12class USkeletalMeshComponent;
14class UE_DEPRECATED(5.7, "Use IClothingSimulationInterface instead.") IClothingSimulation;
16struct FClothSimulData;
17
25
35{
36public:
39
40protected:
41
43
51 virtual void CreateActor(USkeletalMeshComponent* InOwnerComponent, const UClothingAssetBase* InAsset, int32 SimDataIndex) = 0;
52
54 virtual void EndCreateActor() = 0;
55
58
67
69 virtual void Initialize() = 0;
70
75 virtual void Shutdown() = 0;
76
81 virtual bool ShouldSimulateLOD(int32 OwnerLODIndex) const = 0;
82
92
98
101
103 virtual void DestroyActors() = 0;
104
110
118 virtual void AppendSimulationData(TMap<int32, FClothSimulData>& InOutData, const USkeletalMeshComponent* OwnerComponent, const USkinnedMeshComponent* OverrideComponent) const = 0;
119
121 virtual FBoxSphereBounds GetBounds(const USkeletalMeshComponent* InOwnerComponent) const = 0;
122
130
136 virtual void ClearExternalCollisions() = 0;
137
146
147public:
149 UE_DEPRECATED(5.7, "This method is used to ease transition between the new and old interface and will be removed.")
151
152 UE_DEPRECATED(5.7, "This method is used to ease transition between the new and old interface and will be removed.")
155
157 virtual int32 GetNumCloths() const { return 0; }
159 virtual int32 GetNumKinematicParticles() const { return 0; }
161 virtual int32 GetNumDynamicParticles() const { return 0; }
167 virtual int32 GetNumIterations() const { return 0; }
173 virtual int32 GetNumSubsteps() const { return 0; }
175 virtual float GetSimulationTime() const { return 0.f; }
177 virtual bool IsTeleported() const { return false; }
178
179private:
181 friend class IClothingSimulation; // For bIsLegacyInterface
183 bool bIsLegacyInterface = false; // UE_DEPRECATED(5.7, "Use IClothingSimulationInterface instead.")
184};
185
186class UE_DEPRECATED(5.7, "Use IClothingSimulationInterface instead.") IClothingSimulation : public IClothingSimulationInterface
187{
188public:
191
192 // The majority of the API for this class is protected. The required objects (skel meshes and the parallel task)
193 // are friends so they can use the functionality. For the most part the simulation is not designed to be used
194 // outside of the skeletal mesh component as its parallel simulation is tied to the skel mesh tick and
195 // dependents.
196 // Any method that is available in the public section below should consider that it may be called while
197 // the simulation is running.
198 // Currently only a const pointer is exposed externally to the skeletal mesh component, so barring that
199 // being cast away external callers can't call non-const methods. The debug skel mesh component exposes a
200 // mutable version for editor use
201protected:
202
203 friend class USkeletalMeshComponent;
204 friend class FParallelClothTask;
205 friend struct FClothingSimulationInstance;
206 friend struct FEnvironmentalCollisions;
207
215 virtual void CreateActor(USkeletalMeshComponent* InOwnerComponent, const UClothingAssetBase* InAsset, int32 SimDataIndex) override
216 {
220 }
221
222 UE_DEPRECATED(5.7, "Use const arguments version instead,")
223 virtual void CreateActor(USkeletalMeshComponent* InOwnerComponent, UClothingAssetBase* InAsset, int32 SimDataIndex) {}
224
232 virtual void FillContextAndPrepareTick(const USkeletalMeshComponent* InComponent, float InDeltaTime, IClothingSimulationContext* InOutContext, bool bIsInitialization, bool bForceTeleportResetOnly) override
233 {
235 return FillContext(const_cast<USkeletalMeshComponent*>(InComponent), InDeltaTime, InOutContext, bIsInitialization);
237 }
238
239 UE_DEPRECATED(5.7, "Use FillContextAndPrepareTick instead.")
241 {
245 }
246 UE_DEPRECATED(5.7, "Use FillContextAndPrepareTick instead.")
247 virtual void FillContext(USkeletalMeshComponent* InComponent, float InDeltaTime, IClothingSimulationContext* InOutContext) {}
248
253 UE_DEPRECATED(5.7, "This method has not been used consistently and has been replaced with ShouldSimulateLOD")
254 virtual bool ShouldSimulate() const
255 {
256 return true;
257 }
258
262 virtual bool ShouldSimulateLOD(int32 OwnerLODIndex) const override
263 {
265 return ShouldSimulate();
267 }
268
276 virtual void Simulate_AnyThread(const IClothingSimulationContext* InContext) override
277 {
279 return Simulate(const_cast<IClothingSimulationContext*>(InContext));
281 }
282
283 UE_DEPRECATED(5.7, "Use Simulate_AnyThread instead,")
285
287 virtual void ForceClothNextUpdateTeleportAndReset_AnyThread() override {}
288
290 virtual void HardResetSimulation(const IClothingSimulationContext* InContext) override {}
291
299 virtual void AppendSimulationData(TMap<int32, FClothSimulData>& InOutData, const USkeletalMeshComponent* OwnerComponent, const USkinnedMeshComponent* OverrideComponent) const override
300 {
302 GetSimulationData(InOutData, const_cast<USkeletalMeshComponent*>(OwnerComponent), const_cast<USkinnedMeshComponent*>(OverrideComponent));
304 }
305
306 UE_DEPRECATED(5.7, "Use AppendSimulationData instead.")
308
309public:
310 UE_DEPRECATED(5.7, "GatherStats is unused and will be removed from future interfaces. Do not override.")
311 virtual void GatherStats() const {}
312
313 UE_DEPRECATED(5.7, "Use a clothing simulation interactor to set this simulation property instead.")
314 virtual void SetNumIterations(int32 NumIterations) {}
315 UE_DEPRECATED(5.7, "Use a clothing simulation interactor to set this simulation property instead.")
316 virtual void SetMaxNumIterations(int32 MaxNumIterations) {}
317 UE_DEPRECATED(5.7, "Use a clothing simulation interactor to set this simulation property instead.")
318 virtual void SetNumSubsteps(int32 NumSubsteps) {}
319
320 UE_DEPRECATED(5.7, "Use FillContextAndPrepareTick instead.")
321 virtual void UpdateWorldForces(const USkeletalMeshComponent* OwnerComponent) {}
322};
323
325inline const class IClothingSimulation* IClothingSimulationInterface::DynamicCastToIClothingSimulation() const
326{
327 return bIsLegacyInterface ? static_cast<const class IClothingSimulation*>(this) : nullptr;
328}
329
331{
332 return bIsLegacyInterface ? static_cast<class IClothingSimulation*>(this) : nullptr;
333}
335
336#undef UE_API
#define UE_API
Definition ClothingSimulationInterface.h:9
#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
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
#define UE_API
Definition SColorGradingComponentViewer.h:12
Definition SkeletalMeshComponentPhysics.cpp:3396
Definition ClothingSimulationInterface.h:20
virtual UE_API ~IClothingSimulationContext()
Definition ClothingSimulationInterface.h:35
virtual int32 GetNumSubsteps() const
Definition ClothingSimulationInterface.h:173
virtual IClothingSimulationContext * CreateContext()=0
virtual void EndCreateActor()=0
PRAGMA_DISABLE_DEPRECATION_WARNINGS const IClothingSimulation * DynamicCastToIClothingSimulation() const
virtual void AddExternalCollisions(const FClothCollisionData &InData)=0
virtual int32 GetNumIterations() const
Definition ClothingSimulationInterface.h:167
virtual bool IsTeleported() const
Definition ClothingSimulationInterface.h:177
virtual void HardResetSimulation(const IClothingSimulationContext *InContext)=0
virtual UE_API ~IClothingSimulationInterface()
virtual void Initialize()=0
virtual PRAGMA_ENABLE_DEPRECATION_WARNINGS int32 GetNumCloths() const
Definition ClothingSimulationInterface.h:157
virtual bool ShouldSimulateLOD(int32 OwnerLODIndex) const =0
virtual void CreateActor(USkeletalMeshComponent *InOwnerComponent, const UClothingAssetBase *InAsset, int32 SimDataIndex)=0
virtual void ForceClothNextUpdateTeleportAndReset_AnyThread()=0
virtual void GetCollisions(FClothCollisionData &OutCollisions, bool bIncludeExternal=true) const =0
virtual void DestroyActors()=0
virtual void AppendSimulationData(TMap< int32, FClothSimulData > &InOutData, const USkeletalMeshComponent *OwnerComponent, const USkinnedMeshComponent *OverrideComponent) const =0
friend class IClothingSimulation
Definition ClothingSimulationInterface.h:181
virtual void DestroyContext(IClothingSimulationContext *InContext)=0
virtual void FillContextAndPrepareTick(const USkeletalMeshComponent *InComponent, float InDeltaTime, IClothingSimulationContext *InOutContext, bool bIsInitialization, bool bForceTeleportResetOnly)=0
virtual int32 GetNumKinematicParticles() const
Definition ClothingSimulationInterface.h:159
virtual void ClearExternalCollisions()=0
virtual FBoxSphereBounds GetBounds(const USkeletalMeshComponent *InOwnerComponent) const =0
virtual void Simulate_AnyThread(const IClothingSimulationContext *InContext)=0
virtual float GetSimulationTime() const
Definition ClothingSimulationInterface.h:175
virtual int32 GetNumDynamicParticles() const
Definition ClothingSimulationInterface.h:161
Definition UnrealString.h.inl:34
Definition ClothingAssetBase.h:21
Definition SkinnedMeshComponent.h:258
FSolverCollisionParticles class
Definition PBDSoftsEvolutionFwd.h:38
Definition ClothCollisionData.h:14
Definition ClothingSystemRuntimeTypes.h:15
Definition ClothingSimulationInstance.h:25
Definition EnvironmentalCollisions.h:9
Definition BoxSphereBounds.h:25