From 274ff3901d50dafbba6b4a9c7d1a34e7ba366b1b Mon Sep 17 00:00:00 2001 From: smb123w64gb Date: Thu, 10 Aug 2023 04:21:00 -0700 Subject: [PATCH] Vrad hack for lightmap packing(Thanks valve) --- utils/vrad/imagepacker.cpp | 9 ++++----- utils/vrad/lightmap.cpp | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/utils/vrad/imagepacker.cpp b/utils/vrad/imagepacker.cpp index 7fe299c..dcd06e3 100644 --- a/utils/vrad/imagepacker.cpp +++ b/utils/vrad/imagepacker.cpp @@ -62,8 +62,9 @@ bool CImagePacker::AddBlock( int width, int height, int *returnX, int *returnY ) { // If we've already determined that a block this big couldn't fit // then blow off checking again... - if ( ( width >= m_MaxBlockWidth ) && ( height >= m_MaxBlockHeight ) ) + if ( ( width >= m_MaxBlockWidth ) && ( height >= m_MaxBlockHeight ) ){ return false; + } int bestX = -1; int maxYIdx; @@ -101,7 +102,6 @@ bool CImagePacker::AddBlock( int width, int height, int *returnX, int *returnY ) m_MaxBlockWidth = width; m_MaxBlockHeight = height; } - return false; } @@ -111,15 +111,14 @@ bool CImagePacker::AddBlock( int width, int height, int *returnX, int *returnY ) // Check if it actually fit height-wise. // hack - // if( *returnY + height > maxLightmapHeight ) - if( *returnY + height >= m_MaxLightmapHeight - 1 ) + if( *returnY + height > m_MaxLightmapHeight) + //if( *returnY + height >= m_MaxLightmapHeight - 1 ) { if ( ( width <= m_MaxBlockWidth ) && ( height <= m_MaxBlockHeight ) ) { m_MaxBlockWidth = width; m_MaxBlockHeight = height; } - return false; } diff --git a/utils/vrad/lightmap.cpp b/utils/vrad/lightmap.cpp index e850007..851a4fb 100644 --- a/utils/vrad/lightmap.cpp +++ b/utils/vrad/lightmap.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// +//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============// // // Purpose: // @@ -3941,7 +3941,7 @@ static void RegisterLightmappedSurface( dface_t *pFace ) // register this surface's lightmap lightmapPage = AllocateLightmap( allocationWidth, allocationHeight, offsetIntoLightmapPage, pMaterialName ); -// Warning( "%s: page %d (%dx%d)\n", pMaterialName, lightmapPage, allocationWidth, allocationHeight ); + //Warning( "%s: page %d (%dx%d)\n", pMaterialName, lightmapPage, allocationWidth, allocationHeight ); if ( lightmapPage >= 0 ) {