This commit is contained in:
2025-04-21 20:08:05 +08:00
parent 0f34d06513
commit 7c33e9830c
12 changed files with 2160 additions and 2151 deletions

View File

@@ -3,6 +3,8 @@
#include "CoreMinimal.h"
#include "Toolkits/AssetEditorToolkit.h"
#include "EditorUndoClient.h"
#include "BooleanCutTool.h"
#include "AnatomicalLayerSystem.h"
class USkeletalMesh;
class SDockTab;
@@ -12,48 +14,116 @@ class SBorder;
/**
* Dismemberment System Editor
* Provides real-time boolean cutting and multi-layer system editing functionality
* Allows users to create and edit anatomical layer structures for skeletal meshes
* Supports physics settings and effect previews
*/
class FDismembermentEditor : public FAssetEditorToolkit, public FEditorUndoClient
{
public:
/** Constructor */
FDismembermentEditor();
/** Destructor */
virtual ~FDismembermentEditor();
/**
* Initialize the dismemberment editor
* @param Mode - Toolkit mode
* @param InitToolkitHost - Toolkit host
* @param InSkeletalMesh - Skeletal mesh to edit
*/
void InitDismembermentEditor(const EToolkitMode::Type Mode, const TSharedPtr<IToolkitHost>& InitToolkitHost, USkeletalMesh* InSkeletalMesh);
/** Get toolkit name */
virtual FName GetToolkitFName() const override;
/** Get base toolkit name */
virtual FText GetBaseToolkitName() const override;
/** Get world centric tab prefix */
virtual FString GetWorldCentricTabPrefix() const override;
/** Get world centric tab color scale */
virtual FLinearColor GetWorldCentricTabColorScale() const override;
/** Post undo handler */
virtual void PostUndo(bool bSuccess) override;
/** Post redo handler */
virtual void PostRedo(bool bSuccess) override;
/** Get current skeletal mesh being edited */
USkeletalMesh* GetSkeletalMesh() const { return SkeletalMesh; }
private:
/** Create editor layout */
void CreateEditorLayout();
/** Create editor toolbar */
void CreateEditorToolbar();
void RegisterTabSpawners(const TSharedRef<FTabManager>& InTabManager);
void UnregisterTabSpawners(const TSharedRef<FTabManager>& InTabManager);
/** Register tab spawners */
virtual void RegisterTabSpawners(const TSharedRef<FTabManager>& InTabManager) override;
/** Unregister tab spawners */
virtual void UnregisterTabSpawners(const TSharedRef<FTabManager>& InTabManager) override;
/** Spawn viewport tab */
TSharedRef<SDockTab> SpawnTab_Viewport(const FSpawnTabArgs& Args);
/** Spawn details tab */
TSharedRef<SDockTab> SpawnTab_Details(const FSpawnTabArgs& Args);
/** Spawn layer system tab */
TSharedRef<SDockTab> SpawnTab_LayerSystem(const FSpawnTabArgs& Args);
/** Spawn physics settings tab */
TSharedRef<SDockTab> SpawnTab_PhysicsSettings(const FSpawnTabArgs& Args);
/** Perform boolean cut operation */
void PerformBooleanCut();
/** Add new anatomical layer */
void AddNewLayer();
/** Save edits */
void SaveEdits();
/** Preview effects */
void PreviewEffects();
private:
/** Current skeletal mesh being edited */
USkeletalMesh* SkeletalMesh;
/** Viewport widget */
TSharedPtr<SBorder> ViewportWidget;
/** Details widget */
TSharedPtr<IDetailsView> DetailsWidget;
/** Layer system widget */
TSharedPtr<SBorder> LayerSystemWidget;
/** Physics settings widget */
TSharedPtr<SBorder> PhysicsSettingsWidget;
/** Boolean cut tool */
UBooleanCutTool* BooleanCutTool;
/** Anatomical layer system */
UAnatomicalLayerSystem* LayerSystem;
/** Current cut plane */
FCutPlane CurrentCutPlane;
/** Selected bone name for cutting */
FName SelectedBoneName;
/** Flag to create cap mesh */
bool bCreateCapMesh;
/** Tab ID constants */
static const FName ViewportTabId;
static const FName DetailsTabId;
static const FName LayerSystemTabId;

View File

@@ -19,4 +19,4 @@ public:
// The asset that owns this graph
UPROPERTY()
TObjectPtr<class UDismembermentGraphAsset> OwningAsset;
};
};

