Skip to content

Commit 05f6248

Browse files
committed
Tweaks + remap snapping + Data Bounds filter + Parcels subgraph
1 parent 913292f commit 05f6248

25 files changed

+822
-63
lines changed
14.6 KB
Binary file not shown.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2025 Timothé Lapetite and contributors
2+
// Released under the MIT license https://opensource.org/license/MIT/
3+
4+
5+
#include "Details/PCGExDetailsCompareShorthands.h"
6+
7+
#include "PCGEx.h"
8+
#include "PCGExContext.h"
9+
#include "PCGExHelpers.h"
10+
#include "Data/PCGExDataHelpers.h"
11+
#include "Details/PCGExDetailsSettings.h"
12+
13+
14+
PCGEX_SETTING_VALUE_IMPL(FPCGExCompareSelectorDouble, , double, Input, Attribute, Constant)
15+
16+
bool FPCGExCompareSelectorDouble::TryReadDataValue(const TSharedPtr<PCGExData::FPointIO>& IO, double& OutValue, const bool bQuiet) const
17+
{
18+
return PCGExDataHelpers::TryGetSettingDataValue(IO, Input, Attribute, Constant, OutValue, bQuiet);
19+
}
20+
21+
#if WITH_EDITOR
22+
FString FPCGExCompareSelectorDouble::GetDisplayNamePostfix() const
23+
{
24+
FString DisplayName = PCGExCompare::ToString(Comparison);
25+
if (Input == EPCGExInputValueType::Attribute) { DisplayName += PCGEx::GetSelectorDisplayName(Attribute); }
26+
else { DisplayName += FString::Printf(TEXT("%.1f"), Constant); }
27+
return DisplayName;
28+
}
29+
#endif
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
// Copyright 2025 Timothé Lapetite and contributors
2+
// Released under the MIT license https://opensource.org/license/MIT/
3+
4+
#include "Misc/CollectionFilters/PCGExDataBoundsFilter.h"
5+
6+
#include "Data/PCGExPointIO.h"
7+
8+
#define LOCTEXT_NAMESPACE "PCGExCompareFilterDefinition"
9+
#define PCGEX_NAMESPACE CompareFilterDefinition
10+
11+
TSharedPtr<PCGExPointFilter::IFilter> UPCGExDataBoundsFilterFactory::CreateFilter() const
12+
{
13+
return MakeShared<PCGExPointFilter::FDataBoundsFilter>(this);
14+
}
15+
16+
bool PCGExPointFilter::FDataBoundsFilter::Test(const TSharedPtr<PCGExData::FPointIO>& IO, const TSharedPtr<PCGExData::FPointIOCollection>& ParentCollection) const
17+
{
18+
double A = 0;
19+
FVector AV = FVector::ZeroVector;
20+
const FBox Bounds = IO->GetIn()->GetBounds();
21+
double MinRatio = 0;
22+
double MaxRatio = 0;
23+
24+
switch (TypedFilterFactory->Config.OperandA)
25+
{
26+
case EPCGExDataBoundsAspect::Extents:
27+
AV = Bounds.GetExtent();
28+
break;
29+
case EPCGExDataBoundsAspect::Min:
30+
AV = Bounds.Min;
31+
break;
32+
case EPCGExDataBoundsAspect::Max:
33+
AV = Bounds.Max;
34+
break;
35+
case EPCGExDataBoundsAspect::Size:
36+
AV = Bounds.GetSize();
37+
break;
38+
case EPCGExDataBoundsAspect::Volume:
39+
AV = Bounds.GetSize();
40+
A = AV.X * AV.Y * AV.Z;
41+
break;
42+
case EPCGExDataBoundsAspect::AspectRatio:
43+
AV = Bounds.GetSize();
44+
switch (TypedFilterFactory->Config.Ratio)
45+
{
46+
case EPCGExDataBoundsRatio::XY:
47+
MinRatio = AV.X;
48+
MaxRatio = AV.Y;
49+
break;
50+
case EPCGExDataBoundsRatio::XZ:
51+
MinRatio = AV.X;
52+
MaxRatio = AV.Z;
53+
break;
54+
case EPCGExDataBoundsRatio::YZ:
55+
MinRatio = AV.Y;
56+
MaxRatio = AV.Z;
57+
break;
58+
case EPCGExDataBoundsRatio::YX:
59+
MinRatio = AV.Y;
60+
MaxRatio = AV.X;
61+
break;
62+
case EPCGExDataBoundsRatio::ZX:
63+
MinRatio = AV.Z;
64+
MaxRatio = AV.X;
65+
break;
66+
case EPCGExDataBoundsRatio::ZY:
67+
MinRatio = AV.Z;
68+
MaxRatio = AV.Y;
69+
break;
70+
}
71+
break;
72+
case EPCGExDataBoundsAspect::SortedRatio:
73+
AV = Bounds.GetSize();
74+
MinRatio = FMath::Min3(AV.X, AV.Y, AV.Z);
75+
MaxRatio = FMath::Max3(AV.X, AV.Y, AV.Z);
76+
break;
77+
}
78+
79+
if (TypedFilterFactory->Config.OperandA == EPCGExDataBoundsAspect::AspectRatio
80+
|| TypedFilterFactory->Config.OperandA == EPCGExDataBoundsAspect::SortedRatio)
81+
{
82+
A = MaxRatio / MinRatio;
83+
}else
84+
{
85+
switch (TypedFilterFactory->Config.SubOperand)
86+
{
87+
case EPCGExDataBoundsComponent::Length:
88+
A = AV.Length();
89+
break;
90+
case EPCGExDataBoundsComponent::LengthSquared:
91+
A = AV.SquaredLength();
92+
break;
93+
case EPCGExDataBoundsComponent::X:
94+
A = AV.X;
95+
break;
96+
case EPCGExDataBoundsComponent::Y:
97+
A = AV.Y;
98+
break;
99+
case EPCGExDataBoundsComponent::Z:
100+
A = AV.Z;
101+
break;
102+
}
103+
}
104+
105+
double B = 0;
106+
if (!TypedFilterFactory->Config.OperandB.TryReadDataValue(IO, B, PCGEX_QUIET_HANDLING)) { PCGEX_QUIET_HANDLING_RET }
107+
const bool bResult = TypedFilterFactory->Config.OperandB.Compare(A, B);
108+
109+
return TypedFilterFactory->Config.bInvert ? !bResult : bResult;
110+
}
111+
112+
PCGEX_CREATE_FILTER_FACTORY(DataBounds)
113+
114+
#if WITH_EDITOR
115+
FString UPCGExDataBoundsFilterProviderSettings::GetDisplayName() const
116+
{
117+
FString DisplayName = TEXT("Bound's ");
118+
119+
switch (Config.OperandA)
120+
{
121+
case EPCGExDataBoundsAspect::Extents:
122+
DisplayName += TEXT("Extents");
123+
break;
124+
case EPCGExDataBoundsAspect::Min:
125+
DisplayName += TEXT("Min");
126+
break;
127+
case EPCGExDataBoundsAspect::Max:
128+
DisplayName += TEXT("Max");
129+
break;
130+
case EPCGExDataBoundsAspect::Size:
131+
DisplayName += TEXT("Size");
132+
break;
133+
case EPCGExDataBoundsAspect::Volume:
134+
DisplayName += TEXT("Volume");
135+
break;
136+
case EPCGExDataBoundsAspect::AspectRatio:
137+
DisplayName += TEXT("Ratio");
138+
break;
139+
case EPCGExDataBoundsAspect::SortedRatio:
140+
DisplayName += TEXT("Ratio");
141+
break;
142+
}
143+
144+
if (static_cast<uint8>(Config.OperandA) < 4)
145+
{
146+
switch (Config.SubOperand)
147+
{
148+
case EPCGExDataBoundsComponent::Length:
149+
DisplayName += TEXT(".Len");
150+
break;
151+
case EPCGExDataBoundsComponent::LengthSquared:
152+
DisplayName += TEXT(".LenSq");
153+
break;
154+
case EPCGExDataBoundsComponent::X:
155+
DisplayName += TEXT(".X");
156+
break;
157+
case EPCGExDataBoundsComponent::Y:
158+
DisplayName += TEXT(".Y");
159+
break;
160+
case EPCGExDataBoundsComponent::Z:
161+
DisplayName += TEXT(".Z");
162+
break;
163+
}
164+
}
165+
166+
DisplayName += Config.OperandB.GetDisplayNamePostfix();
167+
return DisplayName;
168+
}
169+
#endif
170+
171+
#undef LOCTEXT_NAMESPACE
172+
#undef PCGEX_NAMESPACE

