Skip to content

Commit

Permalink
- Fixes errors/warnings for UE5.5 preview1.
Browse files Browse the repository at this point in the history
  The plugin source code should now build properly with UE5.5.
  • Loading branch information
dpernuit committed Nov 5, 2024
1 parent 81fecaa commit 89ab012
Show file tree
Hide file tree
Showing 17 changed files with 258 additions and 43 deletions.
6 changes: 5 additions & 1 deletion Source/HoudiniEngine/Private/HCsgUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,11 @@ void UHCsgUtils::FilterWorldThroughBrush
// Get rid of all the fragments we added.
Model->Nodes[GLastCoplanar].iPlane = INDEX_NONE;
const bool bAllowShrinking = false;
Model->Nodes.RemoveAt( GNumNodes, Model->Nodes.Num()-GNumNodes, bAllowShrinking );
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
Model->Nodes.RemoveAt( GNumNodes, Model->Nodes.Num()-GNumNodes, bAllowShrinking ? EAllowShrinking::Yes : EAllowShrinking::No );
#else
Model->Nodes.RemoveAt(GNumNodes, Model->Nodes.Num() - GNumNodes, bAllowShrinking);
#endif
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Source/HoudiniEngine/Private/HoudiniEngineUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ void FHoudiniEngineUtils::LogPackageInfo(const UPackage* InPackage)

HOUDINI_LOG_MESSAGE(TEXT(" = Filename: %s"), *(InPackage->GetLoadedPath().GetPackageName()));
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
HOUDINI_LOG_MESSAGE(TEXT(" = Package Id: %d"), InPackage->GetPackageId().LexToString());
HOUDINI_LOG_MESSAGE(TEXT(" = Package Id: %s"), *(LexToString(InPackage->GetPackageId())));
#else
HOUDINI_LOG_MESSAGE(TEXT(" = Package Id: %d"), InPackage->GetPackageId().ValueForDebugging());
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
#include "Materials/Material.h"
#include "WorldPartition/WorldPartition.h"

#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
#include "LandscapeEditLayer.h"
#endif


