2016-12-08 08:52:44 -05:00
|
|
|
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
|
2014-09-17 04:34:40 -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"
|
2016-11-23 19:55:41 -05:00
|
|
|
#if WITH_ENGINE
|
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 "Kismet2/KismetReinstanceUtilities.h"
|
2016-11-23 19:55:41 -05:00
|
|
|
#endif
|
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
|
|
|
|
|
|
|
|
class UBlueprint;
|
|
|
|
|
|
2014-09-17 04:34:40 -04:00
|
|
|
#if WITH_ENGINE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Helper class used for re-instancing native and blueprint classes after hot-reload
|
|
|
|
|
*/
|
|
|
|
|
class FHotReloadClassReinstancer : public FBlueprintCompileReinstancer
|
|
|
|
|
{
|
2014-12-11 06:03:58 -05:00
|
|
|
/** Holds a property and its offset in the serialized properties data array */
|
|
|
|
|
struct FCDOProperty
|
|
|
|
|
{
|
|
|
|
|
FCDOProperty()
|
|
|
|
|
: Property(nullptr)
|
2015-01-23 08:34:49 -05:00
|
|
|
, SubobjectName(NAME_None)
|
2014-12-11 06:03:58 -05:00
|
|
|
, SerializedValueOffset(0)
|
|
|
|
|
, SerializedValueSize(0)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
UProperty* Property;
|
2015-01-23 08:34:49 -05:00
|
|
|
FName SubobjectName;
|
2014-12-11 06:03:58 -05:00
|
|
|
int64 SerializedValueOffset;
|
|
|
|
|
int64 SerializedValueSize;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** Contains all serialized CDO property data and the map of all serialized properties */
|
|
|
|
|
struct FCDOPropertyData
|
|
|
|
|
{
|
|
|
|
|
TArray<uint8> Bytes;
|
|
|
|
|
TMap<FName, FCDOProperty> Properties;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** Hot-reloaded version of the old class */
|
|
|
|
|
UClass* NewClass;
|
|
|
|
|
|
|
|
|
|
/** Serialized properties of the original CDO (before hot-reload) */
|
|
|
|
|
FCDOPropertyData OriginalCDOProperties;
|
|
|
|
|
|
|
|
|
|
/** Serialized properties of the new CDO (after hot-reload) */
|
|
|
|
|
FCDOPropertyData ReconstructedCDOProperties;
|
|
|
|
|
|
2014-09-17 04:34:40 -04:00
|
|
|
/** True if the provided native class needs re-instancing */
|
2014-12-11 06:03:58 -05:00
|
|
|
bool bNeedsReinstancing;
|
2014-09-17 04:34:40 -04:00
|
|
|
|
2015-03-09 15:41:53 -04:00
|
|
|
/** Necessary for delta serialization */
|
|
|
|
|
UObject* CopyOfPreviousCDO;
|
|
|
|
|
|
2014-09-17 04:34:40 -04:00
|
|
|
/**
|
|
|
|
|
* Sets the re-instancer up for new class re-instancing
|
|
|
|
|
*
|
|
|
|
|
* @param InNewClass Class that has changed after hot-reload
|
|
|
|
|
* @param InOldClass Class before it was hot-reloaded
|
|
|
|
|
*/
|
|
|
|
|
void SetupNewClassReinstancing(UClass* InNewClass, UClass* InOldClass);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the re-instancer up for old class re-instancing. Always re-creates the CDO.
|
|
|
|
|
*
|
|
|
|
|
* @param InOldClass Class that has NOT changed after hot-reload
|
|
|
|
|
*/
|
|
|
|
|
void RecreateCDOAndSetupOldClassReinstancing(UClass* InOldClass);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a mem-comparable array of data containing CDO property values.
|
|
|
|
|
*
|
|
|
|
|
* @param InObject CDO
|
|
|
|
|
* @param OutData Data containing all of the CDO property values
|
|
|
|
|
*/
|
2014-12-11 06:03:58 -05:00
|
|
|
void SerializeCDOProperties(UObject* InObject, FCDOPropertyData& OutData);
|
2014-09-17 04:34:40 -04:00
|
|
|
|
|
|
|
|
/**
|
2015-05-15 14:07:44 -04:00
|
|
|
* Re-creates class default object.
|
|
|
|
|
*
|
|
|
|
|
* @param InClass Class that has NOT changed after hot-reload.
|
|
|
|
|
* @param InOuter Outer for the new CDO.
|
|
|
|
|
* @param InName Name of the new CDO.
|
|
|
|
|
* @param InFlags Flags of the new CDO.
|
|
|
|
|
*/
|
|
|
|
|
void ReconstructClassDefaultObject(UClass* InClass, UObject* InOuter, FName InName, EObjectFlags InFlags);
|
2014-09-17 04:34:40 -04:00
|
|
|
|
2014-12-11 06:03:58 -05:00
|
|
|
/** Updates property values on instances of the hot-reloaded class */
|
|
|
|
|
void UpdateDefaultProperties();
|
|
|
|
|
|
|
|
|
|
/** Returns true if the properties of the CDO have changed during hot-reload */
|
|
|
|
|
FORCEINLINE bool DefaultPropertiesHaveChanged() const
|
|
|
|
|
{
|
|
|
|
|
return OriginalCDOProperties.Bytes.Num() != ReconstructedCDOProperties.Bytes.Num() ||
|
|
|
|
|
FMemory::Memcmp(OriginalCDOProperties.Bytes.GetData(), ReconstructedCDOProperties.Bytes.GetData(), OriginalCDOProperties.Bytes.Num());
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-17 04:34:40 -04:00
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
/** Sets the re-instancer up to re-instance native classes */
|
2015-09-30 05:26:51 -04:00
|
|
|
FHotReloadClassReinstancer(UClass* InNewClass, UClass* InOldClass, const TMap<UClass*, UClass*>& OldToNewClassesMap, TMap<UObject*, UObject*>& OutReconstructedCDOsMap, TSet<UBlueprint*>& InBPSetToRecompile, TSet<UBlueprint*>& InBPSetToRecompileBytecodeOnly);
|
2014-09-17 04:34:40 -04:00
|
|
|
|
|
|
|
|
/** Destructor */
|
|
|
|
|
virtual ~FHotReloadClassReinstancer();
|
|
|
|
|
|
|
|
|
|
/** If true, the class needs re-instancing */
|
|
|
|
|
FORCEINLINE bool ClassNeedsReinstancing() const
|
|
|
|
|
{
|
|
|
|
|
return bNeedsReinstancing;
|
|
|
|
|
}
|
2014-12-11 06:03:58 -05:00
|
|
|
|
|
|
|
|
/** Reinstances all objects of the hot-reloaded class and update their properties to match the new CDO */
|
|
|
|
|
void ReinstanceObjectsAndUpdateDefaults();
|
2015-02-24 11:28:59 -05:00
|
|
|
|
|
|
|
|
/** Creates the reinstancer as a sharable object */
|
2015-09-30 05:26:51 -04:00
|
|
|
static TSharedPtr<FHotReloadClassReinstancer> Create(UClass* InNewClass, UClass* InOldClass, const TMap<UClass*, UClass*>& OldToNewClassesMap, TMap<UObject*, UObject*>& OutReconstructedCDOsMap, TSet<UBlueprint*>& InBPSetToRecompile, TSet<UBlueprint*>& InBPSetToRecompileBytecodeOnly)
|
2015-02-24 11:28:59 -05:00
|
|
|
{
|
2015-09-30 05:26:51 -04:00
|
|
|
return MakeShareable(new FHotReloadClassReinstancer(InNewClass, InOldClass, OldToNewClassesMap, OutReconstructedCDOsMap, InBPSetToRecompile, InBPSetToRecompileBytecodeOnly));
|
2015-02-24 11:28:59 -05:00
|
|
|
}
|
2015-03-09 15:41:53 -04:00
|
|
|
|
|
|
|
|
// FSerializableObject interface
|
|
|
|
|
virtual void AddReferencedObjects(FReferenceCollector& Collector) override;
|
|
|
|
|
// End of FSerializableObject interface
|
2015-03-18 14:55:09 -04:00
|
|
|
|
|
|
|
|
virtual bool IsClassObjectReplaced() const override { return true; }
|
2015-04-16 11:43:50 -04:00
|
|
|
|
2015-07-21 10:33:15 -04:00
|
|
|
virtual void EnlistDependentBlueprintToRecompile(UBlueprint* BP, bool bBytecodeOnly) override;
|
|
|
|
|
virtual void BlueprintWasRecompiled(UBlueprint* BP, bool bBytecodeOnly) override;
|
|
|
|
|
|
2015-04-16 11:43:50 -04:00
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
// FBlueprintCompileReinstancer interface
|
|
|
|
|
virtual bool ShouldPreserveRootComponentOfReinstancedActor() const override { return false; }
|
|
|
|
|
// End of FBlueprintCompileReinstancer interface
|
2015-07-13 07:30:06 -04:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
/** Reference to reconstructed CDOs map in this hot-reload session. */
|
|
|
|
|
TMap<UObject*, UObject*>& ReconstructedCDOsMap;
|
2015-07-21 10:33:15 -04:00
|
|
|
TSet<UBlueprint*>& BPSetToRecompile;
|
|
|
|
|
TSet<UBlueprint*>& BPSetToRecompileBytecodeOnly;
|
2015-09-30 05:26:51 -04:00
|
|
|
const TMap<UClass*, UClass*>& OldToNewClassesMap;
|
2014-09-17 04:34:40 -04:00
|
|
|
};
|
|
|
|
|
|
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
|
|
|
#endif // WITH_ENGINE
|