Skip to content

Commit

Permalink
backport of r438217
Browse files Browse the repository at this point in the history
- (UE5) Fixed regression that caused Foliage Types to be instantiated as meshes if the "unreal_foliage" attribute wasn't set.
  • Loading branch information
dpernuit committed Feb 16, 2023
1 parent 6e514f0 commit 2bca9a4
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions Source/HoudiniEngine/Private/HoudiniInstanceTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2031,7 +2031,7 @@ FHoudiniInstanceTranslator::CreateOrUpdateInstanceComponent(
{
for(auto OldComponent : OldComponents)
{
RemoveAndDestroyComponent(OldComponent, nullptr);
RemoveAndDestroyComponent(OldComponent, nullptr);
}
OldComponents.Empty();
}
Expand All @@ -2044,14 +2044,19 @@ FHoudiniInstanceTranslator::CreateOrUpdateInstanceComponent(
UFoliageType* FoliageType = Cast<UFoliageType>(InstancedObject);
if (IsValid(FoliageType))
{
StaticMesh = Cast<UStaticMesh>(FoliageType->GetSource());
StaticMesh = Cast<UStaticMesh>(FoliageType->GetSource());
}

UHoudiniStaticMesh * HSM = nullptr;
if (!StaticMesh && !FoliageType)
HSM = Cast<UHoudiniStaticMesh>(InstancedObject);

if (StaticMesh)
if (IsValid(FoliageType))
{
// We must test for foliage type first, or FT will be considered as meshes
NewType = Foliage;
}
else if(IsValid(StaticMesh))
{
const bool bMustUseInstancerComponent = InstancedObjectTransforms.Num() > 1 || bForceInstancer;
if (InIsFoliageInstancer)
Expand All @@ -2068,7 +2073,7 @@ FHoudiniInstanceTranslator::CreateOrUpdateInstanceComponent(
else
NewType = StaticMeshComponent;
}
else if (HSM)
else if (IsValid(HSM))
{
if (InstancedObjectTransforms.Num() == 1)
NewType = HoudiniStaticMeshComponent;
Expand All @@ -2079,10 +2084,6 @@ FHoudiniInstanceTranslator::CreateOrUpdateInstanceComponent(
return false;
}
}
else if (FoliageType)
{
NewType = Foliage;
}
else
{
NewType = HoudiniInstancedActorComponent;
Expand All @@ -2093,7 +2094,7 @@ FHoudiniInstanceTranslator::CreateOrUpdateInstanceComponent(
NewComponents = OldComponents;
}

if (NewComponents.Num() == 0)
if (NewComponents.Num() == 0)
NewComponents.Add(nullptr);

// First valid index in the original instancer part
Expand Down

0 comments on commit 2bca9a4

Please sign in to comment.