From 393e768be3a2124c0268e41eac62da8f105e57b4 Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Tue, 31 Mar 2026 11:37:06 +0000 Subject: [PATCH] perf(terrain): Optimize terrain texture data access and add null checks --- .../Source/W3DDevice/GameClient/TerrainTex.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/TerrainTex.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/TerrainTex.cpp index ae2e0b3e548..e5c0837d61f 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/TerrainTex.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/TerrainTex.cpp @@ -135,9 +135,11 @@ int TerrainTextureClass::update(WorldHeightMap *htMap) ICoord2D position = pTile->m_tileLocationInTexture; if (position.x<=0) continue; // all real tile offsets start at 2. jba. + UnsignedByte *pTileRGB = pTile->getRGBDataForWidth(tilePixelExtent); + if (!pTileRGB) continue; Int i,j; for (j=0; jgetRGBDataForWidth(tilePixelExtent); + UnsignedByte *pBGR = pTileRGB; pBGR += (tilePixelExtent-1-j)*TILE_BYTES_PER_PIXEL*tilePixelExtent; // invert to match. Int row = position.y+j; UnsignedByte *pBGRX = ((UnsignedByte*)locked_rect.pBits) + @@ -805,11 +807,13 @@ int AlphaEdgeTextureClass::update(WorldHeightMap *htMap) if (!pTile) continue; ICoord2D position = pTile->m_tileLocationInTexture; if (position.x<=0) continue; // all real edge offsets start at 4. jba. + UnsignedByte *pEdgeRGB = pTile->getRGBDataForWidth(tilePixelExtent); + if (!pEdgeRGB) continue; Int i,j; Int column = position.x; for (j=0; jgetEdgeTile(tileNdx)->getRGBDataForWidth(tilePixelExtent); + UnsignedByte *pBGR = pEdgeRGB; pBGR += (tilePixelExtent-1-j)*TILE_BYTES_PER_PIXEL*tilePixelExtent; // invert to match. UnsignedByte *pBGRX = ((UnsignedByte*)locked_rect.pBits) + (row)*surface_desc.Width*pixelBytes;