Source/PCGExtendedToolkit/Private/Misc/PCGExAttributeRemap.cpp

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "Data/PCGExPointIO.h"
1010
#include "Data/PCGExProxyData.h"
1111
#include "Data/PCGExProxyDataHelpers.h"
12+
#include "Details/PCGExDetailsSettings.h"
1213
#include "Details/PCGExVersion.h"
1314

1415

@@ -26,6 +27,34 @@ FString UPCGExAttributeRemapSettings::GetDisplayName() const
2627
return TEXT("Remap : ") + Attributes.Source.ToString();
2728
}
2829

30+
double FPCGExRemapDetails::GetRemappedValue(const double Value, const double Step) const
31+
{
32+
switch (Snapping)
33+
{
34+
default:
35+
case EPCGExVariationSnapping::None:
36+
return PCGExMath::TruncateDbl(
37+
RemapCurveObj->Eval(PCGExMath::Remap(Value, InMin, InMax, 0, 1)) * Scale,
38+
TruncateOutput) * PostTruncateScale + Offset;
39+
case EPCGExVariationSnapping::SnapOffset:
40+
{
41+
double V = PCGExMath::TruncateDbl(
42+
RemapCurveObj->Eval(PCGExMath::Remap(Value, InMin, InMax, 0, 1)) * Scale,
43+
TruncateOutput) * PostTruncateScale;
44+
PCGExMath::Snap(V, Step);
45+
return V + Offset;
46+
}
47+
case EPCGExVariationSnapping::SnapResult:
48+
{
49+
double V = PCGExMath::TruncateDbl(
50+
RemapCurveObj->Eval(PCGExMath::Remap(Value, InMin, InMax, 0, 1)) * Scale,
51+
TruncateOutput) * PostTruncateScale + Offset;
52+
PCGExMath::Snap(V, Step);
53+
return V;
54+
}
55+
}
56+
}
57+
2958
void UPCGExAttributeRemapSettings::ApplyDeprecation(UPCGNode* InOutNode)
3059
{
3160
PCGEX_UPDATE_TO_DATA_VERSION(1, 70, 11)
@@ -239,6 +268,7 @@ namespace PCGExAttributeRemap
239268
{
240269
Rule.MinCache = MakeShared<PCGExMT::TScopedNumericValue<double>>(Loops, MAX_dbl);
241270
Rule.MaxCache = MakeShared<PCGExMT::TScopedNumericValue<double>>(Loops, MIN_dbl_neg);
271+
Rule.SnapCache = Rule.RemapDetails.Snap.GetValueSetting();
242272
}
243273
};
244274

