Skip to content

Commit

Permalink
Update lightmap even when game is paused.
Browse files Browse the repository at this point in the history
Lightmap was updating every game tick, instead of up to once every 80ms of real time as was intended.
  • Loading branch information
Cyp committed Nov 25, 2011
1 parent db86404 commit 2b928d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/advvis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void avUpdateTiles( void )
}
if (psTile->level > maxLevel)
{
psTile->level = MAX(psTile->level - increment, 0);
psTile->level = MAX(psTile->level - increment, maxLevel);
}
else if (psTile->level < maxLevel)
{
Expand Down
8 changes: 4 additions & 4 deletions src/terrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ struct DecalVertex
/// The lightmap texture
static GLuint lightmap_tex_num;
/// When are we going to update the lightmap next?
static unsigned int lightmapNextUpdate;
static unsigned int lightmapLastUpdate;
/// How big is the lightmap?
static int lightmapWidth;
static int lightmapHeight;
Expand Down Expand Up @@ -1015,7 +1015,7 @@ bool initTerrain(void)
glBindBuffer(GL_ARRAY_BUFFER, 0);

lightmap_tex_num = 0;
lightmapNextUpdate = 0;
lightmapLastUpdate = 0;
lightmapWidth = 1;
lightmapHeight = 1;
// determine the smallest power-of-two size we can use for the lightmap
Expand Down Expand Up @@ -1107,9 +1107,9 @@ void drawTerrain(void)
glEnable(GL_TEXTURE_2D);

// we limit the framerate of the lightmap, because updating a texture is an expensive operation
if (gameTime >= lightmapNextUpdate)
if (realTime - lightmapLastUpdate >= LIGHTMAP_REFRESH)
{
lightmapNextUpdate = gameTime + LIGHTMAP_REFRESH;
lightmapLastUpdate = realTime;

for (j = 0; j < mapHeight; ++j)
{
Expand Down

0 comments on commit 2b928d2

Please sign in to comment.