实现敲击凹陷
This commit is contained in:
@@ -1,13 +0,0 @@
|
|||||||
<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/=436DC2F9_002D640A_002D357F_002D8A01_002D8B10A58FB273_002Fdl_003ASource_003AD_0021_003FProgram_0020Files_003FEpic_0020Games_003FUE_005F5_002E6_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003ACore_002Fd_003APublic_002Fd_003AContainers_002Ff_003AArray_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=436DC2F9_002D640A_002D357F_002D8A01_002D8B10A58FB273_002Fdl_003ASource_003AD_0021_003FProgram_0020Files_003FEpic_0020Games_003FUE_005F5_002E6_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003ACore_002Fd_003APublic_002Fd_003AGenericPlatform_002Ff_003AGenericPlatformMemory_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=436DC2F9_002D640A_002D357F_002D8A01_002D8B10A58FB273_002Fdl_003ASource_003AD_0021_003FProgram_0020Files_003FEpic_0020Games_003FUE_005F5_002E6_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003ACore_002Fd_003APublic_002Fd_003AMath_002Ff_003AUnrealMathUtility_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=436DC2F9_002D640A_002D357F_002D8A01_002D8B10A58FB273_002Fdl_003ASource_003AD_0021_003FProgram_0020Files_003FEpic_0020Games_003FUE_005F5_002E6_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003ACore_002Fd_003APublic_002Fd_003ATemplates_002Ff_003AFunction_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=436DC2F9_002D640A_002D357F_002D8A01_002D8B10A58FB273_002Fdl_003ASource_003AD_0021_003FProgram_0020Files_003FEpic_0020Games_003FUE_005F5_002E6_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003ACore_002Fd_003APublic_002Fd_003ATemplates_002Ff_003ASharedPointer_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=436DC2F9_002D640A_002D357F_002D8A01_002D8B10A58FB273_002Fdl_003ASource_003AD_0021_003FProgram_0020Files_003FEpic_0020Games_003FUE_005F5_002E6_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003AEngine_002Fd_003AClasses_002Fd_003AEngine_002Ff_003ATextureDefines_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=436DC2F9_002D640A_002D357F_002D8A01_002D8B10A58FB273_002Fdl_003ASource_003AD_0021_003FProgram_0020Files_003FEpic_0020Games_003FUE_005F5_002E6_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003ARenderCore_002Fd_003APublic_002Ff_003AGlobalShader_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=436DC2F9_002D640A_002D357F_002D8A01_002D8B10A58FB273_002Fdl_003ASource_003AD_0021_003FProgram_0020Files_003FEpic_0020Games_003FUE_005F5_002E6_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003ARenderCore_002Fd_003APublic_002Ff_003AShader_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=436DC2F9_002D640A_002D357F_002D8A01_002D8B10A58FB273_002Fdl_003ASource_003AD_0021_003FProgram_0020Files_003FEpic_0020Games_003FUE_005F5_002E6_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003ARenderCore_002Fd_003APublic_002Ff_003AShaderParameterStruct_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACaxobyt_002Easm_002Fl_003AC_0021_003FUsers_003Fstarm_003FAppData_003FLocal_003FTemp_003FSandboxFiles_003FGasofan_003FCaxobyt_002Easm/@EntryIndexedValue">ForceIncluded</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASizibap_002Easm_002Fl_003AC_0021_003FUsers_003Fstarm_003FAppData_003FLocal_003FTemp_003FSandboxFiles_003FRomujif_003FSizibap_002Easm/@EntryIndexedValue">ForceIncluded</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AZukimes_002Easm_002Fl_003AC_0021_003FUsers_003Fstarm_003FAppData_003FLocal_003FTemp_003FSandboxFiles_003FGoryhes_003FZukimes_002Easm/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
|
|
||||||
Binary file not shown.
Binary file not shown.
@@ -6,6 +6,7 @@ public class BladeSmith : ModuleRules
|
|||||||
{
|
{
|
||||||
public BladeSmith(ReadOnlyTargetRules Target) : base(Target)
|
public BladeSmith(ReadOnlyTargetRules Target) : base(Target)
|
||||||
{
|
{
|
||||||
|
PrivateDependencyModuleNames.AddRange(new string[] { "GeometryScriptingCore" });
|
||||||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||||
|
|
||||||
// 如果你的模块类型是 Runtime 或 Gameplay 相关的,则添加这行:
|
// 如果你的模块类型是 Runtime 或 Gameplay 相关的,则添加这行:
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "GeometryScript/GeometryScriptSelectionTypes.h"
|
||||||
|
#include "GeometryScript/MeshDeformFunctions.h"
|
||||||
|
#include "GeometryScript/MeshSpatialFunctions.h"
|
||||||
|
#include "GeometryScript/MeshTransformFunctions.h"
|
||||||
|
#include "Kismet/BlueprintAsyncActionBase.h"
|
||||||
|
#include "DeformAsyncTask.generated.h"
|
||||||
|
|
||||||
|
|
||||||
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnDeformFinished, bool, ResultValue);
|
||||||
|
// .h 文件
|
||||||
|
UCLASS()
|
||||||
|
class UDeformAsyncTask : public UBlueprintAsyncActionBase
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
// 暴露给蓝图的静态工厂方法
|
||||||
|
UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true", Category = "AsyncTask", WorldContext = "WorldContextObject"))
|
||||||
|
static UDeformAsyncTask* StartCalculation(UObject* WorldContextObject,FGeometryScriptMeshSelection& InSelection,FVector& InLocalHitLocation,FVector& InLocaHitNormal);
|
||||||
|
|
||||||
|
// 成功回调引脚 (在游戏线程触发)
|
||||||
|
UPROPERTY(BlueprintAssignable)
|
||||||
|
FOnDeformFinished OnDeformFinish;
|
||||||
|
|
||||||
|
virtual void Activate() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
FGeometryScriptMeshSelection Selection;
|
||||||
|
FVector LocalHitLocation;
|
||||||
|
FVector LocaHitNormal;
|
||||||
|
// 核心计算逻辑,在工作线程中执行
|
||||||
|
void PerformBackgroundCalculation();
|
||||||
|
};
|
||||||
|
|
||||||
|
inline UDeformAsyncTask* UDeformAsyncTask::StartCalculation(UObject* WorldContextObject,
|
||||||
|
FGeometryScriptMeshSelection& InSelection, FVector& InLocalHitLocation, FVector& InLocaHitNormal)
|
||||||
|
{
|
||||||
|
// 1. 检查 WorldContextObject 是否有效,这是异步操作节点的标准做法
|
||||||
|
if (!WorldContextObject || !WorldContextObject->GetWorld())
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 创建 UCalculateAsyncTask 的实例
|
||||||
|
// 使用 NewObject 而非 new,以确保对象被 UE 的内存管理系统(GC)追踪
|
||||||
|
UDeformAsyncTask* Task = NewObject<UDeformAsyncTask>();
|
||||||
|
|
||||||
|
// 3. 存储输入参数
|
||||||
|
Task->Selection = InSelection;
|
||||||
|
Task->LocalHitLocation = InLocalHitLocation;
|
||||||
|
Task->LocaHitNormal = InLocaHitNormal;
|
||||||
|
|
||||||
|
// 4. 将实例的生命周期与 WorldContextObject 绑定,确保在关卡卸载时它能被回收
|
||||||
|
Task->RegisterWithGameInstance(WorldContextObject);
|
||||||
|
|
||||||
|
// 5. 调用 Activate() 启动实际的后台逻辑
|
||||||
|
// Activate() 才是真正执行后台任务的地方
|
||||||
|
Task->Activate();
|
||||||
|
|
||||||
|
// 6. 返回实例,在蓝图节点上显示回调引脚
|
||||||
|
return Task;
|
||||||
|
}
|
||||||
|
|
||||||
|
// .cpp 文件(在 Activate 中启动后台任务)
|
||||||
|
inline void UDeformAsyncTask::Activate()
|
||||||
|
{
|
||||||
|
// 启动一个后台任务,使用 UE 的 Task Graph
|
||||||
|
// 这里的 lambda 函数会在工作线程上运行
|
||||||
|
(new FAutoDeleteAsyncTask<TFunction<void()>>(
|
||||||
|
[this]()
|
||||||
|
{
|
||||||
|
PerformBackgroundCalculation(); // 耗时的计算在这里执行
|
||||||
|
|
||||||
|
// 切换回游戏线程执行回调
|
||||||
|
FFunctionGraphTask::CreateAndDispatchWhenReady(
|
||||||
|
[this]()
|
||||||
|
{
|
||||||
|
if (IsValid(this))
|
||||||
|
{
|
||||||
|
// 确保在游戏线程上触发蓝图回调
|
||||||
|
OnDeformFinish.Broadcast(true);
|
||||||
|
SetReadyToDestroy();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
TStatId(),
|
||||||
|
nullptr,
|
||||||
|
ENamedThreads::GameThread // 确保在游戏线程回调
|
||||||
|
);
|
||||||
|
}
|
||||||
|
))->StartBackgroundTask();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void UDeformAsyncTask::PerformBackgroundCalculation()
|
||||||
|
{
|
||||||
|
UGeometryScriptLibrary_MeshTransformFunctions::TranslateMeshSelection()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user