Skip to content

Commit

Permalink
- split up g_visibility into two variables.
Browse files Browse the repository at this point in the history
This is preparation for experimenting with the weapon flashes that can be quite annoying with how they brighten distant parts of the level far more than nearby parts.
  • Loading branch information
coelckers committed Jan 10, 2022
1 parent da5a928 commit ddcee4e
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 43 deletions.
5 changes: 2 additions & 3 deletions source/build/include/build.h
Expand Up @@ -119,7 +119,7 @@ enum {
PALETTE_TRANSLUC = 1<<2,
};

EXTERN int32_t g_visibility;
inline int32_t g_visibility = 512, g_relvisibility = 0;

EXTERN vec2_t windowxy1, windowxy2;

Expand Down Expand Up @@ -189,8 +189,7 @@ enum {
EXTERN int32_t enginecompatibility_mode;


int32_t engineInit(void);
void engineUnInit(void);
void engineInit(void);

void videoSetCorrectedAspect();
void videoSetViewableArea(int32_t x1, int32_t y1, int32_t x2, int32_t y2);
Expand Down
49 changes: 14 additions & 35 deletions source/build/src/engine.cpp
Expand Up @@ -146,30 +146,21 @@ int32_t animateoffs(int const tilenum, int fakevar)
return offs;
}

static int32_t engineLoadTables(void)
void engineInit(void)
{
static char tablesloaded = 0;

if (tablesloaded == 0)
{
int32_t i;

for (i=0; i<=512; i++)
sintable[i] = int(sin(i * BAngRadian) * +SINTABLEUNIT);
for (i=513; i<1024; i++)
sintable[i] = sintable[1024-i];
for (i=1024; i<2048; i++)
sintable[i] = -sintable[i-1024];

for (i=0; i<640; i++)
radarang[i] = atan((639.5 - i) / 160.) * (-64. / BAngRadian);
for (i=0; i<640; i++)
radarang[1279-i] = -radarang[i];

tablesloaded = 1;
}

return 0;
int32_t i;

for (i=0; i<=512; i++)
sintable[i] = int(sin(i * BAngRadian) * +SINTABLEUNIT);
for (i=513; i<1024; i++)
sintable[i] = sintable[1024-i];
for (i=1024; i<2048; i++)
sintable[i] = -sintable[i-1024];

for (i=0; i<640; i++)
radarang[i] = atan((639.5 - i) / 160.) * (-64. / BAngRadian);
for (i=0; i<640; i++)
radarang[1279-i] = -radarang[i];
}

//
Expand Down Expand Up @@ -342,18 +333,6 @@ const int16_t* getpsky(int32_t picnum, int32_t* dapyscale, int32_t* dapskybits,
return psky->tileofs;
}


//
// initengine
//
int32_t engineInit(void)
{
engineLoadTables();
g_visibility = 512;
return 0;
}


//
// inside
//
Expand Down
2 changes: 1 addition & 1 deletion source/build/src/polymost.cpp
Expand Up @@ -337,7 +337,7 @@ static void polymost_updaterotmat(void)
multiplyMatrix4f(matrix, tiltmatrix);
renderSetViewMatrix(matrix);
float fxdimen = FixedToFloat(xdimenscale);
renderSetVisibility(g_visibility * fxdimen * (1.f / (65536.f)) / r_ambientlight);
renderSetVisibility((g_visibility + g_relvisibility) * fxdimen * (1.f / (65536.f)) / r_ambientlight);
}

const vec2_16_t tileSize(int index)
Expand Down
2 changes: 1 addition & 1 deletion source/core/rendering/scene/hw_drawinfo.cpp
Expand Up @@ -139,7 +139,7 @@ void HWDrawInfo::StartScene(FRenderViewpoint& parentvp, HWViewpointUniforms* uni
VPUniforms.mViewMatrix.loadIdentity();
VPUniforms.mNormalViewMatrix.loadIdentity();
//VPUniforms.mViewHeight = viewheight;
VPUniforms.mGlobVis = (2 / 65536.f) * g_visibility / r_ambientlight;
VPUniforms.mGlobVis = (2 / 65536.f) * (isBuildSoftwareLighting()? g_visibility + g_relvisibility : g_visibility) / r_ambientlight;
VPUniforms.mPalLightLevels = numshades | (static_cast<int>(gl_fogmode) << 8) | (5 << 16);

VPUniforms.mClipLine.X = -10000000.0f;
Expand Down
1 change: 1 addition & 0 deletions source/core/savegamehelp.cpp
Expand Up @@ -695,6 +695,7 @@ void SerializeMap(FSerializer& arc)
("randomseed", randomseed)
("numshades", numshades) // is this really needed?
("visibility", g_visibility)
("relvisibility", g_relvisibility)
("parallaxtype", parallaxtype)
("parallaxyo", parallaxyoffs_override)
("parallaxys", parallaxyscale_override)
Expand Down
2 changes: 1 addition & 1 deletion source/games/blood/src/view.cpp
Expand Up @@ -739,7 +739,7 @@ void viewDrawScreen(bool sceneonly)
break;
}
}
g_visibility = (int32_t)(ClipLow(gVisibility - 32 * gView->visibility - brightness, 0));
g_relvisibility = (int32_t)(ClipLow(gVisibility - 32 * gView->visibility - brightness, 0)) - g_visibility;
cA += interpolatedangle(buildang(deliriumTurnO), buildang(deliriumTurn), gInterpolate);

int ceilingZ, floorZ;
Expand Down
1 change: 1 addition & 0 deletions source/games/duke/src/actors_lava.cpp
Expand Up @@ -563,6 +563,7 @@ void thunder(void)
{
if (testgotpic(RRTILE2577, true))
{
g_relvisibility = 0;
if (krand() > 65000)
{
thunderflash = 1;
Expand Down
3 changes: 2 additions & 1 deletion source/games/duke/src/render.cpp
Expand Up @@ -271,7 +271,8 @@ void displayrooms(int snum, double smoothratio, bool sceneonly)
p->visibility = ud.const_visibility;
}

g_visibility = p->visibility;
g_visibility = ud.const_visibility;
g_relvisibility = p->visibility - ud.const_visibility;

videoSetCorrectedAspect();

Expand Down
4 changes: 3 additions & 1 deletion source/games/sw/src/draw.cpp
Expand Up @@ -1450,7 +1450,9 @@ void drawscreen(PLAYER* pp, double smoothratio, bool sceneonly)
pp->siang = tang.asbuild();

QuakeViewChange(camerapp, &quake_z, &quake_x, &quake_y, &quake_ang);
VisViewChange(camerapp, &g_visibility);
int vis = g_visibility;
VisViewChange(camerapp, &vis);
g_relvisibility = vis - g_visibility;
tz = tz + quake_z;
tx = tx + quake_x;
ty = ty + quake_y;
Expand Down

0 comments on commit ddcee4e

Please sign in to comment.