2019-12-26 15:33:43 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
2014-03-14 14:13:41 -04:00
# pragma once
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
# include "CoreMinimal.h"
# include "ARFilter.h"
# include "CollectionManagerTypes.h"
# include "ICollectionManager.h"
# include "CollectionManagerModule.h"
2014-03-14 14:13:41 -04:00
struct FSourcesData
{
TArray < FName > PackagePaths ;
TArray < FCollectionNameType > Collections ;
2015-07-09 09:59:51 -04:00
FSourcesData ( )
: PackagePaths ( )
, Collections ( )
{
}
explicit FSourcesData ( FName InPackagePath )
: PackagePaths ( )
, Collections ( )
{
PackagePaths . Add ( InPackagePath ) ;
}
explicit FSourcesData ( FCollectionNameType InCollection )
: PackagePaths ( )
, Collections ( )
{
Collections . Add ( InCollection ) ;
}
FSourcesData ( TArray < FName > InPackagePaths , TArray < FCollectionNameType > InCollections )
: PackagePaths ( MoveTemp ( InPackagePaths ) )
, Collections ( MoveTemp ( InCollections ) )
{
}
FSourcesData ( const FSourcesData & Other )
: PackagePaths ( Other . PackagePaths )
, Collections ( Other . Collections )
{
}
FSourcesData ( FSourcesData & & Other )
: PackagePaths ( MoveTemp ( Other . PackagePaths ) )
, Collections ( MoveTemp ( Other . Collections ) )
{
}
FSourcesData & operator = ( const FSourcesData & Other )
{
if ( this ! = & Other )
{
PackagePaths = Other . PackagePaths ;
Collections = Other . Collections ;
}
return * this ;
}
FSourcesData & operator = ( FSourcesData & & Other )
{
if ( this ! = & Other )
{
PackagePaths = MoveTemp ( Other . PackagePaths ) ;
Collections = MoveTemp ( Other . Collections ) ;
}
return * this ;
}
FORCEINLINE bool IsEmpty ( ) const
2014-03-14 14:13:41 -04:00
{
return PackagePaths . Num ( ) = = 0 & & Collections . Num ( ) = = 0 ;
}
2015-07-09 09:59:51 -04:00
FORCEINLINE bool HasPackagePaths ( ) const
{
return PackagePaths . Num ( ) > 0 ;
}
FORCEINLINE bool HasCollections ( ) const
{
return Collections . Num ( ) > 0 ;
}
bool IsDynamicCollection ( ) const
{
if ( Collections . Num ( ) = = 1 & & FCollectionManagerModule : : IsModuleAvailable ( ) )
{
// Collection manager module should already be loaded since it may cause a hitch on the first search
FCollectionManagerModule & CollectionManagerModule = FCollectionManagerModule : : GetModule ( ) ;
ECollectionStorageMode : : Type StorageMode = ECollectionStorageMode : : Static ;
return ( CollectionManagerModule . Get ( ) . GetCollectionStorageMode ( Collections [ 0 ] . Name , Collections [ 0 ] . Type , StorageMode ) & & StorageMode = = ECollectionStorageMode : : Dynamic ) ;
}
return false ;
}
2014-03-14 14:13:41 -04:00
FARFilter MakeFilter ( bool bRecurse , bool bUsingFolders ) const
{
FARFilter Filter ;
// Package Paths
Filter . PackagePaths = PackagePaths ;
Filter . bRecursivePaths = bRecurse | | ! bUsingFolders ;
2015-07-09 09:59:51 -04:00
// If we have a dynamic source, then we need to make sure that the root path is searched for matching objects as the dynamic filter will sort through them
if ( IsDynamicCollection ( ) )
{
Filter . PackagePaths . AddUnique ( TEXT ( " / " ) ) ;
}
2014-03-14 14:13:41 -04:00
// Collections
TArray < FName > ObjectPathsFromCollections ;
2015-06-01 10:04:42 -04:00
if ( Collections . Num ( ) & & FCollectionManagerModule : : IsModuleAvailable ( ) )
2014-03-14 14:13:41 -04:00
{
// Collection manager module should already be loaded since it may cause a hitch on the first search
2015-06-01 10:04:42 -04:00
FCollectionManagerModule & CollectionManagerModule = FCollectionManagerModule : : GetModule ( ) ;
2014-03-14 14:13:41 -04:00
2015-06-19 07:33:02 -04:00
// Include objects from child collections if we're recursing
const ECollectionRecursionFlags : : Flags CollectionRecursionMode = ( Filter . bRecursivePaths ) ? ECollectionRecursionFlags : : SelfAndChildren : ECollectionRecursionFlags : : Self ;
2014-03-14 14:13:41 -04:00
for ( int32 CollectionIdx = 0 ; CollectionIdx < Collections . Num ( ) ; + + CollectionIdx )
{
// Find the collection
const FCollectionNameType & CollectionNameType = Collections [ CollectionIdx ] ;
2015-06-19 07:33:02 -04:00
CollectionManagerModule . Get ( ) . GetObjectsInCollection ( CollectionNameType . Name , CollectionNameType . Type , ObjectPathsFromCollections , CollectionRecursionMode ) ;
2014-03-14 14:13:41 -04:00
}
}
Filter . ObjectPaths = ObjectPathsFromCollections ;
return Filter ;
}
2015-07-09 09:59:51 -04:00
} ;