Refresh cached transforms before saving. (#1858)
If the prefab template saves default values for a cached transform, but *shouldn't* have default values, it will get patch application errors at runtime due to missing cached transform fields. Signed-off-by: mbalfour <mbalfour@amazon.com>
This commit is contained in:
@@ -330,6 +330,7 @@ namespace AZ
|
||||
prefabPlaceholderEntities.clear();
|
||||
for (size_t curEntityIdx = 0; curEntityIdx < sliceEntities.size(); curEntityIdx++)
|
||||
{
|
||||
UpdateCachedTransform(*(sliceEntities[curEntityIdx]));
|
||||
sourceInstance->AddEntity(*(sliceEntities[curEntityIdx]), entityAliases[curEntityIdx]);
|
||||
}
|
||||
|
||||
@@ -631,12 +632,14 @@ namespace AZ
|
||||
AZ_Assert(false, "Couldn't find nested instance %s", it->c_str());
|
||||
}
|
||||
}
|
||||
UpdateCachedTransform(*entity);
|
||||
addingInstance->AddEntity(*entity, mappingStruct.m_entityAlias);
|
||||
addedEntityList.emplace_back(entity, addingInstance);
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(false, "Failed to find entity alias.");
|
||||
UpdateCachedTransform(*entity);
|
||||
nestedInstance->AddEntity(*entity);
|
||||
addedEntityList.emplace_back(entity, nestedInstance.get());
|
||||
}
|
||||
@@ -781,6 +784,16 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
void SliceConverter::UpdateCachedTransform(const AZ::Entity& entity)
|
||||
{
|
||||
AzToolsFramework::Components::TransformComponent* transformComponent =
|
||||
entity.FindComponent<AzToolsFramework::Components::TransformComponent>();
|
||||
if (transformComponent)
|
||||
{
|
||||
transformComponent->UpdateCachedWorldTransform();
|
||||
}
|
||||
}
|
||||
|
||||
void SliceConverter::PrintPrefab(AzToolsFramework::Prefab::TemplateId templateId)
|
||||
{
|
||||
auto prefabSystemComponentInterface = AZ::Interface<AzToolsFramework::Prefab::PrefabSystemComponentInterface>::Get();
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace AZ
|
||||
bool ConvertSliceInstance(
|
||||
AZ::SliceComponent::SliceInstance& instance, AZ::Data::Asset<AZ::SliceAsset>& sliceAsset,
|
||||
AzToolsFramework::Prefab::TemplateReference nestedTemplate, AzToolsFramework::Prefab::Instance* topLevelInstance);
|
||||
void UpdateCachedTransform(const AZ::Entity& entity);
|
||||
void SetParentEntity(const AZ::Entity& entity, const AZ::EntityId& parentId, bool onlySetIfInvalid);
|
||||
void PrintPrefab(AzToolsFramework::Prefab::TemplateId templateId);
|
||||
bool SavePrefab(AZ::IO::PathView outputPath, AzToolsFramework::Prefab::TemplateId templateId);
|
||||
|
||||
Reference in New Issue
Block a user