Skip to content

Commit

Permalink
Fixed dynlight bug I caused in my recent changes. I mistakenly though…
Browse files Browse the repository at this point in the history
…t SEG_MIDDLE et al where integers (0-2) and had been using them as indexes into the light list arrays.
  • Loading branch information
danij committed Aug 25, 2006
1 parent a0a6acc commit 8bdec88
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
8 changes: 5 additions & 3 deletions doomsday/engine/portable/include/rend_main.h
Expand Up @@ -27,9 +27,11 @@
#include "r_things.h"

// Parts of a wall segment.
#define SEG_MIDDLE 0x1
#define SEG_TOP 0x2
#define SEG_BOTTOM 0x4
typedef enum segsection_e {
SEG_MIDDLE,
SEG_TOP,
SEG_BOTTOM
} segsection_t;

// Light mod matrix range
#define MOD_RANGE 100
Expand Down
32 changes: 19 additions & 13 deletions doomsday/engine/portable/src/rend_dyn.c
Expand Up @@ -391,6 +391,9 @@ static boolean DL_SegTexCoords(float *t, float top, float bottom,
*/
void DL_ProcessWallSeg(lumobj_t * lum, seg_t *seg, sector_t *frontsec)
{
#define SMIDDLE 0x1
#define STOP 0x2
#define SBOTTOM 0x4
int present = 0;
sector_t *backsec = seg->backsector;
side_t *sdef = seg->sidedef;
Expand Down Expand Up @@ -427,7 +430,7 @@ void DL_ProcessWallSeg(lumobj_t * lum, seg_t *seg, sector_t *frontsec)
// Is there a mid wall segment?
if(Rend_IsWallSectionPVisible(seg->linedef, SEG_MIDDLE, backSide))
{
present |= SEG_MIDDLE;
present |= SMIDDLE;
if(backsec)
{
// Check the middle texture's mask status.
Expand All @@ -442,18 +445,18 @@ void DL_ProcessWallSeg(lumobj_t * lum, seg_t *seg, sector_t *frontsec)
{
// We can't light masked textures.
// FIXME: Use vertex lighting.
present &= ~SEG_MIDDLE;
present &= ~SMIDDLE;
} */
}
}

// Is there a top wall segment?
if(Rend_IsWallSectionPVisible(seg->linedef, SEG_TOP, backSide))
present |= SEG_TOP;
present |= STOP;

// Is there a lower wall segment?
if(Rend_IsWallSectionPVisible(seg->linedef, SEG_BOTTOM, backSide))
present |= SEG_BOTTOM;
present |= SBOTTOM;

// There are no surfaces to light!
if(!present)
Expand Down Expand Up @@ -497,7 +500,7 @@ void DL_ProcessWallSeg(lumobj_t * lum, seg_t *seg, sector_t *frontsec)
return; // Outside the seg.

// Process the visible parts of the segment.
if(present & SEG_MIDDLE)
if(present & SMIDDLE)
{
if(backsec)
{
Expand All @@ -524,7 +527,7 @@ void DL_ProcessWallSeg(lumobj_t * lum, seg_t *seg, sector_t *frontsec)
DL_SegLink(dyn, segindex, SEG_MIDDLE);
}
}
if(present & SEG_TOP)
if(present & STOP)
{
if(DL_SegTexCoords(t, fceil, MAX_OF(ffloor, bceil), lum))
{
Expand All @@ -534,7 +537,7 @@ void DL_ProcessWallSeg(lumobj_t * lum, seg_t *seg, sector_t *frontsec)
DL_SegLink(dyn, segindex, SEG_TOP);
}
}
if(present & SEG_BOTTOM)
if(present & SBOTTOM)
{
if(DL_SegTexCoords(t, MIN_OF(bfloor, fceil), ffloor, lum))
{
Expand All @@ -544,6 +547,9 @@ void DL_ProcessWallSeg(lumobj_t * lum, seg_t *seg, sector_t *frontsec)
DL_SegLink(dyn, segindex, SEG_BOTTOM);
}
}
#undef SMIDDLE
#undef STOP
#undef SBOTTOM
}

/**
Expand Down Expand Up @@ -572,7 +578,7 @@ static void DL_CreateGlowLights(seg_t *seg, int part, float segtop,
if(segbottom < floor)
segbottom = floor;

for(g = 0; g < 2; g++)
for(g = 0; g < 2; ++g)
{
// Only do what's told.
if((g == PLN_CEILING && !glow_ceil) || (g == PLN_FLOOR && !glow_floor))
Expand All @@ -598,8 +604,8 @@ static void DL_CreateGlowLights(seg_t *seg, int part, float segtop,
top = ceil;
bottom = ceil - glowHeight;

t[0] = (top - segtop) / glowHeight;
t[1] = t[0] + (segtop - segbottom) / glowHeight;
t[1] = t[0] = (top - segtop) / glowHeight;
t[1]+= (segtop - segbottom) / glowHeight;

if(t[0] > 1 || t[1] < 0)
continue;
Expand All @@ -609,8 +615,8 @@ static void DL_CreateGlowLights(seg_t *seg, int part, float segtop,
bottom = floor;
top = floor + glowHeight;

t[1] = (segbottom - bottom) / glowHeight;
t[0] = t[1] + (segtop - segbottom) / glowHeight;
t[0] = t[1] = (segbottom - bottom) / glowHeight;
t[0]+= (segtop - segbottom) / glowHeight;

if(t[1] > 1 || t[0] < 0)
continue;
Expand All @@ -621,7 +627,7 @@ static void DL_CreateGlowLights(seg_t *seg, int part, float segtop,

dyn->texture = GL_PrepareLSTexture(LST_GRADIENT);

for(i = 0; i < 3; i++)
for(i = 0; i < 3; ++i)
{
dyn->color[i] *= dlFactor;

Expand Down
11 changes: 9 additions & 2 deletions doomsday/engine/portable/src/rend_list.c
Expand Up @@ -2111,8 +2111,15 @@ void RL_SetupPassState(listmode_t mode)
gl.Disable(DGL_DEPTH_WRITE);
gl.Enable(DGL_DEPTH_TEST);
gl.Func(DGL_DEPTH_TEST, DGL_LEQUAL, 0);
// Fog would mess with the color (this is an additive pass).
gl.Disable(DGL_FOG);

if(usingFog)
{
gl.Enable(DGL_FOG);
gl.Fogv(DGL_FOG_COLOR, blackColor);
}
else
gl.Disable(DGL_FOG);

gl.Enable(DGL_BLENDING);
gl.Func(DGL_BLENDING, DGL_SRC_ALPHA, DGL_ONE);
break;
Expand Down

0 comments on commit 8bdec88

Please sign in to comment.