@@ -312,7 +342,7 @@ namespace PCGExAttributeRemap
312342
double V = InProxy->Get(i);
313343
OutProxy->Set(
314344
i, Rule.OutputClampDetails.GetClampedValue(
315-
Rule.RemapDetails.GetRemappedValue(FMath::Abs(V)) * PCGExMath::SignPlus(V)));
345+
Rule.RemapDetails.GetRemappedValue(FMath::Abs(V), Rule.SnapCache->Read(i)) * PCGExMath::SignPlus(V)));
316346
}
317347
}
318348
else
@@ -322,7 +352,7 @@ namespace PCGExAttributeRemap
322352
OutProxy->Set(
323353
i, Rule.OutputClampDetails.GetClampedValue(
324354
Rule.RemapDetails.GetRemappedValue(
325-
FMath::Abs(InProxy->Get(i)))));
355+
FMath::Abs(InProxy->Get(i)), Rule.SnapCache->Read(i))));
326356
}
327357
}
328358
}
@@ -335,7 +365,7 @@ namespace PCGExAttributeRemap
335365
OutProxy->Set(
336366
i, Rule.OutputClampDetails.GetClampedValue(
337367
Rule.RemapDetails.GetRemappedValue(
338-
InProxy->Get(i))));
368+
InProxy->Get(i), Rule.SnapCache->Read(i))));
339369
}
340370
}
341371
else
@@ -345,7 +375,7 @@ namespace PCGExAttributeRemap
345375
OutProxy->Set(
346376
i, Rule.OutputClampDetails.GetClampedValue(
347377
Rule.RemapDetails.GetRemappedValue(
348-
FMath::Abs(InProxy->Get(i)))));
378+
FMath::Abs(InProxy->Get(i)), Rule.SnapCache->Read(i))));
349379
}
350380
}
351381
}

Source/PCGExtendedToolkit/Private/Misc/PCGExUberBranch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ TArray<FPCGPinProperties> UPCGExUberBranchSettings::InputPinProperties() const
3838

3939
for (int i = 0; i < NumBranches; i++)
4040
{
41-
PCGEX_PIN_FILTERS(InputLabels[i], "Collection filters. Only support C-Filter or regular filters that are set-up to work with data bounds or @Data attributes.", Normal)
41+
PCGEX_PIN_FILTERS(InputLabels[i], "Collection filters. Only support Data Filter or regular filters that are set-up to work with data bounds or @Data attributes.", Normal)
4242
}
4343

