Skip to content

Commit

Permalink
Fixed usage of the ambient lighting cvar. The user-set value was bein…
Browse files Browse the repository at this point in the history
…g incorrectly reset on map load due to the fact that r_ambient was being used to hold the value of the cvar.
  • Loading branch information
danij committed Oct 22, 2006
1 parent 1d22fa0 commit c7ac735
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 40 deletions.
1 change: 1 addition & 0 deletions doomsday/engine/portable/include/p_mapdata.h
Expand Up @@ -150,6 +150,7 @@ extern side_t *sides;
extern int numthings;

extern fixed_t mapgravity; // Gravity for the current map.
extern int mapambient; // Ambient light level for the current map.

extern int numUniqueLines;

Expand Down
1 change: 1 addition & 0 deletions doomsday/engine/portable/src/p_data.c
Expand Up @@ -139,6 +139,7 @@ nodepile_t thingnodes, linenodes; // all kinds of wacky links

ded_mapinfo_t *mapinfo = 0; // Current mapinfo.
fixed_t mapgravity; // Gravity for the current map.
int mapambient; // Ambient lightlevel for the current map.

/*
* Value types for the DMU constants.
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/r_world.c
Expand Up @@ -2398,13 +2398,13 @@ void R_SetupLevel(char *level_id, int flags)
if(mapinfo)
{
mapgravity = mapinfo->gravity * FRACUNIT;
r_ambient = mapinfo->ambient * 255;
mapambient = mapinfo->ambient * 255;
}
else
{
// No map info found, set some basic stuff.
mapgravity = FRACUNIT;
r_ambient = 0;
mapambient = 0;
}

// Invalidate old cmds.
Expand Down
7 changes: 0 additions & 7 deletions doomsday/engine/portable/src/rend_dyn.c
Expand Up @@ -157,8 +157,6 @@ void DL_Register(void)
C_VAR_BYTE("rend-info-lums", &rendInfoLums, 0, 0, 1);

C_VAR_INT("rend-light", &useDynLights, 0, 0, 1);
C_VAR_INT2("rend-light-ambient", &r_ambient, 0, 0, 255,
Rend_CalcLightRangeModMatrix);
C_VAR_INT("rend-light-blend", &dlBlend, 0, 0, 2);

C_VAR_FLOAT("rend-light-bright", &dlFactor, 0, 0, 1);
Expand All @@ -167,13 +165,8 @@ void DL_Register(void)
C_VAR_FLOAT("rend-light-radius-scale", &dlRadFactor, 0, 0.1f, 10);
C_VAR_INT("rend-light-radius-max", &dlMaxRad, 0, 64, 512);
C_VAR_INT("rend-light-radius-min-bias", &dlMinRadForBias, 0, 128, 1024);
C_VAR_INT("rend-light-sky", &rendSkyLight, 0, 0, 1);
C_VAR_FLOAT("rend-light-wall-angle", &rend_light_wall_angle, CVF_NO_MAX,
0, 0);
C_VAR_INT("rend-light-multitex", &useMultiTexLights, 0, 0, 1);

C_VAR_INT("rend-mobj-light-auto", &useMobjAutoLights, 0, 0, 1);

Rend_DecorRegister();
}

Expand Down
67 changes: 36 additions & 31 deletions doomsday/engine/portable/src/rend_main.c
Expand Up @@ -50,6 +50,13 @@

// TYPES -------------------------------------------------------------------

typedef struct {
int value;
int currentlight;
sector_t *sector;
unsigned int updateTime;
} lightsample_t;

// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------

// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
Expand Down Expand Up @@ -82,26 +89,24 @@ boolean freezeRLs = false;

int missileBlend = 1;
int litSprites = 1;
int r_ambient = 0;
// Ambient lighting, r_ambient is used within the renderer, ambientLight is
// used to store the value of the ambient light cvar. ambientLight is used
// The value chosen for r_ambient occurs in Rend_CalcLightRangeModMatrix
// for convenience (since we would have to recalculate the matrix anyway).
int r_ambient = 0, ambientLight = 0;

int viewpw, viewph; // Viewport size, in pixels.
int viewpx, viewpy; // Viewpoint top left corner, in pixels.

float yfov;

int gamedrawhud = 1; // Set to zero when we advise that the HUD should not be drawn
int gamedrawhud = 1; // Set to zero when we advise that the HUD
// should not be drawn

extern DGLuint ddTextures[];

int playerLightRange[MAXPLAYERS];

typedef struct {
int value;
int currentlight;
sector_t *sector;
unsigned int updateTime;
} lightsample_t;

lightsample_t playerLastLightSample[MAXPLAYERS];

float r_lightAdapt = 0.8f; // Amount of light adaption
Expand Down Expand Up @@ -143,34 +148,29 @@ static byte devNoTexFix = 0;
void Rend_Register(void)
{
C_VAR_INT("rend-dev-freeze", &freezeRLs, CVF_NO_ARCHIVE, 0, 1);

C_VAR_INT("rend-dev-cull-subsectors", &devNoCulling, CVF_NO_ARCHIVE, 0, 1);

C_VAR_INT("rend-dev-cull-subsectors", &devNoCulling,CVF_NO_ARCHIVE,0,1);
C_VAR_INT("rend-dev-mobj-bbox", &devMobjBBox, 0, 0, 1);

C_VAR_FLOAT("rend-camera-fov", &fieldOfView, 0, 1, 179);

C_VAR_BYTE("rend-tex-anim-smooth", &smoothTexAnim, 0, 0, 1);

C_VAR_INT("rend-tex-shiny", &useShinySurfaces, 0, 0, 1);

C_VAR_FLOAT2("rend-light-compression", &r_lightcompression, 0, -100, 100,
C_VAR_FLOAT2("rend-light-compression", &r_lightcompression,0, -100, 100,
Rend_CalcLightRangeModMatrix);

C_VAR_FLOAT("rend-light-adaptation", &r_lightAdapt, 0, 0, 1);

C_VAR_FLOAT2("rend-light-adaptation-mul", &r_lightAdaptMul, CVF_PROTECTED, 0, 1,
Rend_CalcLightRangeModMatrix);

C_VAR_FLOAT2("rend-light-adaptation-ramp", &r_lightAdaptRamp, CVF_PROTECTED, 0, 1,
Rend_CalcLightRangeModMatrix);

C_VAR_INT("rend-light-adaptation-darktime", &r_lightAdaptDarkTime, 0, 0, 200);

C_VAR_INT("rend-light-adaptation-brighttime", &r_lightAdaptBrightTime, 0, 0, 200);

C_VAR_INT("rend-dev-light-modmatrix", &debugLightModMatrix, CVF_NO_ARCHIVE, 0, 1);

C_VAR_FLOAT2("rend-light-adaptation-mul", &r_lightAdaptMul,
CVF_PROTECTED, 0, 1, Rend_CalcLightRangeModMatrix);
C_VAR_FLOAT2("rend-light-adaptation-ramp", &r_lightAdaptRamp,
CVF_PROTECTED, 0, 1, Rend_CalcLightRangeModMatrix);
C_VAR_INT("rend-light-adaptation-darktime", &r_lightAdaptDarkTime,
0, 0, 200);
C_VAR_INT("rend-light-adaptation-brighttime", &r_lightAdaptBrightTime,
0, 0, 200);
C_VAR_INT2("rend-light-ambient", &ambientLight, 0, 0, 255,
Rend_CalcLightRangeModMatrix);
C_VAR_INT("rend-light-sky", &rendSkyLight, 0, 0, 1);
C_VAR_FLOAT("rend-light-wall-angle", &rend_light_wall_angle, CVF_NO_MAX,
0, 0);
C_VAR_INT("rend-dev-light-modmatrix", &debugLightModMatrix,
CVF_NO_ARCHIVE, 0, 1);
C_VAR_BYTE("rend-dev-tex-showfix", &devNoTexFix, 0, 0, 1);

RL_Register();
Expand Down Expand Up @@ -1991,6 +1991,11 @@ void Rend_CalcLightRangeModMatrix(cvar_t* unused)
float f, mod, factor;
double multiplier, mx;

if(mapambient > ambientLight)
r_ambient = mapambient;
else
r_ambient = ambientLight;

memset(lightRangeModMatrix, 0, (sizeof(byte) * 255) * MOD_RANGE);

if(r_lightcompression > 0)
Expand Down

0 comments on commit c7ac735

Please sign in to comment.