Files
UnrealEngineUWP/Engine/Plugins/Runtime/MeshModelingToolset/Source/MeshModelingTools/Public/DrawAndRevolveTool.h

151 lines
4.9 KiB
C
Raw Normal View History

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "ModelingOperators.h" //IDynamicMeshOperatorFactory
#include "InteractiveTool.h" //UInteractiveToolPropertySet
#include "InteractiveToolBuilder.h" //UInteractiveToolBuilder
#include "MeshOpPreviewHelpers.h" //FDynamicMeshOpResult
#include "Properties/MeshMaterialProperties.h"
#include "PropertySets/CreateMeshObjectTypeProperties.h"
#include "Properties/RevolveProperties.h"
#include "DrawAndRevolveTool.generated.h"
class UCollectSurfacePathMechanic;
class UConstructionPlaneMechanic;
class UCurveControlPointsMechanic;
UCLASS()
class MESHMODELINGTOOLS_API UDrawAndRevolveToolBuilder : public UInteractiveToolBuilder
{
GENERATED_BODY()
public:
virtual bool CanBuildTool(const FToolBuilderState& SceneState) const override;
virtual UInteractiveTool* BuildTool(const FToolBuilderState& SceneState) const override;
};
UCLASS()
class MESHMODELINGTOOLS_API URevolveToolProperties : public URevolveProperties
{
GENERATED_BODY()
public:
/** Determines how end caps are created. This is not relevant if the end caps are not visible or if the path is not closed. */
UPROPERTY(EditAnywhere, Category = Revolve, AdvancedDisplay, meta = (DisplayAfter = "QuadSplitMode",
EditCondition = "HeightOffsetPerDegree != 0 || RevolveDegrees != 360", ValidEnumValues = "None, CenterFan, Delaunay"))
ERevolvePropertiesCapFillMode CapFillMode = ERevolvePropertiesCapFillMode::Delaunay;
/** Connect the ends of an open path to the axis to add caps to the top and bottom of the revolved result.
* This is not relevant for paths that are already closed. */
UPROPERTY(EditAnywhere, Category = Revolve, AdvancedDisplay)
bool bClosePathToAxis = true;
/** Sets the draw plane origin. The revolution axis is the X axis in the plane. */
UPROPERTY(EditAnywhere, Category = DrawPlane, meta = (DisplayName = "Origin", EditCondition = "bAllowedToEditDrawPlane", HideEditConditionToggle,
Delta = 5, LinearDeltaSensitivity = 1))
FVector DrawPlaneOrigin = FVector(0, 0, 0);
/** Sets the draw plane orientation. The revolution axis is the X axis in the plane. */
UPROPERTY(EditAnywhere, Category = DrawPlane, meta = (DisplayName = "Orientation", EditCondition = "bAllowedToEditDrawPlane", HideEditConditionToggle,
UIMin = -180, UIMax = 180, ClampMin = -180000, ClampMax = 180000))
FRotator DrawPlaneOrientation = FRotator(90, 0, 0);
/** Enables snapping while editing the path. */
UPROPERTY(EditAnywhere, Category = Snapping)
bool bEnableSnapping = true;
// Not user visible- used to disallow draw plane modification.
UPROPERTY(meta = (TransientToolProperty))
bool bAllowedToEditDrawPlane = true;
protected:
virtual ERevolvePropertiesCapFillMode GetCapFillMode() const override
{
return CapFillMode;
}
};
UCLASS()
class MESHMODELINGTOOLS_API URevolveOperatorFactory : public UObject, public UE::Geometry::IDynamicMeshOperatorFactory
{
GENERATED_BODY()
public:
// IDynamicMeshOperatorFactory API
virtual TUniquePtr<UE::Geometry::FDynamicMeshOperator> MakeNewOperator() override;
UPROPERTY()
TObjectPtr<UDrawAndRevolveTool> RevolveTool;
};
/** Draws a profile curve and revolves it around an axis. */
UCLASS()
class MESHMODELINGTOOLS_API UDrawAndRevolveTool : public UInteractiveTool
{
GENERATED_BODY()
public:
virtual void SetWorld(UWorld* World) { TargetWorld = World; }
virtual void RegisterActions(FInteractiveToolActionSet& ActionSet) override;
virtual void OnPointDeletionKeyPress();
virtual bool HasCancel() const override { return true; }
virtual bool HasAccept() const override { return true; }
virtual bool CanAccept() const override;
virtual void Setup() override;
virtual void Shutdown(EToolShutdownType ShutdownType) override;
virtual void OnTick(float DeltaTime) override;
virtual void Render(IToolsContextRenderAPI* RenderAPI) override;
virtual void OnPropertyModified(UObject* PropertySet, FProperty* Property) override;
protected:
UWorld* TargetWorld;
FViewCameraState CameraState;
// This information is replicated in the user-editable transform in the settings and in the PlaneMechanic
// plane, but the tool turned out to be much easier to write and edit with this decoupling.
FVector3d RevolutionAxisOrigin;
FVector3d RevolutionAxisDirection;
bool bProfileCurveComplete = false;
void UpdateRevolutionAxis();
UPROPERTY()
TObjectPtr<UCurveControlPointsMechanic> ControlPointsMechanic = nullptr;
UPROPERTY()
TObjectPtr<UConstructionPlaneMechanic> PlaneMechanic = nullptr;
ModelingTools: add support for creating Volumes directly from DrawPolygon, DrawRevolve, DrawPolyPath, and AddPrimitive, CombineMeshes, CutMeshWithMesh, PlaneCut, BaseCreateFromSelected Tools. Improve support for Editing volumes, eg handling mesh/volume interactions, and add configurable auto-simplification for volumes to avoid painful Editor hangs. - Move ToolTarget implementations, DynamicMeshToVolume to ModelingComponentsEditorOnly module - move VolumeToDynamicMesh, DynamicMeshProvider/Commiter interfaces to ModelingComponents module - Add UCreateMeshObjectTypeProperties property set to expose mesh/volume options - Add FCreateMeshObjectParams::TypeHintClass to allow AVolume type (or other UClass hints) to be passed to creation APIs - Add UE::ToolTarget::ConfigureCreateMeshObjectParams() util function in ModelingToolTargetUtil, tries to determine output type in a FCreateMeshObjectParams based on input ToolTarget - Add UEditorModelingObjectsCreationAPI::CreateVolume() implementation - Add UEditorModelingObjectsCreationAPI::FilterMaterials() that strips out any internal materials and replaces with WorldGridMaterial. This occurs when (eg) subtracting a Volume from a StaticMesh, because the temporary volume mesh gets assigned internal materials, but the Tools don't know this. Use in EditorModelingObjectsCreationAPI when creating new objects. UStaticMeshComponentToolTarget also does this filtering in ::CommitMaterialSetUpdate(). - Add ::ComponentTypeSupportsCollision() function to ComponentCollisionUtil, use to avoid checks/ensures for Volume targets - Add support for automatic mesh simplification in DynamicMeshToVolume. Add CVar to VolumeDynamicMeshToolTarget.h to control max triangle count (default 500). Apply auto-simplify when creating or updating an AVolume. This prevents the Editor from blocking for long periods on meshes that are too high-res for volumes (even 500 is quite high). - DynamicMeshToVolume now emits polygroup-faces that contain holes (ie multiple boundary loops) as a set of triangles, rather than emitting separate overlapping faces for each boundary loop #rb none #rnx #jira none #preflight 60ba50632c42ea0001cb54c5 [CL 16561742 by Ryan Schmidt in ue5-main branch]
2021-06-04 16:04:03 -04:00
/** Property set for type of output object (StaticMesh, Volume, etc) */
UPROPERTY()
TObjectPtr<UCreateMeshObjectTypeProperties> OutputTypeProperties;
ModelingTools: add support for creating Volumes directly from DrawPolygon, DrawRevolve, DrawPolyPath, and AddPrimitive, CombineMeshes, CutMeshWithMesh, PlaneCut, BaseCreateFromSelected Tools. Improve support for Editing volumes, eg handling mesh/volume interactions, and add configurable auto-simplification for volumes to avoid painful Editor hangs. - Move ToolTarget implementations, DynamicMeshToVolume to ModelingComponentsEditorOnly module - move VolumeToDynamicMesh, DynamicMeshProvider/Commiter interfaces to ModelingComponents module - Add UCreateMeshObjectTypeProperties property set to expose mesh/volume options - Add FCreateMeshObjectParams::TypeHintClass to allow AVolume type (or other UClass hints) to be passed to creation APIs - Add UE::ToolTarget::ConfigureCreateMeshObjectParams() util function in ModelingToolTargetUtil, tries to determine output type in a FCreateMeshObjectParams based on input ToolTarget - Add UEditorModelingObjectsCreationAPI::CreateVolume() implementation - Add UEditorModelingObjectsCreationAPI::FilterMaterials() that strips out any internal materials and replaces with WorldGridMaterial. This occurs when (eg) subtracting a Volume from a StaticMesh, because the temporary volume mesh gets assigned internal materials, but the Tools don't know this. Use in EditorModelingObjectsCreationAPI when creating new objects. UStaticMeshComponentToolTarget also does this filtering in ::CommitMaterialSetUpdate(). - Add ::ComponentTypeSupportsCollision() function to ComponentCollisionUtil, use to avoid checks/ensures for Volume targets - Add support for automatic mesh simplification in DynamicMeshToVolume. Add CVar to VolumeDynamicMeshToolTarget.h to control max triangle count (default 500). Apply auto-simplify when creating or updating an AVolume. This prevents the Editor from blocking for long periods on meshes that are too high-res for volumes (even 500 is quite high). - DynamicMeshToVolume now emits polygroup-faces that contain holes (ie multiple boundary loops) as a set of triangles, rather than emitting separate overlapping faces for each boundary loop #rb none #rnx #jira none #preflight 60ba50632c42ea0001cb54c5 [CL 16561742 by Ryan Schmidt in ue5-main branch]
2021-06-04 16:04:03 -04:00
UPROPERTY()
TObjectPtr<URevolveToolProperties> Settings = nullptr;
UPROPERTY()
TObjectPtr<UNewMeshMaterialProperties> MaterialProperties;
UPROPERTY()
TObjectPtr<UMeshOpPreviewWithBackgroundCompute> Preview = nullptr;
void StartPreview();
void GenerateAsset(const FDynamicMeshOpResult& Result);
friend class URevolveOperatorFactory;
};