Skip to content

Commit

Permalink
Vrad hack for lightmap packing(Thanks valve)
Browse files Browse the repository at this point in the history
  • Loading branch information
smb123w64gb committed Aug 10, 2023
1 parent 0c40aa6 commit 274ff39
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions utils/vrad/imagepacker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -101,7 +102,6 @@ bool CImagePacker::AddBlock( int width, int height, int *returnX, int *returnY )
m_MaxBlockWidth = width;
m_MaxBlockHeight = height;
}

return false;
}

Expand All @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions utils/vrad/lightmap.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
Expand Down Expand Up @@ -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 )
{
Expand Down

0 comments on commit 274ff39

Please sign in to comment.