vault backup: 2025-06-25 23:32:48

This commit is contained in:
2025-06-25 23:32:48 +08:00
parent 33539f99f0
commit a92bd7ebd9
2 changed files with 204 additions and 3 deletions

View File

@@ -57,10 +57,107 @@ rating: ⭐
- TerrainAndSpawnablesManagement()
### ReadbacksManagement()
相关线程安全变量
- **bProcessingHeightRetrieval**
- **bProcessingHeightRetrievalRT**
- ThreadSafe
- bool
- **bProcessingHeightRetrieval**
- **bProcessingHeightRetrievalRT**
- FSWShareableSamplePoints
- PointsPendingReadBacks
- FSWColorRead
- ReadBackHeightData
- FRenderCommandFence
- HeightReadBackFence
```c++
void AShaderWorldActor::ReadbacksManagement()
{
if (!bProcessingHeightRetrieval.IsValid())
bProcessingHeightRetrieval = MakeShared<FThreadSafeBool, ESPMode::ThreadSafe>();
if (!bProcessingHeightRetrievalRT.IsValid())
bProcessingHeightRetrievalRT = MakeShared<FThreadSafeBool, ESPMode::ThreadSafe>();
//PointsPendingReadBacks存储从GPU回读的采样坐标位置;在RetrieveHeightAt()调用HeightReadBackFence.BeginFence(true)开启渲染栅栏,不开启这段逻辑不会执行。
if ((*bProcessingHeightRetrieval.Get()) && (*bProcessingHeightRetrievalRT.Get()) && HeightReadBackFence.IsFenceComplete() && PointsPendingReadBacks.IsValid())
{
// ReadBackHeightData uin8 贴图数据
if (!ReadBackHeightData.IsValid())
return;
//For now we do Compute samples on a rendertarget 5x5, therefore 25 positions evaluated per request.
//每次请求可以读取25个点。
const int NumOfVertex = 25;
PositionsOfReadBacks.Empty();
PositionsOfReadBacks.AddUninitialized(25);
uint8* ReadData8 = (uint8*)ReadBackHeightData->ReadData.GetData();
uint16 MaterialIndice = 0;
for (int32 k = 0; k < NumOfVertex; k++)
{
FVector3f& PositionSample = PositionsOfReadBacks[k];
if (RendererAPI == EGeoRenderingAPI::OpenGL)
{
int X = k % 5;
int Y = k / 5;
int index = X + Y * 5;
Y = (5 - 1) - Y;
index = X + Y * 5;
PositionSample = FVector3f(PointsPendingReadBacks->PositionsXY[2 * k], PointsPendingReadBacks->PositionsXY[2 * k + 1], GetHeightFromGPURead(&ReadData8[index * 4], MaterialIndice) / HeightScale);
}
else
PositionSample = FVector3f(PointsPendingReadBacks->PositionsXY[2 * k], PointsPendingReadBacks->PositionsXY[2 * k + 1], GetHeightFromGPURead(&ReadData8[k * 4], MaterialIndice) / HeightScale);
}
if(HeightRetrieveDelegate.ExecuteIfBound(PositionsOfReadBacks))
{
//SW_LOG("HeightRetrieveDelegate.ExecuteIfBound(PositionsOfReadBacks) PositionsOfReadBacks[0] %s",*PositionsOfReadBacks[0].ToString())
}
else
{
//SW_LOG("Fail HeightRetrieveDelegate.ExecuteIfBound(PositionsOfReadBacks)")
}
bProcessingHeightRetrieval->AtomicSet(false);
bProcessingHeightRetrievalRT->AtomicSet(false);
}
//For now MinMax is here
//处理FClipMapMeshElement的最大最小队列
if (UseSegmented())
{
if(WorldHasBounds_OnRebuild)
{
FClipMapMeshElement& MeshEl = FarLOD_BoundedWorld;
if (MeshEl.MinMaxQueue.Num() > 0)
{
MeshEl.ProcessMinMaxQueue(SWorldSubsystem);
}
}
for (FClipMapMeshElement& MeshEl : Meshes)
{
if (MeshEl.MinMaxQueue.Num() > 0)
{
MeshEl.ProcessMinMaxQueue(SWorldSubsystem);
}
}
}
}
```
### CollisionManagement()
### SpawnablesManagement()
### TerrainAndSpawnablesManagement()
## PreEditChange() / PostEditChangeProperty()
**PreEditChange()** 主要针对以下两个变量的设置: