2020-08-11 01:36:57 -04:00
|
|
|
// 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"
|
2021-06-23 22:14:55 -04:00
|
|
|
#include "PropertySets/CreateMeshObjectTypeProperties.h"
|
2020-08-11 01:36:57 -04:00
|
|
|
#include "Properties/RevolveProperties.h"
|
|
|
|
|
|
|
|
|
|
#include "DrawAndRevolveTool.generated.h"
|
|
|
|
|
|
|
|
|
|
class UCollectSurfacePathMechanic;
|
|
|
|
|
class UConstructionPlaneMechanic;
|
2020-09-01 14:07:48 -04:00
|
|
|
class UCurveControlPointsMechanic;
|
2020-08-11 01:36:57 -04:00
|
|
|
|
|
|
|
|
UCLASS()
|
2021-09-30 12:00:06 -04:00
|
|
|
class MESHMODELINGTOOLS_API UDrawAndRevolveToolBuilder : public UInteractiveToolBuilder
|
2020-08-11 01:36:57 -04:00
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual bool CanBuildTool(const FToolBuilderState& SceneState) const override;
|
|
|
|
|
virtual UInteractiveTool* BuildTool(const FToolBuilderState& SceneState) const override;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
UCLASS()
|
2021-09-30 12:00:06 -04:00
|
|
|
class MESHMODELINGTOOLS_API URevolveToolProperties : public URevolveProperties
|
2020-08-11 01:36:57 -04:00
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2021-10-26 13:33:36 -04:00
|
|
|
/** 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",
|
2021-10-28 11:24:32 -04:00
|
|
|
EditCondition = "HeightOffsetPerDegree != 0 || RevolveDegrees != 360", ValidEnumValues = "None, CenterFan, Delaunay"))
|
|
|
|
|
ERevolvePropertiesCapFillMode CapFillMode = ERevolvePropertiesCapFillMode::Delaunay;
|
2021-10-26 13:33:36 -04:00
|
|
|
|
|
|
|
|
/** 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;
|
2020-08-11 01:36:57 -04:00
|
|
|
|
2020-10-09 22:42:26 -04:00
|
|
|
/** Sets the draw plane origin. The revolution axis is the X axis in the plane. */
|
2022-01-06 14:39:38 -05:00
|
|
|
UPROPERTY(EditAnywhere, Category = DrawPlane, meta = (DisplayName = "Origin", EditCondition = "bAllowedToEditDrawPlane", HideEditConditionToggle,
|
|
|
|
|
Delta = 5, LinearDeltaSensitivity = 1))
|
2020-10-09 22:42:26 -04:00
|
|
|
FVector DrawPlaneOrigin = FVector(0, 0, 0);
|
|
|
|
|
|
|
|
|
|
/** Sets the draw plane orientation. The revolution axis is the X axis in the plane. */
|
2021-10-26 13:33:36 -04:00
|
|
|
UPROPERTY(EditAnywhere, Category = DrawPlane, meta = (DisplayName = "Orientation", EditCondition = "bAllowedToEditDrawPlane", HideEditConditionToggle,
|
2022-01-06 14:39:38 -05:00
|
|
|
UIMin = -180, UIMax = 180, ClampMin = -180000, ClampMax = 180000))
|
2020-10-09 22:42:26 -04:00
|
|
|
FRotator DrawPlaneOrientation = FRotator(90, 0, 0);
|
|
|
|
|
|
2021-10-26 13:33:36 -04:00
|
|
|
/** Enables snapping while editing the path. */
|
|
|
|
|
UPROPERTY(EditAnywhere, Category = Snapping)
|
2020-09-01 14:07:48 -04:00
|
|
|
bool bEnableSnapping = true;
|
|
|
|
|
|
2020-08-11 01:36:57 -04:00
|
|
|
// Not user visible- used to disallow draw plane modification.
|
2020-09-01 14:07:48 -04:00
|
|
|
UPROPERTY(meta = (TransientToolProperty))
|
|
|
|
|
bool bAllowedToEditDrawPlane = true;
|
2021-10-26 13:33:36 -04:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual ERevolvePropertiesCapFillMode GetCapFillMode() const override
|
|
|
|
|
{
|
2021-10-28 11:24:32 -04:00
|
|
|
return CapFillMode;
|
2021-10-26 13:33:36 -04:00
|
|
|
}
|
2020-08-11 01:36:57 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
UCLASS()
|
2021-09-30 12:00:06 -04:00
|
|
|
class MESHMODELINGTOOLS_API URevolveOperatorFactory : public UObject, public UE::Geometry::IDynamicMeshOperatorFactory
|
2020-08-11 01:36:57 -04:00
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// IDynamicMeshOperatorFactory API
|
2021-03-09 19:33:56 -04:00
|
|
|
virtual TUniquePtr<UE::Geometry::FDynamicMeshOperator> MakeNewOperator() override;
|
2020-08-11 01:36:57 -04:00
|
|
|
|
|
|
|
|
UPROPERTY()
|
2021-07-20 00:24:38 -04:00
|
|
|
TObjectPtr<UDrawAndRevolveTool> RevolveTool;
|
2020-08-11 01:36:57 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Draws a profile curve and revolves it around an axis. */
|
|
|
|
|
UCLASS()
|
2021-09-30 12:00:06 -04:00
|
|
|
class MESHMODELINGTOOLS_API UDrawAndRevolveTool : public UInteractiveTool
|
2020-08-11 01:36:57 -04:00
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual void SetWorld(UWorld* World) { TargetWorld = World; }
|
|
|
|
|
|
2020-09-01 14:07:48 -04:00
|
|
|
virtual void RegisterActions(FInteractiveToolActionSet& ActionSet) override;
|
2021-03-24 16:38:48 -04:00
|
|
|
virtual void OnPointDeletionKeyPress();
|
2020-09-01 14:07:48 -04:00
|
|
|
|
2020-08-11 01:36:57 -04:00
|
|
|
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.
|
2021-03-17 21:45:29 -04:00
|
|
|
FVector3d RevolutionAxisOrigin;
|
|
|
|
|
FVector3d RevolutionAxisDirection;
|
2020-08-11 01:36:57 -04:00
|
|
|
|
|
|
|
|
bool bProfileCurveComplete = false;
|
|
|
|
|
|
2020-10-09 22:42:26 -04:00
|
|
|
void UpdateRevolutionAxis();
|
2020-08-11 01:36:57 -04:00
|
|
|
|
|
|
|
|
UPROPERTY()
|
2021-07-20 00:24:38 -04:00
|
|
|
TObjectPtr<UCurveControlPointsMechanic> ControlPointsMechanic = nullptr;
|
2020-08-11 01:36:57 -04:00
|
|
|
|
|
|
|
|
UPROPERTY()
|
2021-07-20 00:24:38 -04:00
|
|
|
TObjectPtr<UConstructionPlaneMechanic> PlaneMechanic = nullptr;
|
2020-08-11 01:36:57 -04:00
|
|
|
|
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()
|
2021-07-20 00:24:38 -04:00
|
|
|
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
|
|
|
|
2020-08-11 01:36:57 -04:00
|
|
|
UPROPERTY()
|
2021-07-20 00:24:38 -04:00
|
|
|
TObjectPtr<URevolveToolProperties> Settings = nullptr;
|
2020-08-11 01:36:57 -04:00
|
|
|
|
|
|
|
|
UPROPERTY()
|
2021-07-20 00:24:38 -04:00
|
|
|
TObjectPtr<UNewMeshMaterialProperties> MaterialProperties;
|
2020-08-11 01:36:57 -04:00
|
|
|
|
|
|
|
|
UPROPERTY()
|
2021-07-20 00:24:38 -04:00
|
|
|
TObjectPtr<UMeshOpPreviewWithBackgroundCompute> Preview = nullptr;
|
2020-08-11 01:36:57 -04:00
|
|
|
|
|
|
|
|
void StartPreview();
|
|
|
|
|
|
|
|
|
|
void GenerateAsset(const FDynamicMeshOpResult& Result);
|
|
|
|
|
|
|
|
|
|
friend class URevolveOperatorFactory;
|
|
|
|
|
};
|