From 32b737a665a78ca0c36d2bef43a90f0ef90de822 Mon Sep 17 00:00:00 2001 From: BlueRose <378100977@qq.com> Date: Thu, 26 Jun 2025 18:45:36 +0800 Subject: [PATCH] vault backup: 2025-06-26 18:45:35 --- .../ShaderWorldPlugin/ShaderWorld.md | 97 ++++++++++++++++++- 1 file changed, 95 insertions(+), 2 deletions(-) diff --git a/03-UnrealEngine/Rendering/RenderFeature/ShaderWorldPlugin/ShaderWorld.md b/03-UnrealEngine/Rendering/RenderFeature/ShaderWorldPlugin/ShaderWorld.md index 36436e4..57e1e67 100644 --- a/03-UnrealEngine/Rendering/RenderFeature/ShaderWorldPlugin/ShaderWorld.md +++ b/03-UnrealEngine/Rendering/RenderFeature/ShaderWorldPlugin/ShaderWorld.md @@ -154,6 +154,22 @@ void AShaderWorldActor::ReadbacksManagement() ``` ### CollisionManagement() +- ThreadSafe + - bool + - bProcessingGroundCollision + - bPreprocessingCollisionUpdate + - EditRebuild:传递Bool值给 rebuild。 + - FSWCollisionManagementShareableData + - CollisionShareable + - FRenderCommandFence + - 1 +- bool + - RedbuildCollisionContext +- Array + - CollisionWorkQueue:类型为FCollisionProcessingWork。 + - CollisionReadToProcess + + ```c++ void AShaderWorldActor::CollisionManagement(float& DeltaT) { @@ -211,9 +227,86 @@ void AShaderWorldActor::CollisionManagement(float& DeltaT) } ``` -# - #### SetupCollisions() +```c++ +bool AShaderWorldActor::SetupCollisions() +{ + SW_FCT_CYCLE() + + if (!bHadGeneratorAtRebuildTime) + return false; + + if (!Shareable_ID.IsValid() || Meshes.Num() <= 0) + return false; + + //初始化线程安全变量 + if (!bProcessingGroundCollision.IsValid()) + bProcessingGroundCollision = MakeShared(); + if (!bPreprocessingCollisionUpdate.IsValid()) + bPreprocessingCollisionUpdate = MakeShared(); + + if (EditRebuild) + { + EditRebuild.AtomicSet(false); + rebuild = true; + } + + if (rebuild) + RedbuildCollisionContext = true; + //重建相关变量初始化 + if (RedbuildCollisionContext) + { + if (!(*bProcessingGroundCollision.Get()) && !(*bPreprocessingCollisionUpdate.Get()) + && CollisionProcess.IsFenceComplete() + && (CollisionMesh.Num() <= 0) + && (UsedCollisionMesh.Num() <= 0)) + { + + CollisionShareable = nullptr; + + CollisionWorkQueue.Empty(); + CollisionReadToProcess.Empty(); + + RedbuildCollisionContext = false; + + } + } + + if (RedbuildCollisionContext) + return false; + + if (!GenerateCollision) + return false; + + if (!CollisionShareable.IsValid()) + CollisionShareable = MakeShared(CollisionResolution, CollisionVerticesPerPatch); + + if ((*bProcessingGroundCollision.Get()) || (*bPreprocessingCollisionUpdate.Get()) || !CameraSet || (Meshes.Num() == 0)) + return false; + + //Let the data layer be computed before generating collisions and trying to extract material IDs + if (bExportPhysicalMaterialID && (WorldCycle < 2)) + return false; + + + if (CollisionVisibleChanged) + { + if (GetWorld()) + { + for (auto& ColM : CollisionMesh) + { + if (auto& Mesh = ColM.Value.Mesh) + { + Mesh->SetMeshSectionVisible(0, CollisionVisible); + } + } + } + CollisionVisibleChanged.AtomicSet(false); + } + + return true; +} +``` ### SpawnablesManagement()