Files
michael balzer 647682f21c MeshModelingToolset: Rename experimental module MeshModelingToolsEditorOnly to MeshModelingToolsEditorOnlyExp
#preflight 61f855ba41414fb013db45ac

#ROBOMERGE-AUTHOR: michael.balzer
#ROBOMERGE-SOURCE: CL 18799426 in //UE5/Release-5.0/... via CL 18801880 via CL 18802470
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v908-18788545)

[CL 18808168 by michael balzer in ue5-main branch]
2022-02-01 09:52:56 -05:00

108 lines
2.9 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "InteractiveToolBuilder.h"
#include "DynamicMeshBrushTool.h"
#include "BaseTools/MeshSurfacePointMeshEditingTool.h"
#include "ShapeSprayTool.generated.h"
/**
* UMeshSurfacePointMeshEditingToolBuilder override for UShapeSprayTool
*/
UCLASS(Transient)
class MESHMODELINGTOOLSEDITORONLYEXP_API UShapeSprayToolBuilder : public UMeshSurfacePointMeshEditingToolBuilder
{
GENERATED_BODY()
public:
virtual UMeshSurfacePointTool* CreateNewTool(const FToolBuilderState& SceneState) const override;
};
/**
* Settings UObject for UShapeSprayTool.
*/
UCLASS(Transient)
class MESHMODELINGTOOLSEDITORONLYEXP_API UShapeSprayToolProperties : public UInteractiveToolPropertySet
{
GENERATED_BODY()
public:
UShapeSprayToolProperties();
UPROPERTY(EditAnywhere, Category = Options)
FLinearColor Color;
UPROPERTY(EditAnywhere, Category = Options)
bool bRandomColor;
UPROPERTY(EditAnywhere, Category = Options, meta = (DisplayName = "Speed", UIMin = "0.01", UIMax = "1.0"))
float DropSpeed;
UPROPERTY(EditAnywhere, Category = Options, meta = (DisplayName = "Shape Size", UIMin = "1.0", UIMax = "30.0"))
float ObjectSize;
UPROPERTY(EditAnywhere, Category = Options, meta = (DisplayName = "Repeat Per Stamp"))
int NumSplats;
UPROPERTY(EditAnywhere, Category = Options)
TObjectPtr<UMaterialInterface> Material = nullptr;
};
/**
* UShapeSprayTool is a brush-based tool that generates random points on the
* target surface within the brush radius, and then creates small meshes
* at those points. The accumulated meshes are appended and can
* be emitted as a new StaticMeshComponent on Accept.
*/
UCLASS(Transient)
class MESHMODELINGTOOLSEDITORONLYEXP_API UShapeSprayTool : public UDynamicMeshBrushTool
{
GENERATED_BODY()
public:
UShapeSprayTool();
virtual void SetWorld(UWorld* World);
// UInteractiveTool API
virtual void Setup() override;
virtual void Shutdown(EToolShutdownType ShutdownType) override;
virtual bool HasCancel() const override { return true; }
virtual bool HasAccept() const override { return true; }
virtual bool CanAccept() const override;
virtual void OnPropertyModified(UObject* PropertySet, FProperty* Property) override;
// UMeshSurfacePointTool API
virtual void OnBeginDrag(const FRay& Ray) override;
virtual void OnUpdateDrag(const FRay& Ray) override;
virtual void OnEndDrag(const FRay& Ray) override;
protected:
UPROPERTY()
TObjectPtr<UShapeSprayToolProperties> Settings;
// small meshes are accumulated here
UPROPERTY()
TObjectPtr<UDynamicMeshComponent> AccumMeshComponent;
protected:
UWorld* TargetWorld;
UE::Geometry::FDynamicMesh3 ShapeMesh;
void UpdateShapeMesh();
void SplatShape(const UE::Geometry::FFrame3d& LocalFrame, double Scale, UE::Geometry::FDynamicMesh3* TargetMesh);
TArray<int> VertexMap;
FRandomStream Random;
virtual void EmitResult();
};