Files
UnrealEngineUWP/Engine/Source/Runtime/Landscape/Private/LandscapeSplineActor.cpp
Patrick Enfedaque f5545aa360 New "AffectsLandscape" ActorDesc property: Implemented for Water, PatchComponent and LandscapeSplineActor
- Deprecated LandscapeSplineActorDesc as it is no longer needed with this property

#jira none
#rb jeanfrancois.dube, richard.malo
#preflight 62a8c041a43e20b293533548

[CL 20654038 by Patrick Enfedaque in ue5-main branch]
2022-06-14 14:28:12 -04:00

113 lines
2.7 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "LandscapeSplineActor.h"
#include "LandscapeInfo.h"
#include "LandscapeInfoMap.h"
#include "Landscape.h"
#include "LandscapeSplinesComponent.h"
#if WITH_EDITOR
#include "WorldPartition/WorldPartitionActorDesc.h"
#endif
ALandscapeSplineActor::ALandscapeSplineActor(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
ULandscapeSplinesComponent* SplineComponent = CreateDefaultSubobject<ULandscapeSplinesComponent>(TEXT("RootComponent0"));
RootComponent = SplineComponent;
RootComponent->Mobility = EComponentMobility::Static;
}
ULandscapeSplinesComponent* ALandscapeSplineActor::GetSplinesComponent() const
{
return Cast<ULandscapeSplinesComponent>(RootComponent);
}
FTransform ALandscapeSplineActor::LandscapeActorToWorld() const
{
return GetLandscapeInfo()->LandscapeActor->LandscapeActorToWorld();
}
ULandscapeInfo* ALandscapeSplineActor::GetLandscapeInfo() const
{
return ULandscapeInfo::Find(GetWorld(), LandscapeGuid);
}
#if WITH_EDITOR
void ALandscapeSplineActor::GetActorDescProperties(FPropertyPairsMap& PropertyPairsMap) const
{
Super::GetActorDescProperties(PropertyPairsMap);
if (LandscapeGuid.IsValid())
{
PropertyPairsMap.AddProperty(ALandscape::AffectsLandscapeActorDescProperty, *LandscapeGuid.ToString());
}
}
void ALandscapeSplineActor::GetSharedProperties(ULandscapeInfo* InLandscapeInfo)
{
Modify();
LandscapeGuid = InLandscapeInfo->LandscapeGuid;
}
void ALandscapeSplineActor::Destroyed()
{
Super::Destroyed();
UWorld* World = GetWorld();
if (GIsEditor && !World->IsGameWorld())
{
// Modify Splines Objects to support Undo/Redo
GetSplinesComponent()->ModifySplines();
}
}
void ALandscapeSplineActor::PostRegisterAllComponents()
{
Super::PostRegisterAllComponents();
if (!IsPendingKillPending())
{
if (LandscapeGuid.IsValid())
{
ULandscapeInfo* LandscapeInfo = ULandscapeInfo::FindOrCreate(GetWorld(), LandscapeGuid);
LandscapeInfo->RegisterSplineActor(this);
}
}
}
void ALandscapeSplineActor::UnregisterAllComponents(bool bForReregister)
{
if (GetWorld() && IsValidChecked(GetWorld()) && !GetWorld()->IsUnreachable() && LandscapeGuid.IsValid())
{
if (ULandscapeInfo* LandscapeInfo = GetLandscapeInfo())
{
LandscapeInfo->UnregisterSplineActor(this);
}
}
Super::UnregisterAllComponents(bForReregister);
}
void ALandscapeSplineActor::PostEditMove(bool bFinished)
{
Super::PostEditMove(bFinished);
if (bFinished)
{
GetLandscapeInfo()->RequestSplineLayerUpdate();
}
}
AActor* ALandscapeSplineActor::GetSceneOutlinerParent() const
{
if (ULandscapeInfo* LandscapeInfo = GetLandscapeInfo())
{
return LandscapeInfo->LandscapeActor.Get();
}
return nullptr;
}
#endif