Skip to content

Commit 2089f10

Browse files
committed
Entry Count Filter Update
1 parent 894dc99 commit 2089f10

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

Source/PCGExtendedToolkit/Private/Misc/CollectionFilters/PCGExEntryCountFilter.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "Misc/CollectionFilters/PCGExEntryCountFilter.h"
55

66
#include "PCGExHelpers.h"
7+
#include "Data/PCGExDataHelpers.h"
78
#include "Data/PCGExPointIO.h"
89

910
#define LOCTEXT_NAMESPACE "PCGExCompareFilterDefinition"
@@ -16,7 +17,22 @@ TSharedPtr<PCGExPointFilter::IFilter> UPCGExEntryCountFilterFactory::CreateFilte
1617

1718
bool PCGExPointFilter::FEntryCountFilter::Test(const TSharedPtr<PCGExData::FPointIO>& IO, const TSharedPtr<PCGExData::FPointIOCollection>& ParentCollection) const
1819
{
19-
return PCGExCompare::Compare(TypedFilterFactory->Config.Comparison, IO->GetNum(), TypedFilterFactory->Config.OperandB);
20+
int32 B = TypedFilterFactory->Config.OperandB;
21+
if (TypedFilterFactory->Config.CompareAgainst == EPCGExInputValueType::Attribute)
22+
{
23+
if (!PCGExDataHelpers::TryReadDataValue(IO->GetContext(), IO->GetIn(), TypedFilterFactory->Config.OperandBAttr, B))
24+
{
25+
switch (TypedFilterFactory->Config.MissingAttributeFallback)
26+
{
27+
case EPCGExFilterFallback::Pass:
28+
return true;
29+
case EPCGExFilterFallback::Fail:
30+
return false;
31+
}
32+
}
33+
}
34+
35+
return PCGExCompare::Compare(TypedFilterFactory->Config.Comparison, IO->GetNum(), B, TypedFilterFactory->Config.Tolerance);
2036
}
2137

2238
PCGEX_CREATE_FILTER_FACTORY(EntryCount)
@@ -25,7 +41,8 @@ PCGEX_CREATE_FILTER_FACTORY(EntryCount)
2541
FString UPCGExEntryCountFilterProviderSettings::GetDisplayName() const
2642
{
2743
FString DisplayName = TEXT("Entry Count ") + PCGExCompare::ToString(Config.Comparison);
28-
DisplayName += FString::Printf(TEXT("%d"), Config.OperandB);
44+
if (Config.CompareAgainst == EPCGExInputValueType::Constant) { DisplayName += FString::Printf(TEXT("%d"), Config.OperandB); }
45+
else { DisplayName += PCGEx::GetSelectorDisplayName(Config.OperandBAttr); }
2946
return DisplayName;
3047
}
3148
#endif

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@
88

99
#include "UObject/Object.h"
1010

11-
#include "Data/PCGExPointFilter.h"
12-
#include "PCGExPointsProcessor.h"
13-
14-
1511
#include "Misc/Filters/PCGExFilterFactoryProvider.h"
16-
12+
#include "Data/PCGExPointFilter.h"
1713

1814
#include "PCGExEntryCountFilter.generated.h"
1915

@@ -31,13 +27,26 @@ struct FPCGExEntryCountFilterConfig
3127
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Settings, meta=(PCG_Overridable))
3228
EPCGExComparison Comparison = EPCGExComparison::NearlyEqual;
3329

30+
/** Type of OperandB */
31+
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Settings, meta=(PCG_Overridable))
32+
EPCGExInputValueType CompareAgainst = EPCGExInputValueType::Constant;
33+
34+
/** Operand B for testing -- Will be translated to `int32` under the hood. */
35+
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Settings, meta=(PCG_Overridable, DisplayName="Operand B (Attr)", EditCondition="CompareAgainst != EPCGExInputValueType::Constant", EditConditionHides))
36+
FPCGAttributePropertyInputSelector OperandBAttr;
37+
3438
/** Operand B to test Entries count against */
35-
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Settings, meta=(PCG_Overridable, DisplayName="Operand B", ClampMin=0))
39+
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Settings, meta=(PCG_Overridable, DisplayName="Operand B", EditCondition="CompareAgainst == EPCGExInputValueType::Constant", EditConditionHides, ClampMin=0))
3640
int32 OperandB = 0;
3741

3842
/** Rounding mode for relative measures */
3943
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Settings, meta=(PCG_Overridable, EditCondition="Comparison == EPCGExComparison::NearlyEqual || Comparison == EPCGExComparison::NearlyNotEqual", EditConditionHides))
4044
double Tolerance = DBL_COMPARE_TOLERANCE;
45+
46+
/** What should this filter return when dealing with data that don't have the specified? */
47+
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Settings, meta = (PCG_NotOverridable, EditCondition="CompareAgainst != EPCGExInputValueType::Constant", EditConditionHides))
48+
EPCGExFilterFallback MissingAttributeFallback = EPCGExFilterFallback::Fail;
49+
4150
};
4251

4352

0 commit comments

Comments
 (0)