Geometry collection : make sure Resttransform are in sync with RestCollection to avoid scrambled assets in previews

#rb trivial
#preflight none

[CL 24253436 by cedric caillaud in ue5-main branch]
This commit is contained in:
cedric caillaud
2023-02-16 04:18:27 -05:00
parent a523c67334
commit 84e0a41fe9

View File

@@ -2726,6 +2726,13 @@ void UGeometryCollectionComponent::ResetDynamicCollection()
SetRenderStateDirty();
}
// make sure we have the RestTransforms up to date, other wise, otherwise there may be case where they do not match the Restcollection ones
// can happen if the RestCollection asset has been changed without the component knowing about it
if (RestCollection && RestCollection->GetGeometryCollection())
{
RestTransforms = RestCollection->GetGeometryCollection()->Transform.GetConstArray();
}
if (RestTransforms.Num() > 0)
{
SetInitialTransforms(RestTransforms);
@@ -3276,12 +3283,7 @@ void UGeometryCollectionComponent::SetRestCollection(const UGeometryCollection*
{
RestCollection = RestCollectionIn;
const int32 NumTransforms = RestCollection->GetGeometryCollection()->NumElements(FGeometryCollection::TransformGroup);
RestTransforms.SetNum(NumTransforms);
for (int32 Idx = 0; Idx < NumTransforms; ++Idx)
{
RestTransforms[Idx] = RestCollection->GetGeometryCollection()->Transform[Idx];
}
RestTransforms = RestCollection->GetGeometryCollection()->Transform.GetConstArray();
CalculateGlobalMatrices();
CalculateLocalBounds();