diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShroud.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShroud.cpp index abead507fd4..26a5a2f32da 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShroud.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShroud.cpp @@ -120,19 +120,24 @@ void W3DShroud::init(WorldHeightMap *pMap, Real worldCellSizeX, Real worldCellSi //Precompute a bounding box for entire shroud layer if (pMap) { - m_numCellsX = REAL_TO_INT_CEIL((Real)(pMap->getXExtent() - 1 - pMap->getBorderSize()*2)*MAP_XY_FACTOR/m_cellWidth); - m_numCellsY = REAL_TO_INT_CEIL((Real)(pMap->getYExtent() - 1 - pMap->getBorderSize()*2)*MAP_XY_FACTOR/m_cellHeight); + m_numCellsX = REAL_TO_INT_CEIL((Real)(pMap->getXExtent() - 1 - pMap->getBorderSizeInline()*2)*MAP_XY_FACTOR/m_cellWidth); + m_numCellsY = REAL_TO_INT_CEIL((Real)(pMap->getYExtent() - 1 - pMap->getBorderSizeInline()*2)*MAP_XY_FACTOR/m_cellHeight); //Maximum visible cells will depend on maximum drawable terrain size plus 1 for partial cells (since //shroud cells are larger than terrain cells). dstTextureWidth=m_numMaxVisibleCellsX=REAL_TO_INT_FLOOR((Real)(pMap->getDrawWidth()-1)*MAP_XY_FACTOR/m_cellWidth)+1; dstTextureHeight=m_numMaxVisibleCellsY=REAL_TO_INT_FLOOR((Real)(pMap->getDrawHeight()-1)*MAP_XY_FACTOR/m_cellHeight)+1; + + dstTextureWidth = m_numCellsX; + dstTextureHeight = m_numCellsY; + dstTextureWidth += 2; //enlarge by 2 pixels so we can have a border color all the way around. unsigned int depth = 1; dstTextureHeight += 2; //enlarge by 2 pixels so we can have border color all the way around. TextureLoader::Validate_Texture_Size((unsigned int &)dstTextureWidth,(unsigned int &)dstTextureHeight, depth); } + UnsignedInt srcWidth,srcHeight; srcWidth=m_numCellsX; @@ -225,7 +230,7 @@ void W3DShroud::ReleaseResources() Bool W3DShroud::ReAcquireResources() { if (!m_dstTextureWidth) - return TRUE; //nothing to reaquire since shroud was never initialized with valid data + return TRUE; //nothing to reacquire since shroud was never initialized with valid data DEBUG_ASSERTCRASH( m_pDstTexture == nullptr, ("ReAcquire of existing shroud texture")); @@ -613,15 +618,24 @@ void W3DShroud::render(CameraClass *cam) WorldHeightMap *hm=TheTerrainRenderObject->getMap(); - Int visStartX=REAL_TO_INT_FLOOR((Real)(hm->getDrawOrgX()-hm->getBorderSize())*MAP_XY_FACTOR/m_cellWidth); //start of rendered heightmap rectangle + Int visStartX=REAL_TO_INT_FLOOR((Real)(hm->getDrawOrgX()-hm->getBorderSizeInline())*MAP_XY_FACTOR/m_cellWidth); //start of rendered heightmap rectangle if (visStartX < 0) visStartX = 0; //no shroud is applied in border area so it always starts at > 0 - Int visStartY=REAL_TO_INT_FLOOR((Real)(hm->getDrawOrgY()-hm->getBorderSize())*MAP_XY_FACTOR/m_cellHeight); + Int visStartY=REAL_TO_INT_FLOOR((Real)(hm->getDrawOrgY()-hm->getBorderSizeInline())*MAP_XY_FACTOR/m_cellHeight); if (visStartY < 0) visStartY = 0; //no shroud is applied in border area so it always starts at > 0 + + // Do it all [3/11/2003] + visStartX = 0; + visStartY = 0; + Int visEndX=visStartX+REAL_TO_INT_FLOOR((Real)(hm->getDrawWidth()-1)*MAP_XY_FACTOR/m_cellWidth)+1; //size of rendered heightmap rectangle Int visEndY=visStartY+REAL_TO_INT_FLOOR((Real)(hm->getDrawHeight()-1)*MAP_XY_FACTOR/m_cellHeight)+1; + // Do it all [3/11/2003] + visEndX = m_numCellsX; + visEndY = m_numCellsY; + if (visEndX > m_numCellsX) { visStartX -= visEndX - m_numCellsX; //shift visible rectangle to fall within terrain bounds