You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
* 2 implementations for now : ULandscapeEditLayer (standard edit layer, that can be sculpted/painted) and ULandscapeEditLayerSplines (replaces the current "Reserved for Splines" edit layer system) * The edit layers have a bunch of virtual functions to customize their behavior (affects heightmaps/weightmaps/visibility? contains persistent textures? can be edited via standard tools? supports collapsing? etc.) * A composition pattern was used : FLandscapeLayer owns an Instanced ULandscapeEditLayerBase property (null not allowed) although the public "LandscapeLayers" list was deprecated in favor of a private "LandscapeEditLayers" in order to stop users being able to mutate the list of layers and their properties freely * ALandscape::GetLayer was deprecated in favor of ALandscape::GetLayerConst in order to enforce a single, controlled, access to the layer data (via public methods), instead of the current free-for-all way Landscape UX changes/improvements : * Landscape edit layers are now added via a more standard '+' button (like standard array properties) and will then request the user to pick a class of edit layer (standard or splines for now, but any non-abstract edit layer class is discoverable) via a modal dialog. The type of the edit layer cannot be changed after the fact (the "Reserve For Splines" / "Remove Reserve for Splines" actions are therefore gone) * Deletion of edit layer is done via a button or via context menu * Edit layers context menu will now display all available options (instead of hiding some) but will disable the ones that are not available and will display the reason why that's the case in the tooltip (e.g. cannot rename a locked edit layer) * The Collapse Layer action has been made available all the time (instead of only when the Manage panel is active) and now also supports collapsing the splines layer onto a standard layer underneath (but not the other way around), because it's supported, since the Splines layer does have standard heightmaps/weightmaps * The edit layers have the ability to define custom actions generically, which will dynamically extend the context menu on that edit layer (the "Update Splines" actions on the Splines edit layer uses this system) * Added a drag indicator on edit layers to streamline this reorderable list Left to do: * Move most settings from FLandscapeLayer to ULandscapeEditLayer and implement a generic system for responding to property changes in both the landscape and landscape UI, instead of exposing several ad-hoc functions (SetLayerName, SetLayerLocked, etc.) on the landscape and the landscape UI code (plus, it will allow to get those to react to changes to settings defined in an plugin's edit layer) * Prevent useless heightmaps/weightmaps from being created on procedural edit layers that don't need persistent textures (water, landscape patch, etc.) This is a memory optimization : at least, we already prevent those to be edited, which is a common mistake with the current BP brush system, as users can sculpt/paint on a water edit layer, since it's a standard edit layer and they're allowed to * Move the systems that act as proper edit layers (LandscapePatchManager, WaterBrushManager) from BP brush to the landscape edit layer class system * Integrate proper icons for edit layer classes to help the user tell at a glance the type of layer (e.g. splines layer) #jira UE-209960 #tests Editor #rb don.boogert [CL 32477586 by jonathan bard in ue5-main branch]
146 lines
4.7 KiB
C++
146 lines
4.7 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
/*=============================================================================
|
|
LandscapeBlueprintSupport.cpp: Landscape blueprint functions
|
|
=============================================================================*/
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "Engine/World.h"
|
|
#include "LandscapeProxy.h"
|
|
#include "LandscapeSplineSegment.h"
|
|
#include "LandscapeSplineRaster.h"
|
|
#include "Components/SplineComponent.h"
|
|
#include "LandscapeComponent.h"
|
|
#include "Landscape.h"
|
|
#include "LandscapePrivate.h"
|
|
#include "Materials/MaterialInstanceDynamic.h"
|
|
#include "LandscapeProxy.h"
|
|
|
|
void ALandscapeProxy::EditorApplySpline(USplineComponent* InSplineComponent, float StartWidth, float EndWidth, float StartSideFalloff, float EndSideFalloff, float StartRoll, float EndRoll, int32 NumSubdivisions, bool bRaiseHeights, bool bLowerHeights, ULandscapeLayerInfoObject* PaintLayer, FName EditLayerName)
|
|
{
|
|
#if WITH_EDITOR
|
|
if (InSplineComponent && !GetWorld()->IsGameWorld())
|
|
{
|
|
if (ALandscape* Landscape = GetLandscapeInfo()->LandscapeActor.Get())
|
|
{
|
|
const FLandscapeLayer* Layer = Landscape->GetLayerConst(EditLayerName);
|
|
if (Landscape->HasLayersContent() && (Layer == nullptr))
|
|
{
|
|
UE_LOG(LogLandscape, Error, TEXT("Invalid landscape edit layer name (\"%s\") for Edit Layers-enabled landscape. Cannot apply spline. "), *EditLayerName.ToString());
|
|
return;
|
|
}
|
|
|
|
FScopedSetLandscapeEditingLayer Scope(Landscape, Layer ? Layer->Guid : FGuid(), [=] { Landscape->RequestLayersContentUpdate(ELandscapeLayerUpdateMode::Update_All); });
|
|
|
|
TArray<FLandscapeSplineInterpPoint> Points;
|
|
LandscapeSplineRaster::FPointifyFalloffs Falloffs(StartSideFalloff, EndSideFalloff);
|
|
LandscapeSplineRaster::Pointify(InSplineComponent->SplineCurves.Position, Points, NumSubdivisions, 0.0f, 0.0f, StartWidth, EndWidth, StartWidth, EndWidth, Falloffs, StartRoll, EndRoll);
|
|
|
|
FTransform SplineToWorld = InSplineComponent->GetComponentTransform();
|
|
LandscapeSplineRaster::RasterizeSegmentPoints(GetLandscapeInfo(), MoveTemp(Points), SplineToWorld, bRaiseHeights, bLowerHeights, PaintLayer);
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|
|
void ALandscapeProxy::SetLandscapeMaterialTextureParameterValue(FName ParameterName, class UTexture* Value)
|
|
{
|
|
if (bUseDynamicMaterialInstance)
|
|
{
|
|
for (ULandscapeComponent* Component : LandscapeComponents)
|
|
{
|
|
for (UMaterialInstanceDynamic* MaterialInstance : Component->MaterialInstancesDynamic)
|
|
{
|
|
if (MaterialInstance != nullptr)
|
|
{
|
|
MaterialInstance->SetTextureParameterValue(ParameterName, Value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void ALandscapeProxy::SetLandscapeMaterialVectorParameterValue(FName ParameterName, FLinearColor Value)
|
|
{
|
|
if (bUseDynamicMaterialInstance)
|
|
{
|
|
for (ULandscapeComponent* Component : LandscapeComponents)
|
|
{
|
|
for (UMaterialInstanceDynamic* MaterialInstance : Component->MaterialInstancesDynamic)
|
|
{
|
|
if (MaterialInstance != nullptr)
|
|
{
|
|
MaterialInstance->SetVectorParameterValue(ParameterName, Value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void ALandscapeProxy::SetLandscapeMaterialScalarParameterValue(FName ParameterName, float Value)
|
|
{
|
|
if (bUseDynamicMaterialInstance)
|
|
{
|
|
for (ULandscapeComponent* Component : LandscapeComponents)
|
|
{
|
|
for (UMaterialInstanceDynamic* MaterialInstance : Component->MaterialInstancesDynamic)
|
|
{
|
|
if (MaterialInstance != nullptr)
|
|
{
|
|
MaterialInstance->SetScalarParameterValue(ParameterName, Value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void ALandscapeProxy::EditorSetLandscapeMaterial(UMaterialInterface* NewLandscapeMaterial)
|
|
{
|
|
#if WITH_EDITOR
|
|
if (!GetWorld()->IsGameWorld())
|
|
{
|
|
LandscapeMaterial = NewLandscapeMaterial;
|
|
FPropertyChangedEvent PropertyChangedEvent(FindFieldChecked<FProperty>(GetClass(), FName("LandscapeMaterial")));
|
|
PostEditChangeProperty(PropertyChangedEvent);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
float ULandscapeComponent::EditorGetPaintLayerWeightByNameAtLocation(const FVector& InLocation, const FName InPaintLayerName)
|
|
{
|
|
#if WITH_EDITOR
|
|
ULandscapeInfo* LandscapeInfo = GetLandscapeInfo();
|
|
ULandscapeLayerInfoObject* PaintLayer = LandscapeInfo ? LandscapeInfo->GetLayerInfoByName(InPaintLayerName) : nullptr;
|
|
return GetLayerWeightAtLocation(InLocation, PaintLayer);
|
|
#else
|
|
return 0.f;
|
|
#endif
|
|
}
|
|
|
|
float ULandscapeComponent::EditorGetPaintLayerWeightAtLocation(const FVector& InLocation, ULandscapeLayerInfoObject* PaintLayer)
|
|
{
|
|
#if WITH_EDITOR
|
|
if (PaintLayer)
|
|
{
|
|
return GetLayerWeightAtLocation(InLocation, PaintLayer);
|
|
}
|
|
#endif
|
|
return 0.f;
|
|
}
|
|
|
|
void ALandscapeProxy::SetVirtualTextureRenderPassType(ERuntimeVirtualTextureMainPassType InType)
|
|
{
|
|
if (InType != VirtualTextureRenderPassType)
|
|
{
|
|
VirtualTextureRenderPassType = InType;
|
|
|
|
for (ULandscapeComponent* Component : LandscapeComponents)
|
|
{
|
|
if (Component != nullptr)
|
|
{
|
|
Component->MarkRenderStateDirty();
|
|
}
|
|
}
|
|
}
|
|
}
|