Geometry collection assets created from one or more static meshes will have Nanite automatically enabled now, as long as at least one of the input meshes had Nanite enabled originally.

#rb trivial
#fyi brian.karis, rune.stubbe
#jira UE-104791

[CL 15028299 by graham wihlidal in ue5-main branch]
This commit is contained in:
graham wihlidal
2021-01-08 20:00:52 -04:00
parent 6cdd53f1b0
commit ee8f378f7b
3 changed files with 16 additions and 3 deletions

View File

@@ -177,6 +177,12 @@ AGeometryCollectionActor* UFractureToolGenerateAsset::ConvertStaticMeshToGeometr
if (StaticMeshComponent != nullptr)
{
UStaticMesh* ComponentStaticMesh = StaticMeshComponent->GetStaticMesh();
if (ComponentStaticMesh != nullptr)
{
// If any of the static meshes have Nanite enabled, also enable on the new geometry collection asset for convenience.
FracturedGeometryCollection->EnableNanite |= ComponentStaticMesh->NaniteSettings.bEnabled;
}
FTransform ComponentTransform(StaticMeshComponent->GetComponentTransform());
ComponentTransform.SetTranslation((ComponentTransform.GetTranslation() - ActorTransform.GetTranslation()) + ActorOffset);
@@ -191,8 +197,15 @@ AGeometryCollectionActor* UFractureToolGenerateAsset::ConvertStaticMeshToGeometr
FracturedGeometryCollection->InitializeMaterials();
}
AddSingleRootNodeIfRequired(FracturedGeometryCollection);
if (FracturedGeometryCollection->EnableNanite)
{
FracturedGeometryCollection->InvalidateCollection();
FracturedGeometryCollection->EnsureDataIsCooked(false /* init resources */);
}
return NewActor;
}

View File

@@ -736,13 +736,13 @@ bool UGeometryCollection::Modify(bool bAlwaysMarkDirty /*= true*/)
return bSuperResult;
}
void UGeometryCollection::EnsureDataIsCooked()
void UGeometryCollection::EnsureDataIsCooked(bool bInitResources)
{
if (StateGuid != LastBuiltGuid)
{
CreateSimulationDataImp(/*bCopyFromDDC=*/ true);
if (FApp::CanEverRender())
if (FApp::CanEverRender() && bInitResources)
{
NaniteData->InitResources(this);
}

View File

@@ -152,7 +152,7 @@ public:
void Serialize(FArchive& Ar);
#if WITH_EDITOR
void EnsureDataIsCooked();
void EnsureDataIsCooked(bool bInitResources = true);
#endif
/** Accessors for internal geometry collection */