@@ -94,65 +94,81 @@ FHoudiniLandscapeUtils::GetCookedLandscapeLayers(UHoudiniAssetComponent& HAC, AL
9494void
9595FHoudiniLandscapeUtils::SetNonCookedLayersVisibility (UHoudiniAssetComponent& HAC , ALandscape& Landscape, bool bVisible)
9696{
97+ FString LayerName;
9798 TSet<FString> CookedLayers = GetCookedLandscapeLayers (HAC , Landscape);
9899#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 6
99100 TArrayView<const FLandscapeLayer> Layers = Landscape.GetLayersConst ();
101+ for (int LayerIndex = 0 ; LayerIndex < Landscape.GetLayersConst ().Num (); LayerIndex++)
102+ {
103+ LayerName = Layers[LayerIndex].EditLayer ->GetName ().ToString ();
104+ if (!CookedLayers.Contains (LayerName))
105+ {
106+ // Non cooked Layer
107+ Layers[LayerIndex].EditLayer ->SetVisible (bVisible, true );
108+ }
109+ }
100110#elif ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
101111 TArrayView<const FLandscapeLayer> Layers = Landscape.GetLayers ();
102- #endif
103-
104- FString LayerName;
105- #if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 6
106- for (int LayerIndex = 0 ; LayerIndex < Landscape.GetLayersConst ().Num (); LayerIndex++)
107- #else
108112 for (int LayerIndex = 0 ; LayerIndex < Landscape.GetLayerCount (); LayerIndex++)
109- #endif
110113 {
111- #if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 6
112- LayerName = Layers[LayerIndex].EditLayer ->GetName ().ToString ();
113- #elif ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
114114 LayerName = Layers[LayerIndex].Name .ToString ();
115+ if (!CookedLayers.Contains (LayerName))
116+ {
117+ // Non cooked Layer
118+ Landscape.SetLayerVisibility (LayerIndex, bVisible);
119+ }
120+ }
115121#else
122+ for (int LayerIndex = 0 ; LayerIndex < Landscape.GetLayerCount (); LayerIndex++)
123+ {
116124 LayerName = Landscape.LandscapeLayers [LayerIndex].Name .ToString ();
117- #endif
118125 if (!CookedLayers.Contains (LayerName))
119126 {
120127 // Non cooked Layer
121128 Landscape.SetLayerVisibility (LayerIndex, bVisible);
122129 }
123130 }
131+ #endif
124132}
125133
126134void
127135FHoudiniLandscapeUtils::SetCookedLayersVisibility (UHoudiniAssetComponent& HAC , ALandscape& Landscape, bool bVisible)
128136{
137+ FString LayerName;
129138 TSet<FString> CookedLayers = GetCookedLandscapeLayers (HAC , Landscape);
130139#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 6
131140 TArrayView<const FLandscapeLayer> Layers = Landscape.GetLayersConst ();
141+ for (int LayerIndex = 0 ; LayerIndex < Landscape.GetLayersConst ().Num (); LayerIndex++)
142+ {
143+ LayerName = Layers[LayerIndex].EditLayer ->GetName ().ToString ();
144+ if (CookedLayers.Contains (LayerName))
145+ {
146+ // Cooked Layer
147+ Layers[LayerIndex].EditLayer ->SetVisible (bVisible, true );
148+ }
149+ }
132150#elif ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
133151 TArrayView<const FLandscapeLayer> Layers = Landscape.GetLayers ();
134- #endif
135-
136- FString LayerName;
137- #if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 6
138- for (int LayerIndex = 0 ; LayerIndex < Landscape.GetLayersConst ().Num (); LayerIndex++)
139- #else
140152 for (int LayerIndex = 0 ; LayerIndex < Landscape.GetLayerCount (); LayerIndex++)
141- #endif
142153 {
143- #if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 6
144- LayerName = Layers[LayerIndex].EditLayer .GetName ();
145- #elif ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
146154 LayerName = Layers[LayerIndex].Name .ToString ();
155+ if (CookedLayers.Contains (LayerName))
156+ {
157+ // Cooked Layer
158+ Landscape.SetLayerVisibility (LayerIndex, bVisible);
159+ }
160+ }
147161#else
162+ for (int LayerIndex = 0 ; LayerIndex < Landscape.GetLayerCount (); LayerIndex++)
163+ {
148164 LayerName = Landscape.LandscapeLayers [LayerIndex].Name .ToString ();
149- #endif
150165 if (CookedLayers.Contains (LayerName))
151166 {
152167 // Cooked Layer
153168 Landscape.SetLayerVisibility (LayerIndex, bVisible);
154169 }
155170 }
171+ #endif
156172}
157173
158174void FHoudiniLandscapeUtils::RealignHeightFieldData (TArray<float >& Data, float ZeroPoint, float Scale)
@@ -655,7 +671,12 @@ FHoudiniLandscapeUtils::ResolveLandscapes(
655671
656672 // Rename the default height layer if needed.
657673 const FString DefaultLayerName = TEXT (" Layer" );
658- #if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
674+ #if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 6
675+ if (LandscapeActor->HasLayersContent () && HeightPart->UnrealLayerName != DefaultLayerName)
676+ {
677+ LandscapeActor->GetEditLayer (0 )->SetName (FName (HeightPart->UnrealLayerName ), true );
678+ }
679+ #elif ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION == 5
659680 if (LandscapeActor->HasLayersContent () && HeightPart->UnrealLayerName != DefaultLayerName)
660681 {
661682 LandscapeActor->SetLayerName (0 , FName (HeightPart->UnrealLayerName ));
@@ -1549,7 +1570,9 @@ void FHoudiniLandscapeUtils::ApplyLocks(UHoudiniLandscapeTargetLayerOutput* Outp
15491570 if (EditLayerIndex == INDEX_NONE )
15501571 return ;
15511572
1552- #if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
1573+ #if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 6
1574+ Output->Landscape ->GetEditLayer (EditLayerIndex)->SetLocked (true , true );
1575+ #elif ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION == 5
15531576 Output->Landscape ->SetLayerLocked (EditLayerIndex, true );
15541577#else
15551578 FLandscapeLayer* UnrealEditLayer = Output->Landscape ->GetLayer (EditLayerIndex);
0 commit comments