This commit is contained in:
2025-04-23 01:18:06 +08:00
parent 83d52181f5
commit 0ea2281199
93 changed files with 8954 additions and 8943 deletions

View File

@@ -3,20 +3,31 @@
#include "CoreMinimal.h"
#include "Toolkits/AssetEditorToolkit.h"
#include "Widgets/Docking/SDockTab.h"
#include "BooleanCutTool.h"
#include "EditorUndoClient.h"
#include "Widgets/SViewport.h"
#include "EditorViewportClient.h"
#include "Widgets/Input/SSearchBox.h"
#include "Slate/SceneViewport.h"
#include "Framework/Application/SlateApplication.h"
#include "Styling/SlateStyleRegistry.h"
// Forward declaration for BooleanCutTool
class FBooleanCutTool;
#include "Logging/LogMacros.h"
#include "FLESHGraph/FLESHCompiler.h"
#include "FLESHGraph/FLESHExecutor.h"
class SDockTab;
class SGraphEditor;
class SPropertyTreeView;
class SAssetBrowser;
class SMatrixInputWidget;
class FFLESHViewportClient;
class FSceneViewport;
class UVisceraNodeObject;
class FDismembermentEditor;
// Forward declaration
class FFLESHViewportClient;
// Define log category
DECLARE_LOG_CATEGORY_EXTERN(LogFLESHEditor, Log, All);
@@ -203,7 +214,9 @@ public:
virtual FText GetBaseToolkitName() const override;
virtual FString GetWorldCentricTabPrefix() const override;
virtual FLinearColor GetWorldCentricTabColorScale() const override;
// End of FAssetEditorToolkit interface
// Override FAssetEditorToolkit methods with correct parameter types
virtual void OnToolkitHostingStarted(const TSharedRef<class IToolkit>& InToolkit) override;
virtual void OnToolkitHostingFinished(const TSharedRef<class IToolkit>& InToolkit) override;
// FEditorUndoClient interface
virtual void PostUndo(bool bSuccess) override;
@@ -219,12 +232,22 @@ public:
UObject* GetEditingObject() const { return EditingObject; }
// Add DismembermentEditor related tab spawners
TSharedRef<SDockTab> SpawnTab_LayerSystem(const FSpawnTabArgs& Args);
TSharedRef<SDockTab> SpawnTab_LayerSystemPanel(const FSpawnTabArgs& Args);
TSharedRef<SDockTab> SpawnTab_PhysicsSettings(const FSpawnTabArgs& Args);
// Create DismembermentEditor related widgets
TSharedRef<SBorder> CreateLayerSystemWidget();
TSharedRef<SBorder> CreatePhysicsSettingsWidget();
TSharedRef<SWidget> CreateNodeTreeWidget();
// Generate node tree row
TSharedRef<ITableRow> OnGenerateNodeTreeRow(TSharedPtr<FVisceraNodeItem> Item, const TSharedRef<STableViewBase>& OwnerTable);
// Get node tree children
void OnGetNodeTreeChildren(TSharedPtr<FVisceraNodeItem> Item, TArray<TSharedPtr<FVisceraNodeItem>>& OutChildren);
// Open node tree right-click menu
TSharedPtr<SWidget> OnNodeTreeContextMenuOpening();
private:
// Tab spawners
@@ -234,6 +257,9 @@ private:
TSharedRef<SDockTab> SpawnTab_MatrixEditor(const FSpawnTabArgs& Args);
TSharedRef<SDockTab> SpawnTab_GraphEditor(const FSpawnTabArgs& Args);
TSharedRef<SDockTab> SpawnTab_Toolbar(const FSpawnTabArgs& Args);
// Additional tab spawners
TSharedRef<SDockTab> SpawnTab_DismembermentGraph(const FSpawnTabArgs& Args);
TSharedRef<SDockTab> SpawnTab_NodeTree(const FSpawnTabArgs& Args);
// Create viewport widget
TSharedRef<SWidget> CreateViewportWidget();
@@ -256,7 +282,7 @@ private:
// Create command list
void CreateCommandList();
// Extend toolbar with custom buttons
// Extend toolbar
void ExtendToolbar();
// Generate bone tree row
@@ -273,6 +299,18 @@ private:
// Build viscera node tree
void BuildVisceraNodeTree();
// Count total nodes in a tree recursively
int32 CountNodes(TSharedPtr<FVisceraNodeItem> Node);
// 从父节点中递归移除节点
bool RemoveNodeFromParent(TSharedPtr<FVisceraNodeItem> ParentNode, TSharedPtr<FVisceraNodeItem> NodeToRemove);
// 递归复制节点
void CopyNodeRecursive(TSharedPtr<FVisceraNodeItem> SourceNode, TSharedPtr<FVisceraNodeItem> TargetParentNode);
// 查找节点的父节点并添加复制的节点
bool AddCopyToParent(TSharedPtr<FVisceraNodeItem> CurrentNode, TSharedPtr<FVisceraNodeItem> NodeToFind, TSharedPtr<FVisceraNodeItem> NodeCopy);
// Tree view generation methods
TSharedRef<ITableRow> OnGenerateNodeRow(TSharedPtr<FVisceraNodeItem> InItem, const TSharedRef<STableViewBase>& OwnerTable);
@@ -299,6 +337,15 @@ private:
void OnSavePreset();
void OnLoadPreset();
// 按钮点击事件处理
FReply OnResetCameraClicked();
FReply OnToggleWireframeClicked();
FReply OnToggleBonesClicked();
FReply OnImportModelClicked();
FReply OnSavePresetClicked();
FReply OnLoadPresetClicked();
FReply OnBooleanCutClicked();
// Viewport widget
TSharedPtr<class SViewport> ViewportWidget;
@@ -350,13 +397,8 @@ private:
// Scene viewport
TSharedPtr<FSceneViewport> Viewport;
// Viewport related methods
FReply OnResetCameraClicked();
FReply OnToggleWireframeClicked();
FReply OnToggleBonesClicked();
// The object being edited
UObject* EditingObject;
TObjectPtr<UObject> EditingObject;
// Tab IDs
static const FName ViewportTabId;
@@ -368,9 +410,7 @@ private:
static const FName LayerSystemTabId;
static const FName PhysicsSettingsTabId;
static const FName DismembermentGraphTabId;
// Is the editor initialized?
bool bIsInitialized;
static const FName NodeTreeTabId;
// New DismembermentEditor related Widgets
TSharedPtr<SBorder> LayerSystemWidget;
@@ -378,4 +418,57 @@ private:
// Error handling method
void HandleEditorError(const FText& ErrorMessage);
// Layer names for dropdown
TArray<TSharedPtr<FString>> LayerNames;
// Layer descriptions for tooltips
TMap<FString, FString> LayerDescriptions;
// Layer visibility states
TMap<FString, bool> LayerVisibility;
// Node tree root nodes
TArray<TSharedPtr<FVisceraNodeItem>> NodeTreeRoots;
// Get node tree root nodes
const TArray<TSharedPtr<FVisceraNodeItem>>& GetNodeTreeRoots() const { return NodeTreeRoots; }
// Get currently selected node
TSharedPtr<FVisceraNodeItem> GetSelectedNodeItem() const { return SelectedNodeItem; }
// Make these methods public so they can be accessed by FFLESHViewportClient
friend class FFLESHViewportClient;
// Node search filter text
FText NodeSearchText;
// Filtered node tree roots
TArray<TSharedPtr<FVisceraNodeItem>> FilteredNodeTreeRoots;
// Check if a node matches the search filter
bool DoesNodeMatchFilter(const TSharedPtr<FVisceraNodeItem>& Node) const;
// Apply search filter to node tree
void ApplySearchFilter();
// Reset search filter
void ResetSearchFilter();
// Handle node search text changes
void OnNodeSearchTextChanged(const FText& InFilterText);
// Bone tree items
TArray<TSharedPtr<FBoneTreeItem>> BoneTreeRoots;
// Boolean cut tool
TSharedPtr<class FBooleanCutTool> BooleanCutTool;
// FLESH Compiler
UPROPERTY()
UFLESHCompiler* FLESHCompiler;
// FLESH Executor
UPROPERTY()
UFLESHExecutor* FLESHExecutor;
};