View File

@@ -37,4 +37,4 @@ public:
virtual void CompileNode(class FDismembermentCompiler* Compiler) override;
virtual void ExecuteNode(class FDismembermentExecutor* Executor) override;
// End of UDismembermentGraphNode interface
};
};

View File

@@ -4,6 +4,8 @@
#include "Toolkits/AssetEditorToolkit.h"
#include "Widgets/Docking/SDockTab.h"
#include "BooleanCutTool.h"
#include "EditorUndoClient.h"
#include "Logging/LogMacros.h"
class SDockTab;
class SGraphEditor;
@@ -13,6 +15,10 @@ class SMatrixInputWidget;
class FFLESHViewportClient;
class FSceneViewport;
class UVisceraNodeObject;
class FDismembermentEditor;
// Define log category
DECLARE_LOG_CATEGORY_EXTERN(LogFLESHEditor, Log, All);
/**
* Bone tree item structure
@@ -181,7 +187,7 @@ struct FVisceraNodeItem : public TSharedFromThis<FVisceraNodeItem>
* FLESH Main Editor
* Provides the main editing functionality for the dismemberment system
*/
class FLESHEDITOR_API FFLESHEditor : public FAssetEditorToolkit
class FLESHEDITOR_API FFLESHEditor : public FAssetEditorToolkit, public FEditorUndoClient
{
public:
FFLESHEditor();
@@ -198,9 +204,27 @@ public:
virtual FString GetWorldCentricTabPrefix() const override;
virtual FLinearColor GetWorldCentricTabColorScale() const override;
// End of FAssetEditorToolkit interface
// FEditorUndoClient interface
virtual void PostUndo(bool bSuccess) override;
virtual void PostRedo(bool bSuccess) override;
// Open the editor
static void OpenEditor();
void OpenEditor();
// Get whether the editor is initialized
bool IsEditorInitialized();
// Get the editing object
UObject* GetEditingObject() const { return EditingObject; }
// Add DismembermentEditor related tab spawners
TSharedRef<SDockTab> SpawnTab_LayerSystem(const FSpawnTabArgs& Args);
TSharedRef<SDockTab> SpawnTab_PhysicsSettings(const FSpawnTabArgs& Args);
// Create DismembermentEditor related widgets
TSharedRef<SBorder> CreateLayerSystemWidget();
TSharedRef<SBorder> CreatePhysicsSettingsWidget();
private:
// Tab spawners
@@ -232,6 +256,9 @@ private:
// Create command list
void CreateCommandList();
// Extend toolbar with custom buttons
void ExtendToolbar();
// Generate bone tree row
TSharedRef<ITableRow> OnGenerateBoneRow(TSharedPtr<FBoneTreeItem> Item, const TSharedRef<STableViewBase>& OwnerTable);
@@ -338,4 +365,17 @@ private:
static const FName MatrixEditorTabId;
static const FName GraphEditorTabId;
static const FName ToolbarTabId;
static const FName LayerSystemTabId;
static const FName PhysicsSettingsTabId;
static const FName DismembermentGraphTabId;
// Is the editor initialized?
bool bIsInitialized;
// New DismembermentEditor related Widgets
TSharedPtr<SBorder> LayerSystemWidget;
TSharedPtr<SBorder> PhysicsSettingsWidget;
// Error handling method
void HandleEditorError(const FText& ErrorMessage);
};