Add selection outline post-process setup (material pending)

- PostProcessComponent on Pawn (unbound, applies to entire scene)
- Auto-loads M_PS_Editor_SelectionOutline material at BeginPlay
- Removed debug bounding box from Tick
- Custom depth stencil already toggled on selected actors
- Material needs to be created in UE editor (edge detection on CustomStencil)
- Instructions: use TexCoord + Constant2Vector offsets for 4-neighbor sampling

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-10 21:28:24 +02:00
parent 36b04bee61
commit 5be3a777f9
4 changed files with 48 additions and 36 deletions

View File

@@ -1,6 +1,7 @@
#include "PS_Editor_Pawn.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"
#include "Components/PostProcessComponent.h"
#include "EnhancedInputComponent.h"
#include "EnhancedInputSubsystems.h"
#include "InputAction.h"
@@ -31,11 +32,29 @@ APS_Editor_Pawn::APS_Editor_Pawn()
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
Camera->SetupAttachment(SpringArm);
OutlinePostProcess = CreateDefaultSubobject<UPostProcessComponent>(TEXT("OutlinePostProcess"));
OutlinePostProcess->SetupAttachment(RootScene);
OutlinePostProcess->bUnbound = true; // Apply to entire scene
}
void APS_Editor_Pawn::BeginPlay()
{
Super::BeginPlay();
// Load outline post-process material
UMaterialInterface* OutlineMat = LoadObject<UMaterialInterface>(
nullptr, TEXT("/PS_Editor/M_PS_Editor_SelectionOutline.M_PS_Editor_SelectionOutline"));
if (OutlineMat && OutlinePostProcess)
{
OutlinePostProcess->Settings.WeightedBlendables.Array.Add(FWeightedBlendable(1.0f, OutlineMat));
UE_LOG(LogTemp, Log, TEXT("PS_Editor: Selection outline material loaded"));
}
else
{
UE_LOG(LogTemp, Warning, TEXT("PS_Editor: Outline material /PS_Editor/M_PS_Editor_SelectionOutline not found. "
"Create a Post Process material in Plugins/PS_Editor/Content/"));
}
}
void APS_Editor_Pawn::Tick(float DeltaTime)
@@ -53,22 +72,6 @@ void APS_Editor_Pawn::Tick(float DeltaTime)
UpdateGizmoHover();
}
// Draw debug bounding box around selected actors
if (APS_Editor_PlayerController* EditorPC = Cast<APS_Editor_PlayerController>(PC))
{
if (UPS_Editor_SelectionManager* SM = EditorPC->GetSelectionManager())
{
for (const TWeakObjectPtr<AActor>& Weak : SM->GetSelectedActors())
{
if (AActor* Actor = Weak.Get())
{
FVector Origin, Extent;
Actor->GetActorBounds(false, Origin, Extent);
DrawDebugBox(GetWorld(), Origin, Extent, FColor::Orange, false, -1.0f, 0, 2.0f);
}
}
}
}
}
}

View File

@@ -8,6 +8,7 @@
class UCameraComponent;
class USpringArmComponent;
class UPostProcessComponent;
class UInputAction;
class UInputMappingContext;
@@ -73,6 +74,9 @@ protected:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Camera")
TObjectPtr<UCameraComponent> Camera;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Camera")
TObjectPtr<UPostProcessComponent> OutlinePostProcess;
// ---- Camera Settings ----
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Camera|Fly")