Compare commits
18 Commits
39512c45b6
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 10e831efb9 | |||
| b079f682c9 | |||
| 1747eb7db7 | |||
| 8c27c82856 | |||
| f7882875c5 | |||
| 61016f9c2a | |||
| 5e237b8466 | |||
| de8b523c3d | |||
| 511f43f2c0 | |||
| bba161810a | |||
| e647723a7a | |||
| dd16f0123a | |||
| 33d0ff62de | |||
| 8bde527782 | |||
| 3ea9686964 | |||
| 0ee31987b5 | |||
| 13de51cf5c | |||
| 08d12c4d47 |
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"Bash(\"C:\\Program Files\\Epic Games\\UE_5.4\\Engine\\Build\\BatchFiles\\Build.bat\" BladeSmithEditor Win64 Development -Project=\"E:\\MiceCola\\work\\BladeSmith\\BladeSmith.uproject\" -WaitMutex -FromMsBuild)",
|
||||
"Bash(\"E:\\MiceCola\\work\\UE_5_6\\Engine\\Build\\BatchFiles\\Build.bat\" BladeSmithEditor Win64 Development \"-Project=E:\\MiceCola\\work\\BladeSmith\\BladeSmith.uproject\" -WaitMutex -FromMsBuild)",
|
||||
"Bash(\"E:\\MiceCola\\work\\UE_5_6\\Engine\\Build\\BatchFiles\\Build.bat\" BladeSmithEditor Win64 Development -Project=\"E:\\MiceCola\\work\\BladeSmith\\BladeSmith.uproject\" -WaitMutex -FromMsBuild)",
|
||||
"Bash(dir:*)",
|
||||
"Bash(git add:*)",
|
||||
"Bash(git commit -m \"$(cat <<''EOF''\n实现DynamicIronBlock温度体素系统基础功能\n\n新增功能:\n- 添加FTemperatureVoxel结构体(温度、塑性系数、表面标志)\n- 实现自适应温度网格(5mm体素精度,基于BoxSize计算分辨率)\n- 实现三线性插值温度/塑性系数采样\n- 实现黑体辐射温度可视化(顶点颜色)\n- 添加HeatRegion蓝图测试函数\n- 添加OnHammerImpact锤击形变函数(体积守恒)\n\n技术细节:\n- Phase 1: CPU侧温度网格初始化,支持10cm-100cm+可变尺寸\n- Phase 3: 温度可视化系统(20°C灰色 → 1200°C白色)\n- 内存占用:30×30×30cm ≈ 1.7MB(60×60×60体素)\n\n待实现:Phase 2 GPU热传导计算\n\n🤖 Generated with [Claude Code](https://claude.com/claude-code)\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n)\")",
|
||||
"Bash(git commit:*)",
|
||||
"Bash(\"E:\\MiceCola\\work\\UE_5_6\\Engine\\Build\\BatchFiles\\Build.bat\" BladeSmithEditor Win64 Development -Project=\"C:\\MiceCola\\Indi\\BladeSmith\\BladeSmith.uproject\" -WaitMutex -FromMsBuild)",
|
||||
"Bash(cmd /c:*)",
|
||||
"Bash(\"C:\\MiceCola\\Indi\\UE_5.6\\Engine\\Build\\BatchFiles\\Build.bat\" BladeSmithEditor Win64 Development \"-Project=C:\\MiceCola\\Indi\\BladeSmith\\BladeSmith.uproject\" -WaitMutex -FromMsBuild)",
|
||||
"Skill(superpowers:brainstorming)"
|
||||
],
|
||||
"deny": [],
|
||||
"ask": []
|
||||
}
|
||||
}
|
||||
@@ -74,3 +74,4 @@ Plugins/**/Intermediate/*
|
||||
# Cache files for the editor to use
|
||||
DerivedDataCache/*
|
||||
|
||||
nul
|
||||
@@ -0,0 +1,354 @@
|
||||
# BladeSmith Agent Development Guide
|
||||
|
||||
## Project Overview
|
||||
|
||||
BladeSmith is a UE5.6 C++ blacksmith simulation game featuring physics-based metal forging with GPU-accelerated compute shaders and dynamic mesh deformation.
|
||||
|
||||
**Core Technologies:**
|
||||
- Unreal Engine 5.6
|
||||
- Geometry Scripting API
|
||||
- Custom Compute Shaders (MiceShaders plugin)
|
||||
- Dynamic Mesh System
|
||||
- Enhanced Input
|
||||
- Voxel-based physics simulation
|
||||
|
||||
---
|
||||
|
||||
## Build Commands
|
||||
|
||||
### Building the Project
|
||||
```bash
|
||||
# Build game target (run from UE5 engine directory)
|
||||
"C:\Program Files\Epic Games\UE_5.6\Engine\Build\BatchFiles\Build.bat" BladeSmith Win64 Development "E:\MiceCola\work\BladeSmith\BladeSmith.uproject"
|
||||
|
||||
# Build editor target
|
||||
"C:\Program Files\Epic Games\UE_5.6\Engine\Build\BatchFiles\Build.bat" BladeSmithEditor Win64 Development "E:\MiceCola\work\BladeSmith\BladeSmith.uproject"
|
||||
|
||||
# Alternative: Open BladeSmith.sln in Visual Studio
|
||||
```
|
||||
|
||||
### Running Tests
|
||||
UE5 uses the Automation System, not traditional test runners:
|
||||
- **Editor**: Window → Developer Tools → Automation Sessions
|
||||
- **Command line**: `UE5Editor.exe BladeSmith.uproject -ExecCmds="Automation RunTests"`
|
||||
- **Single test**: Run specific test class from Automation Sessions panel
|
||||
|
||||
### Development Workflow
|
||||
1. Open `BladeSmith.uproject` in UE5.6 editor
|
||||
2. Use hot reload for C++ changes (Ctrl+F11 in editor)
|
||||
3. Test via "Play In Editor" (Alt+P)
|
||||
4. Use Visual Studio for compilation
|
||||
|
||||
---
|
||||
|
||||
## Code Style Guidelines
|
||||
|
||||
### File Structure
|
||||
- **Header files (.h)**: Class declarations, forward declarations, USTRUCT/UCLASS definitions
|
||||
- **Source files (.cpp)**: Implementations, includes in dependency order
|
||||
- **Shader files (.usf)**: HLSL compute shaders in `Plugins/MiceShaders/Shaders/Private/`
|
||||
|
||||
### Import Ordering
|
||||
|
||||
**Header Files:**
|
||||
```cpp
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "ProjectModule.generated.h"
|
||||
|
||||
class UForwardDeclaredClass; // Forward declarations
|
||||
```
|
||||
|
||||
**Source Files:**
|
||||
```cpp
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "ClassName.h"
|
||||
#include "SystemHeader1.h"
|
||||
#include "SystemHeader2.h"
|
||||
```
|
||||
|
||||
**Pattern:**
|
||||
1. Epic copyright header (required)
|
||||
2. `#pragma once` guard
|
||||
3. Core UE5 headers (`CoreMinimal.h` first)
|
||||
4. Engine framework headers
|
||||
5. Project headers
|
||||
6. Forward declarations (headers only)
|
||||
|
||||
### Naming Conventions
|
||||
|
||||
**Classes:** PascalCase with UE5 prefixes
|
||||
- `ABladeSmithCharacter` - Actor classes (A prefix)
|
||||
- `UBladeSmithWeaponComponent` - Component classes (U prefix)
|
||||
- `FDeformationVoxel` - Structs (F prefix)
|
||||
- `EGameStateEnum` - Enums (E prefix)
|
||||
|
||||
**Functions:** PascalCase
|
||||
```cpp
|
||||
public:
|
||||
void SwingHammer();
|
||||
FVector GetHammerHeadLocation() const;
|
||||
|
||||
private:
|
||||
void PerformHammerHit(); // Private helpers use PascalCase
|
||||
```
|
||||
|
||||
**Variables:** camelCase
|
||||
```cpp
|
||||
float HammerForce = 1000.0f;
|
||||
FVector HammerHeadOffset;
|
||||
UMaterialInstanceDynamic* DynamicMaterialInstance;
|
||||
TArray<FTemperatureVoxel> TemperatureGrid;
|
||||
```
|
||||
|
||||
**Constants:** PascalCase
|
||||
```cpp
|
||||
const int32 MaxResolutionPerAxis = 200;
|
||||
const float DefaultTemperature = 20.0f;
|
||||
```
|
||||
|
||||
### Formatting
|
||||
|
||||
**Indentation:** 4 spaces (no tabs)
|
||||
**Braces:** Allman style - opening brace on new line
|
||||
```cpp
|
||||
void ABladeSmithCharacter::Move(const FInputActionValue& Value)
|
||||
{
|
||||
FVector2D MovementVector = Value.Get<FVector2D>();
|
||||
// implementation
|
||||
}
|
||||
```
|
||||
|
||||
**Line Length:** Under 120 characters, wrap parameters as needed
|
||||
**Spacing:** Spaces around operators, after commas
|
||||
|
||||
### UE5 Macros and Attributes
|
||||
|
||||
**UPROPERTY Specifiers:**
|
||||
```cpp
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Category")
|
||||
UPropertyType* VariableName;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Category|Subcategory", meta = (ClampMin = "0.0", ClampMax = "1.0"))
|
||||
float PropertyWithConstraints;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Category", meta = (AllowPrivateAccess = "true"))
|
||||
UComponentType* PrivateComponent;
|
||||
```
|
||||
|
||||
**UFUNCTION Specifiers:**
|
||||
```cpp
|
||||
UFUNCTION(BlueprintCallable, Category = "Category Name")
|
||||
ReturnType FunctionName(Parameters);
|
||||
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void BlueprintEventName();
|
||||
```
|
||||
|
||||
**USTRUCT:**
|
||||
```cpp
|
||||
USTRUCT(BlueprintType)
|
||||
struct FStructName
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY()
|
||||
Type VariableName;
|
||||
};
|
||||
```
|
||||
|
||||
### Type Annotations
|
||||
|
||||
**UE5 Types (preferred):**
|
||||
- `TArray<T>` instead of std::vector
|
||||
- `TMap<TKey, TValue>` instead of std::map
|
||||
- `TSet<T>` instead of std::unordered_set
|
||||
- `FVector`, `FVector2D`, `FRotator`, `FQuat` for math
|
||||
- `FString` for strings (TEXT() macro for string literals)
|
||||
- `FName` for names, `FText` for localized text
|
||||
- `float` not double (unless precision critical)
|
||||
- `int32` not int, `uint8` for bytes
|
||||
- `bool` for booleans
|
||||
|
||||
**Smart Pointers:**
|
||||
- Use UE5's garbage collection for UObject-derived classes
|
||||
- `TSharedPtr<T>` for non-UObject smart pointers
|
||||
- `TWeakObjectPtr<T>` for weak references to UObjects
|
||||
|
||||
### Error Handling
|
||||
|
||||
**Null Checks:**
|
||||
```cpp
|
||||
if (DynamicMeshComp == nullptr)
|
||||
{
|
||||
UE_LOG(LogTemp, Error, TEXT("DynamicMeshComponent not found"));
|
||||
return;
|
||||
}
|
||||
```
|
||||
|
||||
**Logging:**
|
||||
```cpp
|
||||
UE_LOG(LogTemp, Log, TEXT("Temperature: %.1f°C"), Temperature); // Info
|
||||
UE_LOG(LogTemp, Warning, TEXT("Temperature system disabled")); // Warning
|
||||
UE_LOG(LogTemp, Error, TEXT("Failed to initialize GPU buffers")); // Error
|
||||
```
|
||||
|
||||
**Validation:**
|
||||
```cpp
|
||||
if (!IsValid(InputParam))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Early return pattern
|
||||
if (Condition)
|
||||
{
|
||||
return;
|
||||
}
|
||||
```
|
||||
|
||||
### Documentation
|
||||
|
||||
**Chinese Comments:** Domain-specific logic uses Chinese comments
|
||||
```cpp
|
||||
/** 锤子组件 */
|
||||
/** 温度体素结构 - 存储单个体素的温度和塑性数据 */
|
||||
```
|
||||
|
||||
**Function Documentation:**
|
||||
```cpp
|
||||
/**
|
||||
* 函数简述
|
||||
* @param ParameterName 参数说明
|
||||
* @return 返回值说明
|
||||
*/
|
||||
```
|
||||
|
||||
### Threading and GPU Operations
|
||||
|
||||
**Atomic Flags:**
|
||||
```cpp
|
||||
std::atomic<bool> bGPUBuffersReady{false};
|
||||
```
|
||||
|
||||
**Render Thread Operations:**
|
||||
```cpp
|
||||
ENQUEUE_RENDER_COMMAND(CommandName)(
|
||||
[Params](FRHICommandListImmediate& RHICmdList)
|
||||
{
|
||||
// GPU operations here
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
### Component Structure Pattern
|
||||
|
||||
**Actor Template:**
|
||||
```cpp
|
||||
UCLASS()
|
||||
class BLADESMITH_API AClassName : public AParentClass
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
AClassName();
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Category")
|
||||
UComponentType* Component;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Category")
|
||||
ReturnType PublicFunction();
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
private:
|
||||
void PrivateHelper();
|
||||
};
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Module Dependencies
|
||||
|
||||
**BladeSmith.Build.cs:**
|
||||
- GeometryScriptingCore, GeometryFramework, DynamicMesh
|
||||
- GeometryCore, GeometryAlgorithms, ModelingComponents
|
||||
- RenderCore, RHI, Renderer, PhysicsCore
|
||||
- EnhancedInput, AudioExtensions, AudioMixer
|
||||
- Custom: MiceShaders (plugin)
|
||||
|
||||
---
|
||||
|
||||
## Performance Guidelines
|
||||
|
||||
- **Deformation calculations:** <7ms per frame target
|
||||
- **60 FPS:** Maintain during hammer operations
|
||||
- **High-poly meshes:** ~100k vertices with GPU acceleration
|
||||
- **Voxel resolution:** 50x50x50 typical (balance performance/quality)
|
||||
- **Use RDG (Render Dependency Graph)** for GPU compute operations
|
||||
|
||||
---
|
||||
|
||||
## Common Patterns
|
||||
|
||||
**Material Parameters:**
|
||||
```cpp
|
||||
UMaterialInstanceDynamic* DynMaterial = UMaterialInstanceDynamic::Create(BaseMaterial, this);
|
||||
DynMaterial->SetScalarParameterValue(TEXT("ParameterName"), Value);
|
||||
DynMaterial->SetVectorParameterValue(TEXT("VectorParam"), FLinearColor(R,G,B,A));
|
||||
DynMaterial->SetTextureParameterValue(TEXT("TextureParam"), Texture);
|
||||
```
|
||||
|
||||
**Dynamic Mesh Editing:**
|
||||
```cpp
|
||||
UDynamicMesh* DynMesh = DynMeshComp->GetDynamicMesh();
|
||||
DynMesh->EditMesh([&](FDynamicMesh3& EditMesh)
|
||||
{
|
||||
for (FVertexID VertexID : EditMesh.VertexIndicesItr())
|
||||
{
|
||||
EditMesh.SetVertex(VertexID, NewPosition);
|
||||
}
|
||||
}, EDynamicMeshChangeType::GeneralEdit);
|
||||
```
|
||||
|
||||
**Input Binding (Enhanced Input):**
|
||||
```cpp
|
||||
if (UEnhancedInputComponent* EnhancedInput = Cast<UEnhancedInputComponent>(InputComponent))
|
||||
{
|
||||
EnhancedInput->BindAction(Action, ETriggerEvent::Triggered, this, &ClassName::Handler);
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Plugin System
|
||||
|
||||
**MiceShaders Plugin:**
|
||||
- Custom compute shaders for temperature simulation and deformation
|
||||
- Located in `Plugins/MiceShaders/`
|
||||
- Add new shaders: Create `.h` and `.cpp` in Source/MiceShaders, HLSL in Shaders/Private/
|
||||
- Use RDG for shader dispatch
|
||||
|
||||
---
|
||||
|
||||
## Git Workflow
|
||||
|
||||
- **Ignore:** `Binaries/`, `Intermediate/`, `DerivedDataCache/`, `Saved/`, `.vs/`, `.idea/`
|
||||
- **Commit:** Source/, Content/, Plugins/, Config/, docs/
|
||||
- **No binary assets** in Git (use version control for assets)
|
||||
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
**Technical docs:** Located in `docs/plans/`
|
||||
- Reference existing design docs before implementing new features
|
||||
- Update plans when architecture changes
|
||||
- Use markdown for design documents
|
||||
@@ -0,0 +1,12 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=657466D1_002D2409_002D3196_002D8BA9_002D4914CBD968CC_002Fdl_003ASource_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUE_005F5_002E6_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003AEngine_002Fd_003APublic_002Fd_003AMaterials_002Ff_003AMaterialExpressionBlackBody_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADanyxuq_002Easm_002Fl_003AC_0021_003FUsers_003Fstarm_003FAppData_003FLocal_003FTemp_003FSandboxFiles_003FRewuwer_003FDanyxuq_002Easm/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADycuvaq_002Easm_002Fl_003AC_0021_003FUsers_003Fstarm_003FAppData_003FLocal_003FTemp_003FSandboxFiles_003FWoqosub_003FDycuvaq_002Easm/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFunction_002Eh_002Fl_003AD_0021_003FProgram_0020Files_003FEpic_0020Games_003FUE_005F5_002E6_003FEngine_003FSource_003FRuntime_003FCore_003FPublic_003FTemplates_003FFunction_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASaryqah_002Easm_002Fl_003AC_0021_003FUsers_003Fstarm_003FAppData_003FLocal_003FTemp_003FSandboxFiles_003FZexazuc_003FSaryqah_002Easm/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATedilij_002Easm_002Fl_003AC_0021_003FUsers_003Fstarm_003FAppData_003FLocal_003FTemp_003FSandboxFiles_003FKotyxod_003FTedilij_002Easm/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATextureDefines_002Eh_002Fl_003AD_0021_003FProgram_0020Files_003FEpic_0020Games_003FUE_005F5_002E6_003FEngine_003FSource_003FRuntime_003FEngine_003FClasses_003FEngine_003FTextureDefines_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AShaderParameterStruct_002Eh_002Fl_003AD_0021_003FProgram_0020Files_003FEpic_0020Games_003FUE_005F5_002E6_003FEngine_003FSource_003FRuntime_003FRenderCore_003FPublic_003FShaderParameterStruct_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATuvased_002Easm_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003FAdministrator_003FAppData_003FLocal_003FTemp_003FSandboxFiles_003FKonywix_003FTuvased_002Easm/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AUnrealMathUtility_002Eh_002Fl_003AD_0021_003FProgram_0020Files_003FEpic_0020Games_003FUE_005F5_002E6_003FEngine_003FSource_003FRuntime_003FCore_003FPublic_003FMath_003FUnrealMathUtility_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AArray_002Eh_002Fl_003AD_0021_003FProgram_0020Files_003FEpic_0020Games_003FUE_005F5_002E6_003FEngine_003FSource_003FRuntime_003FCore_003FPublic_003FContainers_003FArray_002Eh/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
|
||||
@@ -0,0 +1,239 @@
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Project Overview
|
||||
|
||||
BladeSmith is an Unreal Engine 5.6 C++ blacksmith simulation game where players forge bladed weapons through realistic physical processes. The core feature is GPU-accelerated plastic deformation of metal using compute shaders, combined with a voxel-based temperature system that determines material plasticity.
|
||||
|
||||
**Engine Version:** UE 5.6
|
||||
**Language:** C++ with Blueprint integration
|
||||
**Platform:** Windows (primary development target)
|
||||
|
||||
## Build and Development Commands
|
||||
|
||||
### Building the Project
|
||||
|
||||
From the UE5 engine directory:
|
||||
```bash
|
||||
# Build game target
|
||||
"C:\Program Files\Epic Games\UE_5.6\Engine\Build\BatchFiles\Build.bat" BladeSmith Win64 Development "E:\MiceCola\work\BladeSmith\BladeSmith.uproject"
|
||||
|
||||
# Build editor target
|
||||
"C:\Program Files\Epic Games\UE_5.6\Engine\Build\BatchFiles\Build.bat" BladeSmithEditor Win64 Development "E:\MiceCola\work\BladeSmith\BladeSmith.uproject"
|
||||
```
|
||||
|
||||
Alternatively, open `BladeSmith.sln` in Visual Studio and build from there.
|
||||
|
||||
### Running the Project
|
||||
|
||||
1. Open `BladeSmith.uproject` in UE5.6 Editor
|
||||
2. Press Alt+P or click Play to run in editor
|
||||
3. Use Ctrl+F11 for hot reload after C++ changes
|
||||
|
||||
### Testing
|
||||
|
||||
Unreal Engine uses the Automation System:
|
||||
- **In Editor:** Window → Developer Tools → Automation Sessions
|
||||
- **Command Line:** `UE5Editor.exe BladeSmith.uproject -ExecCmds="Automation RunTests"`
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
### Core Systems
|
||||
|
||||
**1. Dynamic Mesh Deformation System**
|
||||
- `ADynamicIronBlock` (Source/BladeSmith/DynamicIronBlock.h/cpp) - Main iron block actor that handles all deformation
|
||||
- Uses UE5's GeometryScripting API for runtime mesh manipulation
|
||||
- Implements plastic deformation with volume-preserving bulge effects
|
||||
- BVH acceleration structure for efficient collision detection
|
||||
|
||||
**2. Voxel-Based Temperature System**
|
||||
- 3D temperature voxel grid (`FTemperatureVoxel`) stores temperature and plasticity coefficients
|
||||
- Temperature affects material plasticity: 800-1200°C is the forging range
|
||||
- Heat conduction simulation with surface cooling
|
||||
- Per-vertex color visualization of temperature (black body radiation approximation)
|
||||
- GPU-accelerated temperature computation using ping-pong buffers
|
||||
|
||||
**3. GPU Compute Pipeline (MiceShaders Plugin)**
|
||||
- Custom compute shaders for physics simulation
|
||||
- `FDeformComputeShader` - Plastic deformation calculations
|
||||
- `FTemperatureComputeShader` - Heat conduction and cooling
|
||||
- Located in `Plugins/MiceShaders/`
|
||||
- Shaders written in HLSL (`.usf` files in `Shaders/Private/`)
|
||||
- Uses RDG (Render Dependency Graph) for GPU dispatch
|
||||
|
||||
**4. Hammer Interaction System**
|
||||
- `UBladeSmithWeaponComponent` (Source/BladeSmith/BladeSmithWeaponComponent.h/cpp) - First-person hammer tool
|
||||
- Ray-cast based collision detection
|
||||
- Enhanced Input system integration
|
||||
- Triggers deformation on `ADynamicIronBlock` via `OnHammerImpact()`
|
||||
|
||||
### Key Classes and Their Relationships
|
||||
|
||||
```
|
||||
ABladeSmithCharacter (Player)
|
||||
└── UBladeSmithWeaponComponent (Hammer Tool)
|
||||
└── OnHammerImpact()
|
||||
└── ADynamicIronBlock (Iron Workpiece)
|
||||
├── Temperature Voxel Grid (CPU/GPU)
|
||||
├── Dynamic Mesh (GeometryScripting)
|
||||
└── MiceShaders Compute Shaders
|
||||
```
|
||||
|
||||
### Data Flow: Hammer Impact to Deformation
|
||||
|
||||
1. Player swings hammer (`UBladeSmithWeaponComponent::SwingHammer()`)
|
||||
2. Ray-cast detects hit on `ADynamicIronBlock`
|
||||
3. `OnHammerImpact()` receives: location, normal, radius, depth, force
|
||||
4. Sample plasticity coefficient from temperature voxels at hit location
|
||||
5. Apply plastic deformation to mesh vertices via `EditMesh()` lambda
|
||||
6. Volume-preserving bulge effect applied around impact zone
|
||||
7. Update vertex colors to visualize temperature
|
||||
8. GPU compute shader updates temperature distribution
|
||||
|
||||
## Module Dependencies
|
||||
|
||||
**BladeSmith Module (Source/BladeSmith/BladeSmith.Build.cs):**
|
||||
- GeometryScriptingCore, GeometryFramework, DynamicMesh
|
||||
- GeometryCore, GeometryAlgorithms, ModelingComponents
|
||||
- RenderCore, RHI, Renderer, PhysicsCore
|
||||
- EnhancedInput
|
||||
- AudioExtensions, AudioMixer, AudioPlatformConfiguration
|
||||
- **MiceShaders** (custom plugin)
|
||||
|
||||
**MiceShaders Plugin:**
|
||||
- Core, RenderCore, RHI
|
||||
- Projects (for shader path resolution)
|
||||
|
||||
## Code Conventions
|
||||
|
||||
### File Headers
|
||||
All source files must start with Epic copyright notice (as required by UE5 licensing).
|
||||
|
||||
### Naming Conventions
|
||||
- **Actors:** `AClassName` (e.g., `ADynamicIronBlock`)
|
||||
- **Components:** `UClassName` (e.g., `UBladeSmithWeaponComponent`)
|
||||
- **Structs:** `FStructName` (e.g., `FTemperatureVoxel`)
|
||||
- **Enums:** `EEnumName`
|
||||
- **Functions:** PascalCase (e.g., `OnHammerImpact()`)
|
||||
- **Variables:** PascalCase for properties, camelCase for locals
|
||||
- **Constants:** PascalCase
|
||||
|
||||
### Type Usage
|
||||
- Use UE5 types: `TArray<T>`, `TMap<K,V>`, `TSet<T>`, `FVector`, `FString`, `int32`, `uint8`
|
||||
- Use `float` by default (not `double`)
|
||||
- Smart pointers: rely on UObject garbage collection; use `TSharedPtr<T>` for non-UObjects
|
||||
- String literals: wrap in `TEXT()` macro
|
||||
|
||||
### Indentation and Formatting
|
||||
- **4 spaces** (no tabs)
|
||||
- **Allman style braces** (opening brace on new line)
|
||||
- Line length under 120 characters
|
||||
|
||||
### Threading and GPU Operations
|
||||
```cpp
|
||||
// Atomic flags for thread-safe GPU buffer status
|
||||
std::atomic<bool> bGPUBuffersReady{false};
|
||||
|
||||
// Render thread commands
|
||||
ENQUEUE_RENDER_COMMAND(CommandName)(
|
||||
[Params](FRHICommandListImmediate& RHICmdList)
|
||||
{
|
||||
// GPU operations here
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
### Documentation
|
||||
Comments use Chinese for domain-specific logic (e.g., "锤子组件", "温度体素结构").
|
||||
|
||||
## Important Implementation Details
|
||||
|
||||
### Temperature-Plasticity Relationship
|
||||
- Plasticity = 0 below `ForgeTemperatureMin` (800°C by default)
|
||||
- Plasticity = 1 above `ForgeTemperatureMax` (1200°C by default)
|
||||
- Linear interpolation between min and max
|
||||
- Deformation depth is multiplied by plasticity coefficient
|
||||
|
||||
### Deformation Parameters
|
||||
- `FalloffExponent`: Controls edge transition smoothness (default: 2.0)
|
||||
- `BulgeRatio`: Bulge radius relative to compression zone (default: 0.8)
|
||||
- `BulgeStrength`: Bulge height intensity (default: 0.5)
|
||||
- These simulate realistic plastic flow and volume conservation
|
||||
|
||||
### Vertex Color Mapping
|
||||
- Each vertex samples temperature from voxel grid via trilinear interpolation
|
||||
- Temperature is converted to color using black body radiation approximation
|
||||
- Updated every frame when temperature changes occur
|
||||
|
||||
### GPU Buffer Management
|
||||
- Uses ping-pong double buffering for temperature compute shader
|
||||
- `TemperatureBufferA` and `TemperatureBufferB` alternate as read/write buffers
|
||||
- Separate `PlasticityBuffer` stores derived plasticity coefficients
|
||||
- `SurfaceVoxelFlagsBuffer` marks surface voxels for cooling calculations
|
||||
- Buffers created on render thread, accessed via UAV/SRV
|
||||
|
||||
## Performance Targets
|
||||
|
||||
- **Frame time budget:** <7ms for deformation calculations
|
||||
- **Target FPS:** 60 FPS during hammer operations
|
||||
- **Mesh complexity:** Tested with ~100k vertices using GPU acceleration
|
||||
- **Voxel resolution:** 50x50x50 typical (configurable via `TemperatureVoxelSize`)
|
||||
|
||||
## Adding New Compute Shaders
|
||||
|
||||
1. Create `.h` and `.cpp` in `Plugins/MiceShaders/Source/MiceShaders/Public|Private/`
|
||||
2. Define shader class inheriting from `FGlobalShader`
|
||||
3. Create corresponding `.usf` HLSL shader in `Plugins/MiceShaders/Shaders/Private/`
|
||||
4. Use `IMPLEMENT_GLOBAL_SHADER()` macro to register
|
||||
5. Dispatch via RDG in actor's Tick or specialized function
|
||||
6. Reference existing shaders: `FDeformComputeShader`, `FTemperatureComputeShader`
|
||||
|
||||
## Key UE5 Patterns Used
|
||||
|
||||
**Dynamic Mesh Editing:**
|
||||
```cpp
|
||||
DynamicMesh->EditMesh([&](FDynamicMesh3& EditMesh)
|
||||
{
|
||||
// Modify mesh vertices/triangles here
|
||||
}, EDynamicMeshChangeType::GeneralEdit);
|
||||
```
|
||||
|
||||
**Material Parameter Updates:**
|
||||
```cpp
|
||||
DynamicMaterialInstance->SetScalarParameterValue(TEXT("AvgTemperature"), AvgTemp);
|
||||
DynamicMaterialInstance->SetVectorParameterValue(TEXT("Color"), FLinearColor(R,G,B,A));
|
||||
```
|
||||
|
||||
**Enhanced Input Binding:**
|
||||
```cpp
|
||||
if (UEnhancedInputComponent* EnhancedInput = Cast<UEnhancedInputComponent>(InputComponent))
|
||||
{
|
||||
EnhancedInput->BindAction(HammerAction, ETriggerEvent::Triggered, this, &ThisClass::SwingHammer);
|
||||
}
|
||||
```
|
||||
|
||||
## Plugin Structure
|
||||
|
||||
**Enabled Plugins (BladeSmith.uproject):**
|
||||
- GeometryScripting (UE5 built-in)
|
||||
- ModelingToolsEditorMode (UE5 built-in)
|
||||
- HDRIBackdrop (UE5 built-in)
|
||||
- RiderLink (in repository, for JetBrains Rider integration)
|
||||
- MiceShaders (custom plugin)
|
||||
|
||||
## Content Organization
|
||||
|
||||
- `Content/BP/` - Blueprint actors and components
|
||||
- `Content/Res/` - Game resources (meshes, materials, textures)
|
||||
- `Content/Maps/` - Level maps
|
||||
- `Content/Input/` - Enhanced Input assets
|
||||
- `Content/FirstPersonArms/`, `Content/FPWeapon/` - First-person character assets
|
||||
|
||||
## Notes for AI Agents
|
||||
|
||||
- The AGENTS.md file contains comprehensive coding style guidelines; refer to it for detailed conventions
|
||||
- When modifying deformation logic, always consider the temperature-plasticity coupling
|
||||
- GPU buffer operations must be thread-safe; use atomic flags and render thread commands
|
||||
- Test deformation with varying temperatures to ensure plasticity affects results correctly
|
||||
- Voxel resolution trades off between accuracy and performance; adjust `TemperatureVoxelSize` accordingly
|
||||
@@ -38,6 +38,7 @@ r.DefaultFeature.LocalExposure.HighlightContrastScale=0.8
|
||||
|
||||
r.DefaultFeature.LocalExposure.ShadowContrastScale=0.8
|
||||
r.DefaultFeature.AutoExposure=False
|
||||
r.Lumen.TraceMeshSDFs=1
|
||||
|
||||
[/Script/WindowsTargetPlatform.WindowsTargetSettings]
|
||||
DefaultGraphicsRHI=DefaultGraphicsRHI_DX12
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user