-
Notifications
You must be signed in to change notification settings - Fork 142
[UNR-2003] Create CookAndGenerateSchemaCommandlet #1342
[UNR-2003] Create CookAndGenerateSchemaCommandlet #1342
Conversation
… schema but appears to be missing Data-Only Blueprints
… of things missed. Also filtering UObjects to replicate based on IsSupportedForNetworking
…nent are explicit by default). Also use objectiterator with FObjectListener directly.
… explicit flag is present as a workaround for stale blueprints
Corresponding JIRA ticket: https://improbableio.atlassian.net/browse/UNR-2003 |
SpatialGDK/Source/SpatialGDKEditor/Private/SchemaGenerator/SpatialGDKEditorSchemaGenerator.cpp
Outdated
Show resolved
Hide resolved
for (TObjectIterator<UClass> ClassIt; ClassIt; ++ClassIt) | ||
if (SupportedClass->IsEditorOnly()) | ||
{ | ||
UE_LOG(LogSpatialGDKSchemaGenerator, Verbose, TEXT("[%s] Editor-only Class Not supported for schema gen"), *GetPathNameSafe(SupportedClass)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The capitalization of this message is triggering me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
SpatialGDK/Source/SpatialGDKEditor/Private/SchemaGenerator/SpatialGDKEditorSchemaGenerator.cpp
Show resolved
Hide resolved
return Classes; | ||
} | ||
|
||
TSet<UClass*> FilterClasses(TSet<UClass*> Classes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TSet<UClass*> FilterClasses(TSet<UClass*> Classes) | |
TSet<UClass*> FilterClasses(const TSet<UClass*>& Classes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
return true; | ||
} | ||
|
||
SPATIALGDKEDITOR_API bool SpatialGDKGenerateSchemaForClasses(TSet<UClass*> Classes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SPATIALGDKEDITOR_API bool SpatialGDKGenerateSchemaForClasses(TSet<UClass*> Classes) | |
bool SpatialGDKGenerateSchemaForClasses(TSet<UClass*> Classes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
{ | ||
if (SchemaGeneratedClasses.Contains(Class)) continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: New line please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
{ | ||
if (SchemaGeneratedClasses.Contains(Class)) continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should SchemaGeneratedClasses
get cleared before this loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generate Schema is being called in batches, so it's useful to cache generated classes between calls. This code really needs cleaning up to encapsulate this state properly, most likely as part of the testing work.
} | ||
|
||
UE_LOG(LogCookAndGenerateSchemaCommandlet, Display, TEXT("Generate Schema for C++ and in-memory Classes.")); | ||
if (!SpatialGDKGenerateSchema(false /* bSaveSchemaDatabase */, false /* bRunSchemaCompiler */)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not do this at the end with the blueprint classes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of doing this I've used a class iterator to add the classes to ReferencedClasses upfront.
…nerate-schema-commandlet
@@ -410,47 +410,90 @@ bool SaveSchemaDatabase() | |||
return true; | |||
} | |||
|
|||
TArray<UClass*> GetAllSupportedClasses() | |||
bool IsSupportedClass(UClass* SupportedClass) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool IsSupportedClass(UClass* SupportedClass) | |
bool IsSupportedClass(const UClass* SupportedClass) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -684,21 +727,65 @@ bool RunSchemaCompiler() | |||
} | |||
} | |||
|
|||
bool SpatialGDKGenerateSchema() | |||
bool SpatialGDKGenerateSchema(bool bSaveSchemaDatabase, bool bRunSchemaCompiler) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth considering removing parameter options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
return RunSchemaCompiler(); | ||
return true; | ||
} | ||
|
||
#undef LOCTEXT_NAMESPACE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move outside namespaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
{ | ||
if (UClass* NestedClass = Cast<UClass>(TypeNode->Type)) | ||
{ | ||
if (!Classes.Contains(NestedClass) && !SchemaGeneratedClasses.Contains(NestedClass) && IsSupportedClass(NestedClass)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!Classes.Contains(NestedClass) && !SchemaGeneratedClasses.Contains(NestedClass) && IsSupportedClass(NestedClass)) | |
if (!SchemaGeneratedClasses.Contains(NestedClass) && IsSupportedClass(NestedClass)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
…lType now that semantics have changed
@@ -994,7 +994,8 @@ void USpatialNetDriver::ServerReplicateActors_ProcessPrioritizedActors(UNetConne | |||
// or it's an editor placed actor and the client hasn't initialized the level it's in | |||
if (Channel == nullptr && GuidCache->SupportsObject(Actor->GetClass()) && GuidCache->SupportsObject(Actor->IsNetStartupActor() ? Actor : Actor->GetArchetype())) | |||
{ | |||
if (Actor->GetClass()->HasAnySpatialClassFlags(SPATIALCLASS_NotSpatialType)) | |||
if (Actor->GetClass()->HasAnySpatialClassFlags(SPATIALCLASS_NotSpatialType) || | |||
!Actor->GetClass()->HasAnySpatialClassFlags(SPATIALCLASS_ExplicitSpatialType)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these flags are mutually exclusive. So we should just be able to check for the existence of ExplicitSpatialType.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good Spot. Done
…it's mutually exclusive to SPATIALCLASS_NotSpatialType
…com:spatialos/UnrealGDK into feature/cook-and-generate-schema-commandlet
return false; | ||
} | ||
|
||
// User told us to ignore this class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
…ove redundant check for NotSpatialType
|
||
UE_LOG(LogCookAndGenerateSchemaCommandlet, Display, TEXT("Schema Generation Finished in %.2f seconds"), Duration.GetTotalSeconds()); | ||
|
||
if (!SaveSchemaDatabase()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a ticket to iterate on this process so we don't have to run the cook command multiple times?
...DK/Source/SpatialGDKEditorCommandlet/Private/Commandlets/CookAndGenerateSchemaCommandlet.cpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
…ts/CookAndGenerateSchemaCommandlet.cpp Co-Authored-By: improbable-valentyn <32096431+improbable-valentyn@users.noreply.github.com>
Description
This PR Includes:
NOTE Any users that have custom replicated subobjects will need to make sure they are marked as SpatialType (either with UClass specifier or in the blueprint class properties window).
Engine PR: https://github.com/improbableio/UnrealEngine/pull/250