MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / UpdateSplatMap

Function UpdateSplatMap

Source/Engine/Terrain/TerrainPatch.cpp:362–397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

360}
361
362void UpdateSplatMap(const TerrainDataUpdateInfo& info, const Color32* splatMap, const Int2& modifiedOffset, const Int2& modifiedSize, const byte* data)
363{
364 PROFILE_CPU_NAMED("Terrain.UpdateSplatMap");
365
366 // TODO: use offset and size to improve performance of the data updating
367
368 const auto splatPtr = splatMap;
369 const auto ptr = (Color32*)data;
370 for (int32 chunkIndex = 0; chunkIndex < Terrain::ChunksCount; chunkIndex++)
371 {
372 const int32 chunkX = (chunkIndex % Terrain::ChunksCountEdge);
373 const int32 chunkZ = (chunkIndex / Terrain::ChunksCountEdge);
374
375 const int32 chunkTextureX = chunkX * info.VertexCountEdge;
376 const int32 chunkTextureZ = chunkZ * info.VertexCountEdge;
377
378 const int32 chunkHeightmapX = chunkX * info.ChunkSize;
379 const int32 chunkHeightmapZ = chunkZ * info.ChunkSize;
380
381 for (int32 z = 0; z < info.VertexCountEdge; z++)
382 {
383 const int32 tz = (chunkTextureZ + z) * info.TextureSize;
384 const int32 sz = (chunkHeightmapZ + z) * info.HeightmapSize;
385
386 for (int32 x = 0; x < info.VertexCountEdge; x++)
387 {
388 const int32 tx = chunkTextureX + x;
389 const int32 sx = chunkHeightmapX + x;
390 const int32 textureIndex = tz + tx;
391 const int32 heightmapIndex = sz + sx;
392
393 ptr[textureIndex] = splatPtr[heightmapIndex];
394 }
395 }
396 }
397}
398
399void UpdateSplatMap(const TerrainDataUpdateInfo& info, const Color32* splatMap, const byte* data)
400{

Callers 2

SetupSplatMapMethod · 0.85
ModifySplatMapMethod · 0.85

Calls 1

Int2Class · 0.85

Tested by

no test coverage detected