UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Properties.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
8
9namespace Chaos
10{
11
12template <typename T, EChaosProperty PropName>
14{
15public:
16 TChaosProperty() = default;
18 : Property(Val)
19 {
20 }
21
22 //we don't support this because it could lead to bugs with values not being properly written to remote
24
26 {
27 return Flags.IsDirty(PropertyFlag);
28 }
29
30 const T& Read() const { return Property; }
31 void Write(const T& Val, bool bInvalidate, FDirtyChaosPropertyFlags& Dirty, IPhysicsProxyBase* Proxy)
32 {
33 Property = Val;
34 MarkDirty(bInvalidate, Dirty, Proxy);
35 }
36
37 template <typename Lambda>
39 {
40 LambdaFunc(Property);
41 MarkDirty(bInvalidate, Dirty, Proxy);
42 }
43
45 {
46 Dirty.MarkClean(PropertyFlag);
47 if (Proxy && Dirty.IsClean())
48 {
50 {
51 PhysicsSolverBase->RemoveDirtyProxyIfNoShapesAreDirty(Proxy);
52 }
53 }
54 }
55
57 {
58 Remote.SyncRemote<T,PropName>(Manager, DataIdx, Property);
59 }
60
62 {
63 Ar << Property;
64 }
65
66private:
67 T Property;
68 static constexpr EChaosPropertyFlags PropertyFlag = ChaosPropertyToFlag(PropName);
69
70 void MarkDirty(bool bInvalidate, FDirtyChaosPropertyFlags& Dirty, IPhysicsProxyBase* Proxy)
71 {
72 if(bInvalidate)
73 {
74 Dirty.MarkDirty(PropertyFlag);
75
76 if(Proxy)
77 {
79 {
80 PhysicsSolverBase->AddDirtyProxy(Proxy);
81 }
82 }
83 }
84 }
85
86 //we don't support this because it could lead to bugs with values not being properly written to remote
87 TChaosProperty<T,PropName>& operator=(const TChaosProperty<T,PropName>& Rhs) = delete;
88};
89
90template <typename T, EChaosProperty PropName>
92{
93 //TODO: should this only work with dirty flag? Not sure if this path really matters at this point
94 Prop.Serialize(Ar);
95 return Ar;
96}
97
98
99template <typename T,EShapeProperty PropName>
101{
102public:
103 TShapeProperty() = default;
105 : Property(Val)
106 {
107 }
111
112 //we don't support this because it could lead to bugs with values not being properly written to remote
114
115 const T& Read() const { return Property; }
116 void Write(const T& Val,bool bInvalidate,FShapeDirtyFlags& Dirty,IPhysicsProxyBase* Proxy, int32 ShapeIdx)
117 {
118 Property = Val;
119 MarkDirty(bInvalidate,Dirty,Proxy, ShapeIdx);
120 }
121
122 template <typename Lambda>
123 void Modify(bool bInvalidate,FShapeDirtyFlags& Dirty,IPhysicsProxyBase* Proxy, int32 ShapeIdx, const Lambda& LambdaFunc)
124 {
126 MarkDirty(bInvalidate,Dirty,Proxy, ShapeIdx);
127 }
128
130 {
131 Remote.SyncRemote<T,PropName>(Manager, DataIdx, Property);
132 }
133
135 {
136 Ar << Property;
137 }
138
139private:
140 T Property;
141 static constexpr EShapeFlags PropertyFlag = ShapePropToFlag(PropName);
142
143 void MarkDirty(bool bInvalidate, FShapeDirtyFlags& Dirty,IPhysicsProxyBase* Proxy, int32 ShapeIdx)
144 {
145 if(bInvalidate)
146 {
147 const bool bFirstDirty = Dirty.IsClean();
148 Dirty.MarkDirty(PropertyFlag);
149
150 if(bFirstDirty && Proxy)
151 {
153 {
154 PhysicsSolverBase->AddDirtyProxyShape(Proxy, ShapeIdx);
155 }
156 }
157 }
158 }
159
160 //we don't support this because it could lead to bugs with values not being properly written to remote
161 TShapeProperty<T, PropName>& operator=(const TShapeProperty<T, PropName>& Rhs) = delete;
162};
163
164template <typename T,EShapeProperty PropName>
166{
167 //TODO: should this use dirty flags? not sure if this path even matters
168 Prop.Serialize(Ar);
169 return Ar;
170}
171}
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
float Val(const FString &Value)
Definition UnrealMath.cpp:3163
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
Definition ChaosArchive.h:167
Definition ParticleDirtyFlags.h:1129
Definition ParticleDirtyFlags.h:1039
Definition PhysicsSolverBase.h:313
Definition ParticleDirtyFlags.h:1228
Definition Properties.h:14
void Clear(FDirtyChaosPropertyFlags &Dirty, IPhysicsProxyBase *Proxy)
Definition Properties.h:44
void Modify(bool bInvalidate, FDirtyChaosPropertyFlags &Dirty, IPhysicsProxyBase *Proxy, const Lambda &LambdaFunc)
Definition Properties.h:38
void Write(const T &Val, bool bInvalidate, FDirtyChaosPropertyFlags &Dirty, IPhysicsProxyBase *Proxy)
Definition Properties.h:31
void Serialize(FChaosArchive &Ar)
Definition Properties.h:61
const T & Read() const
Definition Properties.h:30
void SyncRemote(FDirtyPropertiesManager &Manager, int32 DataIdx, const FDirtyChaosProperties &Remote) const
Definition Properties.h:56
TChaosProperty(const TChaosProperty< T, PropName > &Rhs)=delete
bool IsDirty(const FDirtyChaosPropertyFlags &Flags) const
Definition Properties.h:25
TChaosProperty(const T &Val)
Definition Properties.h:17
Definition Properties.h:101
void Serialize(FChaosArchive &Ar)
Definition Properties.h:134
TShapeProperty(TShapeProperty< T, PropName > &&Other)
Definition Properties.h:108
const T & Read() const
Definition Properties.h:115
void Write(const T &Val, bool bInvalidate, FShapeDirtyFlags &Dirty, IPhysicsProxyBase *Proxy, int32 ShapeIdx)
Definition Properties.h:116
TShapeProperty(const T &Val)
Definition Properties.h:104
TShapeProperty(const TShapeProperty< T, PropName > &Rhs)=delete
void SyncRemote(FDirtyPropertiesManager &Manager, int32 DataIdx, FShapeDirtyData &Remote) const
Definition Properties.h:129
void Modify(bool bInvalidate, FShapeDirtyFlags &Dirty, IPhysicsProxyBase *Proxy, int32 ShapeIdx, const Lambda &LambdaFunc)
Definition Properties.h:123
Definition PhysicsProxyBase.h:97
SOLVER_TYPE * GetSolver() const
Definition PhysicsProxyBase.h:110
Definition SkeletalMeshComponent.h:307
EChaosPropertyFlags
Definition ParticleDirtyFlags.h:869
FChaosArchive & operator<<(FChaosArchive &Ar, FRigidParticleControlFlags &Flags)
Definition RigidParticleControlFlags.cpp:15
constexpr EChaosPropertyFlags ChaosPropertyToFlag(EChaosProperty Prop)
Definition ParticleDirtyFlags.h:875
constexpr EShapeFlags ShapePropToFlag(EShapeProperty Prop)
Definition ParticleDirtyFlags.h:905
EShapeFlags
Definition ParticleDirtyFlags.h:899