UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ClothingSimulationFactory.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
11#include "UObject/Object.h"
14
15#include "ClothingSimulationFactory.generated.h"
16
17#define UE_API CLOTHINGSYSTEMRUNTIMEINTERFACE_API
18
19class FName;
20class UClass;
24class UEnum;
25
26// An interface for a class that will provide default simulation factory classes
27// Used by modules wanting to override clothing simulation to provide their own implementation
29{
30public:
31
32 // The feature name to register against for providers
33 static UE_API const FName FeatureName;
34
35 // Called by the engine to get the clothing simulation factory associated with this
36 // provider for skeletal mesh components (see USkeletalMeshComponent constructor).
37 // Returns Factory class for simulations or nullptr to disable clothing simulation
39};
40
41// Any clothing simulation factory should derive from this interface object to interact with the engine
42UCLASS(Abstract, MinimalAPI)
44{
46
47public:
48 // Return the default clothing simulation factory class as set by the build or by
49 // the p.Cloth.DefaultClothingSimulationFactoryClass console variable if any available.
50 // Otherwise return the last registered factory.
51 static UE_API TSubclassOf<class UClothingSimulationFactory> GetDefaultClothingSimulationFactoryClass();
52
53 // Return the clothing simulation factory for the specified asset.
54 // Calls SupportsAsset() internally.
55 // If multiple simulation support the specified asset type then this returns the first one registered through IClothingSimulationFactoryClassProvider.
56 static UE_API UClothingSimulationFactory* GetClothingSimulationFactory(const UClothingAssetBase* InAsset);
57
58 // Create a simulation object for a skeletal mesh to use (see IClothingSimulationInterface)
59 virtual IClothingSimulationInterface* CreateSimulation() const // TODO 5.9: Made this method into a PURE_VIRTUAL
60 {
62 return const_cast<UClothingSimulationFactory*>(this)->CreateSimulation();
64 }
65
67 UE_DEPRECATED(5.7, "Use IClothingSimulationInterface instead.")
68 virtual IClothingSimulation* CreateSimulation()
69 {
70 return nullptr;
71 }
73
74 // Destroy a simulation object, guaranteed to be a pointer returned from CreateSimulation for this factory
75 virtual void DestroySimulation(IClothingSimulationInterface* InSimulation) const // TODO 5.9: Make this method into a PURE_VIRTUAL
76 {
78 if (ensureMsgf(InSimulation && InSimulation->DynamicCastToIClothingSimulation(), TEXT("DestroySimulation(IClothingSimulationInterface*) must be implemented from 5.7, as the function will become pure virtual.")))
79 {
80 const_cast<UClothingSimulationFactory*>(this)->DestroySimulation(InSimulation->DynamicCastToIClothingSimulation());
81 }
83 }
84
86 UE_DEPRECATED(5.7, "Use IClothingSimulationInterface instead.")
87 virtual void DestroySimulation(IClothingSimulation* InSimulation) {}
89
90 // Given an asset, decide whether this factory can create a simulation to use the data inside
91 // (return false if data is invalid or missing in the case of custom data)
92 virtual bool SupportsAsset(const UClothingAssetBase* InAsset) const // TODO 5.9: Make this method into a PURE_VIRTUAL
93 {
94 return const_cast<UClothingSimulationFactory*>(this)->SupportsAsset(InAsset);
95 }
96
97 UE_DEPRECATED(5.7, "Use const version instead.")
98 virtual bool SupportsAsset(UClothingAssetBase* InAsset)
99 {
100 return false;
101 }
102
103 // Whether or not we provide an interactor object to manipulate the simulation at runtime.
104 // If true is returned then CreateInteractor *must* create a valid object to handle this
105 virtual bool SupportsRuntimeInteraction() const // TODO 5.9: Make this method into a PURE_VIRTUAL
106 {
108 return const_cast<UClothingSimulationFactory*>(this)->SupportsRuntimeInteraction();
110 }
111
112 UE_DEPRECATED(5.7, "Use const version instead.")
113 virtual bool SupportsRuntimeInteraction()
114 {
115 return false;
116 }
117
118 // Creates the runtime interactor object for a clothing simulation. This object will
119 // receive events allowing it to write data to the simulation context in a safe manner
121 PURE_VIRTUAL(UClothingSimulationFactory::CreateInteractor, return nullptr;);
122
123 // Return the cloth config type for this cloth factory
124 virtual TArrayView<const TSubclassOf<UClothConfigBase>> GetClothConfigClasses() const
125 PURE_VIRTUAL(UClothingSimulationFactory::GetClothConfigClasses, return TArrayView<const TSubclassOf<UClothConfigBase>>(););
126
127 // Return an enum of the weight map targets that can be used with this simulation.
128 virtual const UEnum* GetWeightMapTargetEnum() const
129 PURE_VIRTUAL(UClothingSimulationFactory::GetWeightMapTargetEnum, return nullptr;);
130};
131
132#undef UE_API
#define ensureMsgf( InExpression, InFormat,...)
Definition AssertionMacros.h:465
#define UE_API
Definition ClothingSimulationFactory.h:17
#define PURE_VIRTUAL(func,...)
Definition CoreMiscDefines.h:103
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
#define TEXT(x)
Definition Platform.h:1272
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 GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UCLASS(...)
Definition ObjectMacros.h:776
Definition NameTypes.h:617
Definition ClothingSimulationFactory.h:29
virtual TSubclassOf< class UClothingSimulationFactory > GetClothingSimulationFactoryClass() const =0
static UE_API const FName FeatureName
Definition ClothingSimulationFactory.h:33
Definition ClothingSimulationInterface.h:35
Definition IModularFeature.h:12
Definition ArrayView.h:139
Definition SubclassOf.h:30
Definition Class.h:3793
Definition ClothConfigBase.h:19
Definition ClothingAssetBase.h:21
Definition ClothingSimulationFactory.h:44
virtual IClothingSimulationInterface * CreateSimulation() const
Definition ClothingSimulationFactory.h:59
virtual UClothingSimulationInteractor * CreateInteractor() PURE_VIRTUAL(UClothingSimulationFactory
Definition ClothingSimulationFactory.h:120
virtual bool SupportsRuntimeInteraction() const
Definition ClothingSimulationFactory.h:105
virtual PRAGMA_ENABLE_DEPRECATION_WARNINGS bool SupportsAsset(const UClothingAssetBase *InAsset) const
Definition ClothingSimulationFactory.h:92
virtual PRAGMA_ENABLE_DEPRECATION_WARNINGS void DestroySimulation(IClothingSimulationInterface *InSimulation) const
Definition ClothingSimulationFactory.h:75
Definition ClothingSimulationInteractor.h:65
Definition Class.h:2791
Definition Object.h:95