| 317 | } |
| 318 | |
| 319 | void UpdateHeightMap(const TerrainDataUpdateInfo& info, const float* heightmap, const Int2& modifiedOffset, const Int2& modifiedSize, const byte* data) |
| 320 | { |
| 321 | PROFILE_CPU_NAMED("Terrain.UpdateHeightMap"); |
| 322 | |
| 323 | // TODO: use offset and size to improve performance of the data updating |
| 324 | |
| 325 | const auto heightmapPtr = heightmap; |
| 326 | const auto ptr = (Color32*)data; |
| 327 | |
| 328 | for (int32 chunkIndex = 0; chunkIndex < Terrain::ChunksCount; chunkIndex++) |
| 329 | { |
| 330 | const int32 chunkX = (chunkIndex % Terrain::ChunksCountEdge); |
| 331 | const int32 chunkZ = (chunkIndex / Terrain::ChunksCountEdge); |
| 332 | |
| 333 | const int32 chunkTextureX = chunkX * info.VertexCountEdge; |
| 334 | const int32 chunkTextureZ = chunkZ * info.VertexCountEdge; |
| 335 | |
| 336 | const int32 chunkHeightmapX = chunkX * info.ChunkSize; |
| 337 | const int32 chunkHeightmapZ = chunkZ * info.ChunkSize; |
| 338 | |
| 339 | for (int32 z = 0; z < info.VertexCountEdge; z++) |
| 340 | { |
| 341 | const int32 tz = (chunkTextureZ + z) * info.TextureSize; |
| 342 | const int32 sz = (chunkHeightmapZ + z) * info.HeightmapSize; |
| 343 | |
| 344 | for (int32 x = 0; x < info.VertexCountEdge; x++) |
| 345 | { |
| 346 | const int32 tx = chunkTextureX + x; |
| 347 | const int32 sx = chunkHeightmapX + x; |
| 348 | const int32 textureIndex = tz + tx; |
| 349 | const int32 heightmapIndex = sz + sx; |
| 350 | |
| 351 | WriteHeight(info, ptr[textureIndex], heightmapPtr[heightmapIndex]); |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | void UpdateHeightMap(const TerrainDataUpdateInfo& info, const float* heightmap, const byte* data) |
| 358 | { |
no test coverage detected