vault backup: 2025-07-14 17:51:44
This commit is contained in:
parent
6d9b688f0f
commit
990d1ff0bc
@ -155,7 +155,7 @@ void AShaderWorldActor::ReadbacksManagement()
|
|||||||
### CollisionManagement()
|
### CollisionManagement()
|
||||||
- ThreadSafe
|
- ThreadSafe
|
||||||
- bool
|
- bool
|
||||||
- bProcessingGroundCollision
|
- ***bProcessingGroundCollision***:处理地面碰撞。
|
||||||
- bPreprocessingCollisionUpdate
|
- bPreprocessingCollisionUpdate
|
||||||
- EditRebuild:传递Bool值给 rebuild。
|
- EditRebuild:传递Bool值给 rebuild。
|
||||||
- FSWCollisionManagementShareableData
|
- FSWCollisionManagementShareableData
|
||||||
@ -310,8 +310,8 @@ bool AShaderWorldActor::SetupCollisions()
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### CollisionFinalizeWork()
|
#### CollisionFinalizeWork() 笔记为3.8.6版本非最新
|
||||||
结束碰撞生成任务,true为完成,false为任务超时未完成。
|
结束碰撞生成任务,true为完成,false为任务超时未完成。**主要的逻辑是将之前的数据设置为脏,并且更新FShaderWProceduralMeshSceneProxy,5.4 Finaly版本里这里已经移除了碰撞相关逻辑**
|
||||||
- TMap<FName,FCollisionMeshElement> CollisionMesh:碰撞Name => 碰撞Mesh Map。
|
- TMap<FName,FCollisionMeshElement> CollisionMesh:碰撞Name => 碰撞Mesh Map。
|
||||||
- FCollisionMeshElement:管理单个碰撞数据的结构体。
|
- FCollisionMeshElement:管理单个碰撞数据的结构体。
|
||||||
- UBodySetup:虚幻引擎中一个重要的物理相关类,主要用于定义和存储物体的物理属性和碰撞设置
|
- UBodySetup:虚幻引擎中一个重要的物理相关类,主要用于定义和存储物体的物理属性和碰撞设置
|
||||||
@ -455,6 +455,8 @@ void UShaderWorldCollisionComponent::UpdateSectionTriMesh(TSharedPtr<FSWShareabl
|
|||||||
|
|
||||||
#### CollisionPreprocessGPU()
|
#### CollisionPreprocessGPU()
|
||||||
GPU生成碰撞 的预处理阶段。
|
GPU生成碰撞 的预处理阶段。
|
||||||
|
将从GPU回读的碰撞顶点Z轴数据***uint8* ReadData8*** 反序列化成double,之后再还原成***FCollisionProcessingWork.DestB***的Positions、Normals、Positions3f、MaterialIndices、Bound。
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
bool AShaderWorldActor::CollisionPreprocessGPU()
|
bool AShaderWorldActor::CollisionPreprocessGPU()
|
||||||
{
|
{
|
||||||
@ -500,25 +502,23 @@ bool AShaderWorldActor::CollisionPreprocessGPU()
|
|||||||
SW_LOG("CollisionPreprocessGPU :: Mesh.Mesh->GetProcMeshSection(0) = nullptr")
|
SW_LOG("CollisionPreprocessGPU :: Mesh.Mesh->GetProcMeshSection(0) = nullptr")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CollisionReadToProcess.RemoveAt(CollID);
|
CollisionReadToProcess.RemoveAt(CollID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//回读队列处理完毕后之后执行后续逻辑
|
||||||
if (!CollisionReadToProcess.IsEmpty())
|
if (!CollisionReadToProcess.IsEmpty())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//开始执行碰撞处理队列逻辑
|
||||||
CollisionReadToProcess.Empty();
|
CollisionReadToProcess.Empty();
|
||||||
|
|
||||||
if (CollisionWorkQueue.Num() > 0)
|
if (CollisionWorkQueue.Num() > 0)
|
||||||
{
|
{
|
||||||
(*bProcessingGroundCollision.Get()) = true;
|
(*bProcessingGroundCollision.Get()) = true;
|
||||||
|
|
||||||
AShaderWorldActor* SWContext = this;
|
AShaderWorldActor* SWContext = this;
|
||||||
|
//异步并行 反序列化Ground碰撞数据
|
||||||
Async(EAsyncExecution::TaskGraph, [Completion = bProcessingGroundCollision, RenderAPI = RendererAPI, VerticesPerPatch = CollisionVerticesPerPatch, Work = CollisionWorkQueue]
|
Async(EAsyncExecution::TaskGraph, [Completion = bProcessingGroundCollision, RenderAPI = RendererAPI, VerticesPerPatch = CollisionVerticesPerPatch, Work = CollisionWorkQueue]
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -541,6 +541,7 @@ bool AShaderWorldActor::CollisionPreprocessGPU()
|
|||||||
FVector LocationfVertice_WS(0);
|
FVector LocationfVertice_WS(0);
|
||||||
uint16 MaterialIndice = 0;
|
uint16 MaterialIndice = 0;
|
||||||
|
|
||||||
|
//取得从GPU回读的序列化数据
|
||||||
uint8* ReadData8 = (uint8*)WorkEl.Read->ReadData.GetData();
|
uint8* ReadData8 = (uint8*)WorkEl.Read->ReadData.GetData();
|
||||||
|
|
||||||
TSet<int32>& TrianglesAffectedByHoles = WorkEl.DestB->TrianglesAffectedByHoles;
|
TSet<int32>& TrianglesAffectedByHoles = WorkEl.DestB->TrianglesAffectedByHoles;
|
||||||
@ -559,7 +560,7 @@ bool AShaderWorldActor::CollisionPreprocessGPU()
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
//从对序列化碰撞Z轴数据进行反序列化,还原成double,再之后还原成FCollisionProcessingWork.DestB
|
||||||
for (int32 k = 0; k < NumOfVertex; k++)
|
for (int32 k = 0; k < NumOfVertex; k++)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -600,6 +601,7 @@ bool AShaderWorldActor::CollisionPreprocessGPU()
|
|||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* If the terrain has holes, create a custom index buffer with the related triangles removed
|
* If the terrain has holes, create a custom index buffer with the related triangles removed
|
||||||
|
* 地形挖洞,碰撞逻辑处理。
|
||||||
*/
|
*/
|
||||||
if(TrianglesAffectedByHoles.Num() > 0)
|
if(TrianglesAffectedByHoles.Num() > 0)
|
||||||
{
|
{
|
||||||
@ -627,6 +629,7 @@ bool AShaderWorldActor::CollisionPreprocessGPU()
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//执行完成后将Completion(bProcessingGroundCollision)设置为false代表处理完成。
|
||||||
if (Completion.IsValid())
|
if (Completion.IsValid())
|
||||||
Completion->AtomicSet(false);
|
Completion->AtomicSet(false);
|
||||||
|
|
||||||
@ -638,6 +641,20 @@ bool AShaderWorldActor::CollisionPreprocessGPU()
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
```c++
|
||||||
|
void AShaderWorldActor::CollisionCPU()
|
||||||
|
{
|
||||||
|
SCOPED_NAMED_EVENT_TEXT("AShaderWorldActor::CollisionCPU()", FColor::Magenta);
|
||||||
|
SW_FCT_CYCLE()
|
||||||
|
|
||||||
|
if ((*bPreprocessingCollisionUpdate.Get()) ||
|
||||||
|
CollisionShareable->CollisionMeshToUpdate.Num() > 0 ||
|
||||||
|
CollisionShareable->CollisionMeshToRenameMoveUpdate.Num() > 0 ||
|
||||||
|
CollisionShareable->CollisionMeshToCreate.Num() > 0)
|
||||||
|
return;
|
||||||
|
```
|
||||||
|
|
||||||
### SpawnablesManagement()
|
### SpawnablesManagement()
|
||||||
|
|
||||||
### TerrainAndSpawnablesManagement()
|
### TerrainAndSpawnablesManagement()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user