Skip to content

Commit

Permalink
Merge pull request #74 from Nebukam/filter-cleanup
Browse files Browse the repository at this point in the history
Filter cleanup
  • Loading branch information
Nebukam authored Oct 10, 2024
2 parents 183787b + af9438b commit 41ca407
Show file tree
Hide file tree
Showing 267 changed files with 928 additions and 756 deletions.
1 change: 1 addition & 0 deletions Config/DefaultPCGExtendedToolkit.ini
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@
+StructRedirects=(OldName="/Script/PCGExtendedToolkit.PCGExNeighborsCountFilterConfig",NewName="/Script/PCGExtendedToolkit.PCGExNodeNeighborsCountFilterConfig")
+StructRedirects=(OldName="/Script/PCGExtendedToolkit.PCGExEdgeDirectionFilterConfig",NewName="/Script/PCGExtendedToolkit.PCGExNodeEdgeDirectionFilterConfig")
+ClassRedirects=(OldName="/Script/PCGExtendedToolkit.PCGExEdgeDirectionFilterProviderSettings",NewName="/Script/PCGExtendedToolkit.PCGExNodeEdgeDirectionFilterProviderSettings")
+ClassRedirects=(OldName="/Script/PCGExtendedToolkit.PCGExEdgeRemoveByFilter",NewName="/Script/PCGExtendedToolkit.PCGExEdgeRefineByFilter")
Binary file not shown.
Binary file modified Content/Subgraphs/NodeFlagsPresets/PCGEx_NodeFlags_Edges_XY.uasset
Binary file not shown.
Binary file modified Content/Subgraphs/NodeFlagsPresets/PCGEx_NodeFlags_Edges_XZ.uasset
Binary file not shown.
Binary file not shown.
Binary file modified Content/Subgraphs/NodeFlagsPresets/PCGEx_NodeFlags_Faces_X.uasset
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ bool FPCGExAssetCollectionToSetElement::ExecuteInternal(FPCGContext* Context) co
return OutputToPin();
}

PCGExAssetCollection::FCache* MainCache = MainCollection->LoadCache();
const PCGExAssetCollection::FCache* MainCache = MainCollection->LoadCache();
TArray<const FPCGExAssetStagingData*> StagingDataList;

const FPCGExAssetStagingData* StagingData = nullptr;
Expand All @@ -113,7 +113,7 @@ bool FPCGExAssetCollectionToSetElement::ExecuteInternal(FPCGContext* Context) co