4444
return PinProperties;

Source/PCGExtendedToolkit/Public/Data/Matching/PCGExMatchTagToAttr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct FPCGExMatchTagToAttrConfig : public FPCGExMatchRuleConfigBase
5757
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Settings, meta=(PCG_NotOverridable, DisplayName="Comparison", EditCondition="bDoValueMatch && ValueType == EPCGExComparisonDataType::Numeric", EditConditionHides))
5858
EPCGExComparison NumericComparison = EPCGExComparison::NearlyEqual;
5959

60-
/** Rounding mode for relative measures */
60+
/** Near-equality tolerance */
6161
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Settings, meta=(PCG_NotOverridable, EditCondition="bDoValueMatch && ValueType == EPCGExComparisonDataType::Numeric && (NumericComparison == EPCGExComparison::NearlyEqual || NumericComparison == EPCGExComparison::NearlyNotEqual)", EditConditionHides))
6262
double Tolerance = DBL_COMPARE_TOLERANCE;
6363

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright 2025 Timothé Lapetite and contributors
2+
// Released under the MIT license https://opensource.org/license/MIT/
3+
4+
#pragma once
5+
6+
#include "CoreMinimal.h"
7+
#include "PCGExCommon.h"
8+
#include "PCGExCompare.h"
9+
#include "PCGExSettingsMacros.h"
10+
#include "Metadata/PCGAttributePropertySelector.h"
11+
#include "PCGExDetailsCompareShorthands.generated.h"
12+
13+
namespace PCGExData
14+
{
15+
class FPointIO;
16+
}
17+
18+
struct FPCGExContext;
19+
20+
USTRUCT(BlueprintType)
21+
struct PCGEXTENDEDTOOLKIT_API FPCGExCompareSelectorDouble
22+
{
23+
GENERATED_BODY()
24+
25+
FPCGExCompareSelectorDouble() = default;
26+
explicit FPCGExCompareSelectorDouble(const FString& DefaultName) { Attribute.Update(DefaultName); }
27+
28+
FPCGExCompareSelectorDouble(const FString& DefaultName, const bool DefaultValue)
29+
: FPCGExCompareSelectorDouble(DefaultName)
30+
{
31+
Constant = DefaultValue;
32+
}
33+
34+
PCGEX_SETTING_VALUE_DECL(, double)
35+
bool TryReadDataValue(const TSharedPtr<PCGExData::FPointIO>& IO, double& OutValue, const bool bQuiet = false) const;
36+
37+
/** Comparison */
38+
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Settings, meta=(PCG_Overridable))
39+
EPCGExComparison Comparison = EPCGExComparison::NearlyEqual;
40+
41+
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Settings, meta = (PCG_Overridable))
42+
EPCGExInputValueType Input = EPCGExInputValueType::Constant;
43+
44+
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Settings, meta = (PCG_Overridable))
45+
FPCGAttributePropertyInputSelector Attribute;
46+
47+
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Settings, meta = (PCG_Overridable))
48+
double Constant = 0;
49+
50+
/** Near-equality tolerance */
51+
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Settings, meta=(PCG_Overridable, EditCondition="Comparison == EPCGExComparison::NearlyEqual || Comparison == EPCGExComparison::NearlyNotEqual", EditConditionHides))
52+
double Tolerance = DBL_COMPARE_TOLERANCE;
53+
54+
FORCEINLINE bool Compare(const double A, const double B) const { return PCGExCompare::Compare(Comparison, A, B, Tolerance); }
55+
56+
#if WITH_EDITOR
57+
FString GetDisplayNamePostfix() const;
58+
#endif
59+
};

Source/PCGExtendedToolkit/Public/Misc/CollectionFilters/PCGExAttributeCheckFilter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class UPCGExAttributeCheckFilterProviderSettings : public UPCGExFilterProviderSe
105105
//~Begin UPCGSettings
106106
#if WITH_EDITOR
107107
PCGEX_NODE_INFOS_CUSTOM_SUBTITLE(
108-
AttributeCheckFilterFactory, "C-Filter : Attribute Check", "Simple attribute existence check.",
108+
AttributeCheckFilterFactory, "Data Filter : Attribute Check", "Simple attribute existence check.",
109109
PCGEX_FACTORY_NAME_PRIORITY)
110110
#endif
111111
//~End UPCGSettings

0 commit comments

Comments
 (0)