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

@@ -2,6 +2,11 @@
#include "Engine/SkeletalMesh.h"
#include "Engine/StaticMesh.h"
#include "Materials/MaterialInterface.h"
#include "Logging/LogMacros.h"
#include "Misc/MessageDialog.h"
// Define log category
DEFINE_LOG_CATEGORY_STATIC(LogAnatomicalBrush, Log, All);
UAnatomicalStructureBrush::UAnatomicalStructureBrush()
{
@@ -11,40 +16,147 @@ UAnatomicalStructureBrush::UAnatomicalStructureBrush()
BrushSettings.BrushStrength = 0.5f;
BrushSettings.BrushFalloff = 0.5f;
BrushSettings.BrushMaterial = nullptr;
UE_LOG(LogAnatomicalBrush, Log, TEXT("AnatomicalStructureBrush initialized"));
}
void UAnatomicalStructureBrush::Initialize(const FAnatomicalBrushSettings& InSettings)
{
BrushSettings = InSettings;
UE_LOG(LogAnatomicalBrush, Log, TEXT("AnatomicalStructureBrush settings updated: Type=%d, Size=%.2f"),
(int32)BrushSettings.BrushType, BrushSettings.BrushSize);
}
bool UAnatomicalStructureBrush::ApplyToSkeletalMesh(USkeletalMesh* TargetMesh, const FVector& Location, const FVector& Direction, FName BoneName)
{
// Implementation will be added in future updates
// This is a placeholder to resolve link errors
return false;
// Add error handling
if (!TargetMesh)
{
UE_LOG(LogAnatomicalBrush, Error, TEXT("ApplyToSkeletalMesh failed: Target mesh is null"));
return false;
}
UE_LOG(LogAnatomicalBrush, Log, TEXT("Applying to skeletal mesh %s, Location: (%f, %f, %f), Bone: %s"),
*TargetMesh->GetName(), Location.X, Location.Y, Location.Z, *BoneName.ToString());
try
{
// Implementation will be added in future updates
// This is a basic framework to resolve link errors
// Execute different operations based on brush type
switch (BrushSettings.BrushType)
{
case EAnatomicalBrushType::Bone:
UE_LOG(LogAnatomicalBrush, Log, TEXT("Applying bone brush effect"));
// Bone brush logic
break;
case EAnatomicalBrushType::Muscle:
UE_LOG(LogAnatomicalBrush, Log, TEXT("Applying muscle brush effect"));
// Muscle brush logic
break;
case EAnatomicalBrushType::Organ:
UE_LOG(LogAnatomicalBrush, Log, TEXT("Applying organ brush effect"));
// Organ brush logic
break;
case EAnatomicalBrushType::Vessel:
UE_LOG(LogAnatomicalBrush, Log, TEXT("Applying blood vessel brush effect"));
// Blood vessel brush logic
break;
case EAnatomicalBrushType::Nerve:
UE_LOG(LogAnatomicalBrush, Log, TEXT("Applying nerve brush effect"));
// Nerve brush logic
break;
case EAnatomicalBrushType::Custom:
UE_LOG(LogAnatomicalBrush, Log, TEXT("Applying custom brush effect"));
// Custom brush logic
break;
default:
UE_LOG(LogAnatomicalBrush, Warning, TEXT("Unknown brush type"));
break;
}
return true; // Temporarily return success, should return based on operation result after actual implementation
}
catch (const std::exception& e)
{
UE_LOG(LogAnatomicalBrush, Error, TEXT("ApplyToSkeletalMesh exception: %s"), UTF8_TO_TCHAR(e.what()));
return false;
}
catch (...)
{
UE_LOG(LogAnatomicalBrush, Error, TEXT("ApplyToSkeletalMesh unknown exception occurred"));
return false;
}
}
bool UAnatomicalStructureBrush::ApplyToStaticMesh(UStaticMesh* TargetMesh, const FVector& Location, const FVector& Direction)
{
// Implementation will be added in future updates
// This is a placeholder to resolve link errors
return false;
// Add error handling
if (!TargetMesh)
{
UE_LOG(LogAnatomicalBrush, Error, TEXT("ApplyToStaticMesh failed: Target mesh is null"));
return false;
}
UE_LOG(LogAnatomicalBrush, Log, TEXT("Applying to static mesh %s, Location: (%f, %f, %f)"),
*TargetMesh->GetName(), Location.X, Location.Y, Location.Z);
try
{
// Implementation will be added in future updates
// This is a basic framework to resolve link errors
// Execute different operations based on brush type
switch (BrushSettings.BrushType)
{
case EAnatomicalBrushType::Bone:
UE_LOG(LogAnatomicalBrush, Log, TEXT("Applying bone brush effect to static mesh"));
// Bone brush logic
break;
case EAnatomicalBrushType::Muscle:
UE_LOG(LogAnatomicalBrush, Log, TEXT("Applying muscle brush effect to static mesh"));
// Muscle brush logic
break;
case EAnatomicalBrushType::Organ:
UE_LOG(LogAnatomicalBrush, Log, TEXT("Applying organ brush effect to static mesh"));
// Organ brush logic
break;
default:
UE_LOG(LogAnatomicalBrush, Warning, TEXT("Unknown brush type"));
break;
}
return true; // Temporarily return success, should return based on operation result after actual implementation
}
catch (const std::exception& e)
{
UE_LOG(LogAnatomicalBrush, Error, TEXT("ApplyToStaticMesh exception: %s"), UTF8_TO_TCHAR(e.what()));
return false;
}
catch (...)
{
UE_LOG(LogAnatomicalBrush, Error, TEXT("ApplyToStaticMesh unknown exception occurred"));
return false;
}
}
void UAnatomicalStructureBrush::SetBrushType(EAnatomicalBrushType BrushType)
{
BrushSettings.BrushType = BrushType;
UE_LOG(LogAnatomicalBrush, Log, TEXT("Brush type set to: %d"), (int32)BrushType);
}
void UAnatomicalStructureBrush::SetBrushSize(float Size)
{
BrushSettings.BrushSize = FMath::Clamp(Size, 0.1f, 100.0f);
UE_LOG(LogAnatomicalBrush, Log, TEXT("Brush size set to: %.2f"), BrushSettings.BrushSize);
}
void UAnatomicalStructureBrush::SetBrushStrength(float Strength)
{
BrushSettings.BrushStrength = FMath::Clamp(Strength, 0.0f, 1.0f);
UE_LOG(LogAnatomicalBrush, Log, TEXT("Brush strength set to: %.2f"), BrushSettings.BrushStrength);
}
FAnatomicalBrushSettings UAnatomicalStructureBrush::GetBrushSettings() const
@@ -54,13 +166,24 @@ FAnatomicalBrushSettings UAnatomicalStructureBrush::GetBrushSettings() const
UStaticMesh* UAnatomicalStructureBrush::CreateAnatomicalStructure(const FVector& Location, const FVector& Direction, float Size)
{
UE_LOG(LogAnatomicalBrush, Log, TEXT("Creating anatomical structure, Location: (%f, %f, %f), Size: %.2f"),
Location.X, Location.Y, Location.Z, Size);
// Implementation will be added in future updates
// This is a placeholder to resolve link errors
// This is a basic framework
return nullptr;
}
void UAnatomicalStructureBrush::ApplyPhysicsProperties(UStaticMesh* Mesh)
{
if (!Mesh)
{
UE_LOG(LogAnatomicalBrush, Error, TEXT("ApplyPhysicsProperties failed: Mesh is null"));
return;
}
UE_LOG(LogAnatomicalBrush, Log, TEXT("Applying physics properties to mesh %s"), *Mesh->GetName());
// Implementation will be added in future updates
// This is a placeholder to resolve link errors
// This is a basic framework
}

File diff suppressed because it is too large Load Diff

View File

@@ -5,4 +5,4 @@ UDismembermentGraph::UDismembermentGraph()
{
// Initialize default values
OwningAsset = nullptr;
}
}

View File

@@ -19,4 +19,4 @@ UObject* UDismembermentGraphEditorFactory::FactoryCreateNew(UClass* InClass, UOb
bool UDismembermentGraphEditorFactory::ShouldShowInNewMenu() const
{
return true;
}
}

File diff suppressed because it is too large Load Diff

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);
};