UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PointWeightMap.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include <type_traits>
5
7#include "PointWeightMap.generated.h"
8
10UENUM()
12{
13 None = 0, // None, should always be zero
14 MaxDistance, // The distance that each vertex can move away from its reference (skinned) position
15 BackstopDistance, // Distance along the plane of the surface that the particles can travel (separation constraint)
16 BackstopRadius, // Radius of movement to allow for backstop movement
17 AnimDriveStiffness, // Strength of anim drive per-particle (spring driving particle back to skinned location
18 AnimDriveDamping_DEPRECATED UMETA(Hidden), // Chaos onlyweightmap, deprecated from the common declaration
20 // Users can add additional targets between this range.
21 LastUserTarget = 200,
22 // Add additional common targets after here.
24};
25
31USTRUCT()
33{
35
37#if WITH_EDITORONLY_DATA
39 , CurrentTarget((uint8)EWeightMapTargetCommon::None)
40 , bEnabled(false)
41#endif
42 {}
43
44 explicit FPointWeightMap(int32 NumPoints, float Value = 0.f)
45#if WITH_EDITORONLY_DATA
47 , CurrentTarget((uint8)EWeightMapTargetCommon::None)
48 , bEnabled(false)
49#endif
50 {
51 Values.Init(Value, NumPoints);
52 }
53
55 : Values(InValues)
58 , CurrentTarget((uint8)EWeightMapTargetCommon::None)
59 , bEnabled(false)
60#endif
61 {}
62
64#if WITH_EDITORONLY_DATA
66 , CurrentTarget((uint8)EWeightMapTargetCommon::None)
67 , bEnabled(false)
68#endif
69 {
70 const int32 NumPoints = InValues.Num();
71 Values.SetNumUninitialized(NumPoints);
72 for (int32 Index = 0; Index < NumPoints; ++Index)
73 {
74 Values[Index] = Offset + Scale * InValues[Index];
75 }
76 }
77
80
85 void Initialize(const int32 NumPoints)
86 {
87 Values.Init(0.f, NumPoints);
88#if WITH_EDITORONLY_DATA
89 CurrentTarget = (uint8)EWeightMapTargetCommon::None;
90 bEnabled = false;
91#endif
92 }
93
98 template <
99 typename T
100 UE_REQUIRES(std::is_enum_v<T> || std::is_arithmetic_v<T>)
101 >
102 void Initialize(const FPointWeightMap& Source, T Target)
103 {
104 Values = Source.Values;
105#if WITH_EDITORONLY_DATA
106 CurrentTarget = (uint8)Target;
107 bEnabled = true;
108#endif
109 }
110
112 void Empty()
113 { Values.Empty(); }
114
116 int32 Num() const
117 { return Values.Num(); }
118
123 const float& operator[](int32 Index) const
124 { return Values[Index]; }
125
131 { return Values[Index]; }
132
137 float GetValue(int32 Index) const
138 { return Values.IsValidIndex(Index) ? Values[Index] : 0.f; }
139
146 { if (Values.IsValidIndex(Index)) Values[Index] = Value; }
147
153 bool IsBelowThreshold(const int32 Index, const float Threshold=0.1f) const
154 { return Values.IsValidIndex(Index) && Values[Index] <= Threshold; }
155
157 bool AreAnyBelowThreshold(const int32 Index0, const int32 Index1, const int32 Index2, const float Threshold=0.1f) const
158 { return IsBelowThreshold(Index0, Threshold) || IsBelowThreshold(Index1, Threshold) || IsBelowThreshold(Index2, Threshold); }
159
161 bool AreAllBelowThreshold(const int32 Index0, const int32 Index1, const int32 Index2, const float Threshold=0.1f) const
162 { return IsBelowThreshold(Index0, Threshold) && IsBelowThreshold(Index1, Threshold) && IsBelowThreshold(Index2, Threshold); }
163
165 bool IsZeroed() const
166 { return !Values.FindByPredicate([](const float& Value) { return Value != 0.f; }); }
167
169 void CalcRanges(float& MinValue, float& MaxValue)
170 { MinValue = FMath::Min(Values); MaxValue = FMath::Max(Values); }
171
173 UPROPERTY()
174 TArray<float> Values;
175
176#if WITH_EDITORONLY_DATA
178 UPROPERTY()
179 FName Name;
180
182 UPROPERTY()
183 uint8 CurrentTarget;
184
186 UPROPERTY()
187 bool bEnabled;
188#endif
189};
#define WITH_EDITORONLY_DATA
Definition CoreMiscDefines.h:24
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 UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define UENUM(...)
Definition ObjectMacros.h:749
#define USTRUCT(...)
Definition ObjectMacros.h:746
EWeightMapTargetCommon
Definition PointWeightMap.h:12
#define UE_REQUIRES(...)
Definition Requires.h:86
uint32 Offset
Definition VulkanMemory.cpp:4033
if(Failed) console_printf("Failed.\n")
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition NameTypes.h:617
Definition Array.h:670
@ false
Definition radaudio_common.h:23
U16 Index
Definition radfft.cpp:71
Definition PointWeightMap.h:33
~FPointWeightMap()
Definition PointWeightMap.h:78
void SetValue(int32 Index, float Value)
Definition PointWeightMap.h:145
FPointWeightMap(int32 NumPoints, float Value=0.f)
Definition PointWeightMap.h:44
float GetValue(int32 Index) const
Definition PointWeightMap.h:137
const float & operator[](int32 Index) const
Definition PointWeightMap.h:123
float & operator[](int32 Index)
Definition PointWeightMap.h:130
void CalcRanges(float &MinValue, float &MaxValue)
Definition PointWeightMap.h:169
bool AreAllBelowThreshold(const int32 Index0, const int32 Index1, const int32 Index2, const float Threshold=0.1f) const
Definition PointWeightMap.h:161
bool AreAnyBelowThreshold(const int32 Index0, const int32 Index1, const int32 Index2, const float Threshold=0.1f) const
Definition PointWeightMap.h:157
bool IsZeroed() const
Definition PointWeightMap.h:165
void Initialize(const FPointWeightMap &Source, T Target)
Definition PointWeightMap.h:102
void Empty()
Definition PointWeightMap.h:112
FPointWeightMap()
Definition PointWeightMap.h:36
int32 Num() const
Definition PointWeightMap.h:116
FPointWeightMap(const TConstArrayView< float > &InValues)
Definition PointWeightMap.h:54
FPointWeightMap(const TConstArrayView< float > &InValues, float Offset, float Scale)
Definition PointWeightMap.h:63
bool IsBelowThreshold(const int32 Index, const float Threshold=0.1f) const
Definition PointWeightMap.h:153
void Initialize(const int32 NumPoints)
Definition PointWeightMap.h:85