for (const FPCGExAssetStagingData* S : StagingDataList)
{
int64 Key = OutputSet->Metadata->AddEntry();
const int64 Key = OutputSet->Metadata->AddEntry();

if (!S || S->bIsSubCollection)
{
Expand Down Expand Up @@ -164,7 +164,7 @@ void FPCGExAssetCollectionToSetElement::ProcessStagingData(
if (SubHandling == EPCGExSubCollectionToSet::Ignore) { return; }

UPCGExAssetCollection* SubCollection = InStagingData->LoadSynchronous<UPCGExAssetCollection>();
PCGExAssetCollection::FCache* SubCache = SubCollection ? SubCollection->LoadCache() : nullptr;
const PCGExAssetCollection::FCache* SubCache = SubCollection ? SubCollection->LoadCache() : nullptr;

if (!SubCache)
{
Expand All @@ -188,7 +188,6 @@ void FPCGExAssetCollectionToSetElement::ProcessStagingData(
ProcessStagingData(NestedStaging, OutStagingDataList, bOmitInvalidAndEmpty, bNoDuplicates, SubHandling, GUIDS);
}
return;
break;
case EPCGExSubCollectionToSet::PickRandom:
SubCollection->GetStagingRandom(NestedStaging, 0);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ bool FPCGExAssetStagingElement::ExecuteInternal(FPCGContext* InContext) const

namespace PCGExAssetStaging
{
bool FProcessor::Process(TSharedPtr<PCGExMT::FTaskManager> InAsyncManager)
bool FProcessor::Process(const TSharedPtr<PCGExMT::FTaskManager> InAsyncManager)
{
TRACE_CPUPROFILER_EVENT_SCOPE(PCGExAssetStaging::Process);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

#include "Collections/PCGExMeshCollection.h"

#include "PCGEx.h"
#include "PCGExMacros.h"

bool FPCGExMeshCollectionEntry::Validate(const UPCGExAssetCollection* ParentCollection)
{
if (bIsSubCollection) { LoadSubCollection(SubCollection); }
Expand Down
4 changes: 2 additions & 2 deletions Source/PCGExtendedToolkit/Private/Data/PCGExDataForward.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace PCGExData
// ReSharper disable once CppRedundantTemplateKeyword
const FPCGMetadataAttribute<T>* SourceAtt = SourceDataFacade->GetIn()->Metadata->template GetConstTypedAttribute<T>(Identity.Name);
if (!SourceAtt) { return; }

TSharedPtr<TBuffer<T>> Writer = InTargetDataFacade->GetWritable<T>(SourceAtt, true);

const T ForwardValue = SourceAtt->GetValueFromItemKey(SourceDataFacade->Source->GetInPoint(SourceIndex).MetadataEntry);
Expand All @@ -123,7 +123,7 @@ namespace PCGExData
// ReSharper disable once CppRedundantTemplateKeyword
const FPCGMetadataAttribute<T>* SourceAtt = SourceDataFacade->GetIn()->Metadata->template GetConstTypedAttribute<T>(Identity.Name);
if (!SourceAtt) { return; }

InTargetDataFacade->Source->DeleteAttribute(Identity.Name);
FPCGMetadataAttribute<T>* Mark = InTargetDataFacade->Source->FindOrCreateAttribute<T>(
Identity.Name,
Expand Down
40 changes: 17 additions & 23 deletions Source/PCGExtendedToolkit/Private/Data/PCGExFilterGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,17 @@
#include "Data/PCGExFilterGroup.h"








#include "Graph/PCGExCluster.h"

namespace PCGExFilterGroup
{
bool TFilterGroup::Init(const FPCGContext* InContext, const TSharedPtr<PCGExData::FFacade> InPointDataFacade)
bool FFilterGroup::Init(const FPCGContext* InContext, const TSharedPtr<PCGExData::FFacade> InPointDataFacade)
{
PointDataFacade = InPointDataFacade;
return InitManaged(InContext);
}

bool TFilterGroup::Init(const FPCGContext* InContext, const TSharedRef<PCGExCluster::FCluster>& InCluster, const TSharedRef<PCGExData::FFacade>& InPointDataFacade, const TSharedRef<PCGExData::FFacade>& InEdgeDataFacade)
bool FFilterGroup::Init(const FPCGContext* InContext, const TSharedRef<PCGExCluster::FCluster>& InCluster, const TSharedRef<PCGExData::FFacade>& InPointDataFacade, const TSharedRef<PCGExData::FFacade>& InEdgeDataFacade)
{
bInitForCluster = true;
Cluster = InCluster;
Expand All @@ -29,7 +23,7 @@ namespace PCGExFilterGroup
return InitManaged(InContext);
}

void TFilterGroup::PostInit()
void FFilterGroup::PostInit()
{
// No internal init yet, will cause issues with local caching

Expand All @@ -41,11 +35,11 @@ namespace PCGExFilterGroup
*/
}

bool TFilterGroup::InitManaged(const FPCGContext* InContext)
bool FFilterGroup::InitManaged(const FPCGContext* InContext)
{
for (const UPCGExFilterFactoryBase* ManagedFactory : *ManagedFactories)
{
TSharedPtr<PCGExPointFilter::TFilter> NewFilter = ManagedFactory->CreateFilter();
TSharedPtr<PCGExPointFilter::FFilter> NewFilter = ManagedFactory->CreateFilter();
NewFilter->bCacheResults = false;
if (!InitManagedFilter(InContext, NewFilter)) { continue; }
ManagedFilters.Add(NewFilter);
Expand All @@ -54,22 +48,22 @@ namespace PCGExFilterGroup
return PostInitManaged(InContext);
}

bool TFilterGroup::InitManagedFilter(const FPCGContext* InContext, const TSharedPtr<PCGExPointFilter::TFilter>& Filter) const
bool FFilterGroup::InitManagedFilter(const FPCGContext* InContext, const TSharedPtr<PCGExPointFilter::FFilter>& Filter) const
{
if (Filter->GetFilterType() == PCGExFilters::EType::Point) { return Filter->Init(InContext, PointDataFacade); }

if (Filter->GetFilterType() == PCGExFilters::EType::Group)
{
if (bInitForCluster)
{
TFilterGroup* FilterGroup = static_cast<TFilterGroup*>(Filter.Get());
FFilterGroup* FilterGroup = static_cast<FFilterGroup*>(Filter.Get());
return FilterGroup->Init(InContext, Cluster.ToSharedRef(), PointDataFacade.ToSharedRef(), EdgeDataCache.ToSharedRef());
}

return Filter->Init(InContext, PointDataFacade);
}

if ( PCGExFactories::ClusterSpecificFilters.Contains(Filter->Factory->GetFactoryType()))
if (PCGExFactories::ClusterSpecificFilters.Contains(Filter->Factory->GetFactoryType()))
{
if (!bInitForCluster)
{
Expand All @@ -78,49 +72,49 @@ namespace PCGExFilterGroup
return false;
}

TFilter* ClusterFilter = static_cast<TFilter*>(Filter.Get());
FFilter* ClusterFilter = static_cast<FFilter*>(Filter.Get());
return ClusterFilter->Init(InContext, Cluster.ToSharedRef(), PointDataFacade.ToSharedRef(), EdgeDataCache.ToSharedRef());
}

return false;
}

bool TFilterGroup::PostInitManaged(const FPCGContext* InContext)
bool FFilterGroup::PostInitManaged(const FPCGContext* InContext)
{
bValid = !ManagedFilters.IsEmpty();

if (!bValid) { return false; }

// Sort mappings so higher priorities come last, as they have to potential to override values.
ManagedFilters.Sort([&](const TSharedPtr<PCGExPointFilter::TFilter>& A, const TSharedPtr<PCGExPointFilter::TFilter>& B) { return A->Factory->Priority < B->Factory->Priority; });
ManagedFilters.Sort([&](const TSharedPtr<PCGExPointFilter::FFilter>& A, const TSharedPtr<PCGExPointFilter::FFilter>& B) { return A->Factory->Priority < B->Factory->Priority; });

// Update index & post-init
for (int i = 0; i < ManagedFilters.Num(); i++)
{
TSharedPtr<PCGExPointFilter::TFilter> Filter = ManagedFilters[i];
TSharedPtr<PCGExPointFilter::FFilter> Filter = ManagedFilters[i];
Filter->FilterIndex = i;
PostInitManagedFilter(InContext, Filter);
}

return true;
}

void TFilterGroup::PostInitManagedFilter(const FPCGContext* InContext, const TSharedPtr<PCGExPointFilter::TFilter>& InFilter)
void FFilterGroup::PostInitManagedFilter(const FPCGContext* InContext, const TSharedPtr<PCGExPointFilter::FFilter>& InFilter)
{
InFilter->PostInit();
}
}

TSharedPtr<PCGExPointFilter::TFilter> UPCGExFilterGroupFactoryBaseAND::CreateFilter() const
TSharedPtr<PCGExPointFilter::FFilter> UPCGExFilterGroupFactoryBaseAND::CreateFilter() const
{
TSharedPtr<PCGExFilterGroup::TFilterGroupAND> NewFilterGroup = MakeShared<PCGExFilterGroup::TFilterGroupAND>(this, &FilterFactories);
TSharedPtr<PCGExFilterGroup::FFilterGroupAND> NewFilterGroup = MakeShared<PCGExFilterGroup::FFilterGroupAND>(this, &FilterFactories);
NewFilterGroup->bInvert = bInvert;
return NewFilterGroup;
}

TSharedPtr<PCGExPointFilter::TFilter> UPCGExFilterGroupFactoryBaseOR::CreateFilter() const
TSharedPtr<PCGExPointFilter::FFilter> UPCGExFilterGroupFactoryBaseOR::CreateFilter() const
{
TSharedPtr<PCGExFilterGroup::TFilterGroupOR> NewFilterGroup = MakeShared<PCGExFilterGroup::TFilterGroupOR>(this, &FilterFactories);
TSharedPtr<PCGExFilterGroup::FFilterGroupOR> NewFilterGroup = MakeShared<PCGExFilterGroup::FFilterGroupOR>(this, &FilterFactories);
NewFilterGroup->bInvert = bInvert;
return NewFilterGroup;
}
48 changes: 24 additions & 24 deletions Source/PCGExtendedToolkit/Private/Data/PCGExPointFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "Graph/PCGExCluster.h"

TSharedPtr<PCGExPointFilter::TFilter> UPCGExFilterFactoryBase::CreateFilter() const
TSharedPtr<PCGExPointFilter::FFilter> UPCGExFilterFactoryBase::CreateFilter() const
{
return nullptr;
}
Expand All @@ -19,37 +19,37 @@ bool UPCGExFilterFactoryBase::Init(FPCGExContext* InContext)

namespace PCGExPointFilter
{
bool TFilter::Init(const FPCGContext* InContext, const TSharedPtr<PCGExData::FFacade> InPointDataFacade)
bool FFilter::Init(const FPCGContext* InContext, const TSharedPtr<PCGExData::FFacade> InPointDataFacade)
{
PointDataFacade = InPointDataFacade;
return true;
}

void TFilter::PostInit()
void FFilter::PostInit()
{
if (!bCacheResults) { return; }
const int32 NumResults = PointDataFacade->Source->GetNum();
Results.Init(false, NumResults);
}

bool TFilter::Test(const int32 Index) const PCGEX_NOT_IMPLEMENTED_RET(TFilter::Test(const int32 Index), false)
bool TFilter::Test(const PCGExCluster::FNode& Node) const { return Test(Node.PointIndex); }
bool TFilter::Test(const PCGExGraph::FIndexedEdge& Edge) const { return Test(Edge.PointIndex); }
bool FFilter::Test(const int32 Index) const PCGEX_NOT_IMPLEMENTED_RET(FFilter::Test(const int32 Index), false)
bool FFilter::Test(const PCGExCluster::FNode& Node) const { return Test(Node.PointIndex); }
bool FFilter::Test(const PCGExGraph::FIndexedEdge& Edge) const { return Test(Edge.PointIndex); }

bool TSimpleFilter::Test(const int32 Index) const PCGEX_NOT_IMPLEMENTED_RET(TEdgeFilter::Test(const PCGExCluster::FNode& Node), false)
bool TSimpleFilter::Test(const PCGExCluster::FNode& Node) const { return Test(Node.PointIndex); }
bool TSimpleFilter::Test(const PCGExGraph::FIndexedEdge& Edge) const { return Test(Edge.PointIndex); }
bool FSimpleFilter::Test(const int32 Index) const PCGEX_NOT_IMPLEMENTED_RET(TEdgeFilter::Test(const PCGExCluster::FNode& Node), false)
bool FSimpleFilter::Test(const PCGExCluster::FNode& Node) const { return Test(Node.PointIndex); }
bool FSimpleFilter::Test(const PCGExGraph::FIndexedEdge& Edge) const { return Test(Edge.PointIndex); }

TManager::TManager(const TSharedRef<PCGExData::FFacade>& InPointDataFacade)
FManager::FManager(const TSharedRef<PCGExData::FFacade>& InPointDataFacade)
: PointDataFacade(InPointDataFacade)
{
}

bool TManager::Init(const FPCGContext* InContext, const TArray<TObjectPtr<const UPCGExFilterFactoryBase>>& InFactories)
bool FManager::Init(const FPCGContext* InContext, const TArray<TObjectPtr<const UPCGExFilterFactoryBase>>& InFactories)
{
for (const UPCGExFilterFactoryBase* Factory : InFactories)
{
TSharedPtr<TFilter> NewFilter = Factory->CreateFilter();
TSharedPtr<FFilter> NewFilter = Factory->CreateFilter();
NewFilter->bCacheResults = bCacheResultsPerFilter;
if (!InitFilter(InContext, NewFilter)) { continue; }
ManagedFilters.Add(NewFilter);
Expand All @@ -58,42 +58,42 @@ namespace PCGExPointFilter
return PostInit(InContext);
}

bool TManager::Test(const int32 Index)
bool FManager::Test(const int32 Index)
{
for (const TSharedPtr<TFilter>& Handler : ManagedFilters) { if (!Handler->Test(Index)) { return false; } }
for (const TSharedPtr<FFilter>& Handler : ManagedFilters) { if (!Handler->Test(Index)) { return false; } }
return true;
}

bool TManager::Test(const PCGExCluster::FNode& Node)
bool FManager::Test(const PCGExCluster::FNode& Node)
{
for (const TSharedPtr<TFilter>& Handler : ManagedFilters) { if (!Handler->Test(Node)) { return false; } }
for (const TSharedPtr<FFilter>& Handler : ManagedFilters) { if (!Handler->Test(Node)) { return false; } }
return true;
}

bool TManager::Test(const PCGExGraph::FIndexedEdge& Edge)
bool FManager::Test(const PCGExGraph::FIndexedEdge& Edge)
{
for (const TSharedPtr<TFilter>& Handler : ManagedFilters) { if (!Handler->Test(Edge)) { return false; } }
for (const TSharedPtr<FFilter>& Handler : ManagedFilters) { if (!Handler->Test(Edge)) { return false; } }
return true;
}

bool TManager::InitFilter(const FPCGContext* InContext, const TSharedPtr<TFilter>& Filter)
bool FManager::InitFilter(const FPCGContext* InContext, const TSharedPtr<FFilter>& Filter)
{
return Filter->Init(InContext, PointDataFacade);
}

bool TManager::PostInit(const FPCGContext* InContext)
bool FManager::PostInit(const FPCGContext* InContext)
{
bValid = !ManagedFilters.IsEmpty();

if (!bValid) { return false; }

// Sort mappings so higher priorities come last, as they have to potential to override values.
ManagedFilters.Sort([&](const TSharedPtr<TFilter>& A, const TSharedPtr<TFilter>& B) { return A->Factory->Priority < B->Factory->Priority; });
ManagedFilters.Sort([&](const TSharedPtr<FFilter>& A, const TSharedPtr<FFilter>& B) { return A->Factory->Priority < B->Factory->Priority; });

// Update index & post-init
for (int i = 0; i < ManagedFilters.Num(); i++)
{
TSharedPtr<TFilter> Filter = ManagedFilters[i];
TSharedPtr<FFilter> Filter = ManagedFilters[i];
Filter->FilterIndex = i;
PostInitFilter(InContext, Filter);
}
Expand All @@ -103,12 +103,12 @@ namespace PCGExPointFilter
return true;
}

void TManager::PostInitFilter(const FPCGContext* InContext, const TSharedPtr<TFilter>& InFilter)
void FManager::PostInitFilter(const FPCGContext* InContext, const TSharedPtr<FFilter>& InFilter)
{
InFilter->PostInit();
}

void TManager::InitCache()
void FManager::InitCache()
{
const int32 NumResults = PointDataFacade->Source->GetNum();
Results.Init(false, NumResults);
Expand Down
2 changes: 1 addition & 1 deletion Source/PCGExtendedToolkit/Private/Data/PCGExPointIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ namespace PCGExData
UPCGMetadata* OutMetadata = Out->Metadata;
for (FPCGPoint& Pt : MutablePoints) { OutMetadata->InitializeOnSet(Pt.MetadataEntry); }
}

OutKeys = MakeShared<FPCGAttributeAccessorKeysPoints>(MutablePoints);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "Data/PCGExPointIOMerger.h"

#include "PCGExGlobalSettings.h"
#include "Data/PCGExDataFilter.h"


Expand Down
12 changes: 6 additions & 6 deletions Source/PCGExtendedToolkit/Private/Data/PCGExPointStates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "Data/PCGExPointStates.h"


TSharedPtr<PCGExPointFilter::TFilter> UPCGExPointStateFactoryBase::CreateFilter() const
TSharedPtr<PCGExPointFilter::FFilter> UPCGExPointStateFactoryBase::CreateFilter() const
{
return Super::CreateFilter();
}
Expand All @@ -22,9 +22,9 @@ namespace PCGExPointStates

bool FState::Init(const FPCGContext* InContext, const TSharedPtr<PCGExData::FFacade> InPointDataFacade)
{
if (!TFilter::Init(InContext, InPointDataFacade)) { return false; }
if (!FFilter::Init(InContext, InPointDataFacade)) { return false; }

Manager = MakeShared<PCGExPointFilter::TManager>(InPointDataFacade.ToSharedRef());
Manager = MakeShared<PCGExPointFilter::FManager>(InPointDataFacade.ToSharedRef());
Manager->bCacheResults = true;
return true;
}
Expand All @@ -47,17 +47,17 @@ namespace PCGExPointStates
}

FStateManager::FStateManager(const TSharedPtr<TArray<int64>>& InFlags, const TSharedRef<PCGExData::FFacade>& InPointDataFacade)
: TManager(InPointDataFacade)
: FManager(InPointDataFacade)
{
FlagsCache = InFlags;
}

void FStateManager::PostInitFilter(const FPCGContext* InContext, const TSharedPtr<PCGExPointFilter::TFilter>& InFilter)
void FStateManager::PostInitFilter(const FPCGContext* InContext, const TSharedPtr<PCGExPointFilter::FFilter>& InFilter)
{
const TSharedPtr<FState> State = StaticCastSharedPtr<FState>(InFilter);
State->InitInternalManager(InContext, State->StateFactory->FilterFactories);

TManager::PostInitFilter(InContext, InFilter);
FManager::PostInitFilter(InContext, InFilter);

States.Add(State);
}
Expand Down
Loading

0 comments on commit 41ca407

Please sign in to comment.