FVector
FHoudiniLandscapeSplineTranslator::ConvertPositionToVector(const float* InPosition)
Expand Down Expand Up @@ -171,8 +175,12 @@ FHoudiniLandscapeSplineTranslator::UpdateNonReservedEditLayers(
TSet<FName>& ClearedLayersForLandscape = InClearedLayers.FindOrAdd(InSplineInfo.Landscape);

// If the landscape has a reserved splines layer, then we don't have track the segments to apply. Just record the
// landscape with its reserved layer.
// landscape with its reserved layer.
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
const FLandscapeLayer* ReservedSplinesLayer = InSplineInfo.Landscape->FindLayerOfType(ULandscapeEditLayerSplines::StaticClass());
#else
FLandscapeLayer* const ReservedSplinesLayer = InSplineInfo.Landscape->GetLandscapeSplinesReservedLayer();
#endif
if (ReservedSplinesLayer)
{
FHoudiniLandscapeSplineApplyLayerData& LayerData = InSegmentsToApplyToLayers.FindOrAdd({ InSplineInfo.Landscape, ReservedSplinesLayer->Name});
Expand All @@ -197,7 +205,11 @@ FHoudiniLandscapeSplineTranslator::UpdateNonReservedEditLayers(
const FName CookedEditLayer = *LayerOutput->CookedEditLayer;

// Create layer if it does not exist
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
const FLandscapeLayer* const UnrealEditLayer = FHoudiniLandscapeUtils::GetOrCreateEditLayer(InSplineInfo.Landscape, CookedEditLayer);
#else
FLandscapeLayer* const UnrealEditLayer = FHoudiniLandscapeUtils::GetOrCreateEditLayer(InSplineInfo.Landscape, CookedEditLayer);
#endif
if (!UnrealEditLayer)
{
HOUDINI_LOG_ERROR(TEXT("Could not find edit layer %s and failed to create it: %s"), *CookedEditLayer.ToString(), *(InSplineInfo.Landscape->GetActorLabel()));
Expand Down
17 changes: 15 additions & 2 deletions Source/HoudiniEngine/Private/HoudiniLandscapeTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,21 +589,28 @@ FHoudiniLandscapeTranslator::TranslateHeightFieldPart(
// Create the Edit Layer if it doesn't exist
// ------------------------------------------------------------------------------------------------------------------

#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
const FLandscapeLayer* UnrealEditLayer = nullptr;
#else
FLandscapeLayer* UnrealEditLayer = nullptr;

#endif
bool bWasLocked = false;
if (OutputLandscape->bCanHaveLayersContent)
{
UnrealEditLayer = FHoudiniLandscapeUtils::GetOrCreateEditLayer(OutputLandscape, FName(CookedLayerName));
if (!UnrealEditLayer)
return nullptr;

bWasLocked = UnrealEditLayer->bLocked;
if (UnrealEditLayer->bLocked)
{
if (Part.bWriteLockedLayers)
{
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
OutputLandscape->SetLayerLocked(OutputLandscape->GetLayerIndex(UnrealEditLayer->Name), false);
#else
UnrealEditLayer->bLocked = false;
#endif
}
else
{
Expand Down Expand Up @@ -799,7 +806,13 @@ FHoudiniLandscapeTranslator::TranslateHeightFieldPart(
}

if (bWasLocked && UnrealEditLayer)
{
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
OutputLandscape->SetLayerLocked(OutputLandscape->GetLayerIndex(UnrealEditLayer->Name), true);
#else
UnrealEditLayer->bLocked = true;
#endif
}

// ------------------------------------------------------------------------------------------------------------------
// We successfully did what we came to, return an Object
Expand Down
99 changes: 85 additions & 14 deletions Source/HoudiniEngine/Private/HoudiniLandscapeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
#include "LandscapeSplineControlPoint.h"
#include "LandscapeSplineSegment.h"

#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
#include "LandscapeEditLayer.h"
#endif

TSet<UHoudiniLandscapeTargetLayerOutput *>
FHoudiniLandscapeUtils::GetEditLayers(UHoudiniOutput& Output)
{
Expand Down Expand Up @@ -174,15 +178,24 @@ static float Convert(int NewValue, int NewMax, int OldMax)
return (Scale * OldMax);
}

float FHoudiniLandscapeUtils::GetLandscapeHeightRangeInCM(ALandscape& Landscape)
float
FHoudiniLandscapeUtils::GetLandscapeHeightRangeInCM(ALandscape& Landscape)
{
float Scale = Landscape.GetTransform().GetScale3D().Z;

return Scale * 256.0f;

}

TArray<uint16> FHoudiniLandscapeUtils::GetHeightData(ALandscape* Landscape, const FHoudiniExtents& Extents, FLandscapeLayer* EditLayer)
TArray<uint16>
FHoudiniLandscapeUtils::GetHeightData(
ALandscape* Landscape,
const FHoudiniExtents& Extents,
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
const FLandscapeLayer* EditLayer)
#else
FLandscapeLayer* EditLayer)
#endif
{
int DiffX = 1 + Extents.Max.X - Extents.Min.X;
int DiffY = 1 + Extents.Max.Y - Extents.Min.Y;
Expand All @@ -200,44 +213,75 @@ TArray<uint16> FHoudiniLandscapeUtils::GetHeightData(ALandscape* Landscape, cons
return Values;
}

FLandscapeLayer* FHoudiniLandscapeUtils::GetOrCreateEditLayer(ALandscape* Landscape, const FName& LayerName)
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
const FLandscapeLayer*
#else
FLandscapeLayer*
#endif
FHoudiniLandscapeUtils::GetOrCreateEditLayer(ALandscape* Landscape, const FName& LayerName)
{
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
const FLandscapeLayer* UnrealEditLayer = GetEditLayer(Landscape, LayerName);
#else
FLandscapeLayer* UnrealEditLayer = GetEditLayer(Landscape, LayerName);
#endif
if (UnrealEditLayer == nullptr)
{
int EditLayerIndex = Landscape->CreateLayer(LayerName);

if (EditLayerIndex == INDEX_NONE)
{
HOUDINI_LOG_ERROR(TEXT("Could not create edit layer %s"), *LayerName.ToString());
return nullptr;
}

#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
UnrealEditLayer = Landscape->GetLayerConst(EditLayerIndex);
#else
UnrealEditLayer = Landscape->GetLayer(EditLayerIndex);
#endif
}

return UnrealEditLayer;
}

FLandscapeLayer*
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
const FLandscapeLayer*
#else
FLandscapeLayer*
#endif
FHoudiniLandscapeUtils::GetEditLayer(ALandscape* Landscape, const FName& LayerName)
{
if (!Landscape->bCanHaveLayersContent)
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
return Landscape->GetLayerConst(0);
#else
return Landscape->GetLayer(0);
#endif

int32 EditLayerIndex = Landscape->GetLayerIndex(LayerName);
if (EditLayerIndex == INDEX_NONE)
return nullptr;

FLandscapeLayer* UnrealEditLayer = Landscape->GetLayer(EditLayerIndex);
return UnrealEditLayer;

#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
return Landscape->GetLayerConst(EditLayerIndex);
#else
return Landscape->GetLayer(EditLayerIndex);
#endif
}

FLandscapeLayer*
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
const FLandscapeLayer*
#else
FLandscapeLayer*
#endif
FHoudiniLandscapeUtils::MoveEditLayerAfter(ALandscape* Landscape, const FName& LayerName, const FName& AfterLayerName)
{
if (!Landscape->bCanHaveLayersContent)
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
return Landscape->GetLayerConst(0);
#else
return Landscape->GetLayer(0);
#endif

int32 EditLayerIndex = Landscape->GetLayerIndex(LayerName);
int32 NewLayerIndex = Landscape->GetLayerIndex(AfterLayerName);
Expand All @@ -252,12 +296,15 @@ FHoudiniLandscapeUtils::MoveEditLayerAfter(ALandscape* Landscape, const FName& L

// Ensure we have the correct layer/index
EditLayerIndex = Landscape->GetLayerIndex(LayerName);
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
return Landscape->GetLayerConst(EditLayerIndex);
#else
return Landscape->GetLayer(EditLayerIndex);


#endif
}

TArray<uint8_t> FHoudiniLandscapeUtils::GetLayerData(ALandscape* Landscape, const FHoudiniExtents& Extents, const FName& EditLayerName, const FName& TargetLayerName)
TArray<uint8_t>
FHoudiniLandscapeUtils::GetLayerData(ALandscape* Landscape, const FHoudiniExtents& Extents, const FName& EditLayerName, const FName& TargetLayerName)
{
int DiffX = 1 + Extents.Max.X - Extents.Min.X;
int DiffY = 1 + Extents.Max.Y - Extents.Min.Y;
Expand All @@ -266,7 +313,11 @@ TArray<uint8_t> FHoudiniLandscapeUtils::GetLayerData(ALandscape* Landscape, cons
TArray<uint8_t> Values;
Values.SetNum(NumPoints);

#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
const FLandscapeLayer* EditLayer = FHoudiniLandscapeUtils::GetEditLayer(Landscape, EditLayerName);
#else
FLandscapeLayer* EditLayer = FHoudiniLandscapeUtils::GetEditLayer(Landscape, EditLayerName);
#endif
ULandscapeLayerInfoObject* TargetLayerInfo = Landscape->GetLandscapeInfo()->GetLayerInfoByName(TargetLayerName);

FScopedSetLandscapeEditingLayer Scope(Landscape, EditLayer->Guid, [&] { /*Landscape->RequestLayersContentUpdate(ELandscapeLayerUpdateMode::Update_All); */});
Expand Down Expand Up @@ -647,7 +698,11 @@ void FHoudiniLandscapeUtils::CreateDefaultHeightField(ALandscape* LandscapeActor
HeightMapDataPerLayers,
NULL,
MaterialLayerDataPerLayer,
ELandscapeImportAlphamapType::Layered);
ELandscapeImportAlphamapType::Layered
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
,MakeArrayView<FLandscapeLayer>({})
#endif
);
}

ALandscapeProxy* FHoudiniLandscapeUtils::FindTargetLandscapeProxy(const FString& ActorName, UWorld* World,
Expand Down Expand Up @@ -1295,8 +1350,15 @@ void FHoudiniLandscapeUtils::ApplyMaterialsFromParts(
bool
FHoudiniLandscapeUtils::ApplyLandscapeSplinesToReservedLayer(ALandscape* const InLandscape)
{
if (!IsValid(InLandscape) || !InLandscape->GetLandscapeSplinesReservedLayer())
if (!IsValid(InLandscape)
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
|| !InLandscape->FindLayerOfType(ULandscapeEditLayerSplines::StaticClass()))
#else
|| !InLandscape->GetLandscapeSplinesReservedLayer())
#endif
{
return false;
}

InLandscape->RequestSplineLayerUpdate();

Expand Down Expand Up @@ -1326,7 +1388,12 @@ FHoudiniLandscapeUtils::ApplySegmentsToLandscapeEditLayers(
continue;
}

#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
FLandscapeLayer const* const Layer = Landscape->GetLayerConst(LayerName);
#else
FLandscapeLayer const* const Layer = Landscape->GetLayer(LayerName);
#endif

if (!Layer)
{
HOUDINI_LOG_WARNING(
Expand Down Expand Up @@ -1391,8 +1458,12 @@ void FHoudiniLandscapeUtils::ApplyLocks(UHoudiniLandscapeTargetLayerOutput* Outp
if (EditLayerIndex == INDEX_NONE)
return;

#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
Output->Landscape->SetLayerLocked(EditLayerIndex, true);
#else
FLandscapeLayer* UnrealEditLayer = Output->Landscape->GetLayer(EditLayerIndex);
UnrealEditLayer->bLocked = true;
#endif
}

bool
Expand Down
19 changes: 15 additions & 4 deletions Source/HoudiniEngine/Private/HoudiniLandscapeUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,24 @@ struct HOUDINIENGINE_API FHoudiniLandscapeUtils

static float GetLandscapeHeightRangeInCM(ALandscape& Landscape);

static TArray<uint16> GetHeightData(ALandscape* Landscape, const FHoudiniExtents& Extents, FLandscapeLayer* EditLayer);

static TArray<uint16> GetHeightData(
ALandscape* Landscape,
const FHoudiniExtents& Extents,
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
const FLandscapeLayer* EditLayer);
#else
FLandscapeLayer* EditLayer);
#endif

#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
static const FLandscapeLayer* GetEditLayer(ALandscape* Landscape, const FName& LayerName);
static const FLandscapeLayer* GetOrCreateEditLayer(ALandscape* Landscape, const FName& LayerName);
static const FLandscapeLayer* MoveEditLayerAfter(ALandscape* Landscape, const FName& LayerName, const FName& AfterLayerName);
#else
static FLandscapeLayer* GetEditLayer(ALandscape* Landscape, const FName& LayerName);

static FLandscapeLayer* GetOrCreateEditLayer(ALandscape* Landscape, const FName& LayerName);

static FLandscapeLayer* MoveEditLayerAfter(ALandscape* Landscape, const FName& LayerName, const FName& AfterLayerName);
#endif

static TArray<uint8_t> GetLayerData(ALandscape* Landscape, const FHoudiniExtents& Extents, const FName& EditLayerName, const FName& TargetLayerName);

Expand Down
16 changes: 16 additions & 0 deletions Source/HoudiniEngine/Private/UnrealLandscapeSplineTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ ConvertAndSetRotation(const FRotator& InUnrealRotation, const int32 InArrayStart

bool
FHoudiniUnrealLandscapeSplineControlPointAttributes::AddControlPointData(
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
TObjectPtr<ULandscapeSplineControlPoint>& InControlPoint,
#else
const ULandscapeSplineControlPoint * InControlPoint,
#endif
int32 InControlPointIndex,
TMap<TSoftObjectPtr<ULandscapeSplineControlPoint>, int32>& InControlPointIdMap,
int32& InNextControlPointId)
Expand Down Expand Up @@ -1149,7 +1153,11 @@ bool FUnrealLandscapeSplineTranslator::ExtractSplineData(
static constexpr int32 ConnectionIdx = 0;
OutSplinesData.PointConnectionSocketNames.Emplace(SegmentData.Segment->Connections[ConnectionIdx].SocketName.ToString());
OutSplinesData.PointConnectionTangentLengths.Add(SegmentData.Segment->Connections[ConnectionIdx].TangentLen);
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
TObjectPtr<ULandscapeSplineControlPoint> CPoint = SegmentData.Segment->Connections[ConnectionIdx].ControlPoint;
#else
ULandscapeSplineControlPoint const* const CPoint = SegmentData.Segment->Connections[ConnectionIdx].ControlPoint;
#endif
if (!IsValid(CPoint))
{
OutSplinesData.ControlPointAttributes.AddEmpty();
Expand All @@ -1166,7 +1174,11 @@ bool FUnrealLandscapeSplineTranslator::ExtractSplineData(
static constexpr int32 ConnectionIdx = 1;
OutSplinesData.PointConnectionSocketNames.Emplace(SegmentData.Segment->Connections[ConnectionIdx].SocketName.ToString());
OutSplinesData.PointConnectionTangentLengths.Add(SegmentData.Segment->Connections[ConnectionIdx].TangentLen);
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
TObjectPtr<ULandscapeSplineControlPoint> CPoint = SegmentData.Segment->Connections[ConnectionIdx].ControlPoint;
#else
ULandscapeSplineControlPoint const* const CPoint = SegmentData.Segment->Connections[ConnectionIdx].ControlPoint;
#endif
if (!IsValid(CPoint))
{
OutSplinesData.ControlPointAttributes.AddEmpty();
Expand Down Expand Up @@ -1296,7 +1308,11 @@ FUnrealLandscapeSplineTranslator::ExtractSplineControlPointsData(

for (int32 ControlPointIdx = 0; ControlPointIdx < NumControlPoints; ++ControlPointIdx)
{
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 5
TObjectPtr<ULandscapeSplineControlPoint> CPoint = ControlPoints[ControlPointIdx];
#else
ULandscapeSplineControlPoint const* const CPoint = ControlPoints[ControlPointIdx];
#endif
if (!IsValid(CPoint))
continue;

Expand Down
Loading

0 comments on commit 89ab012

Please sign in to comment.