Skip to content

Commit

Permalink
Map Renderer|Refactor: Completed merging geometry calculations for su…
Browse files Browse the repository at this point in the history
…rfaces and light decorations
  • Loading branch information
danij-deng committed May 27, 2012
1 parent b34029d commit 849baff
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 131 deletions.
10 changes: 0 additions & 10 deletions doomsday/engine/portable/include/r_world.h
Expand Up @@ -99,16 +99,6 @@ boolean R_FindBottomTop(LineDef* line, int side, SideDefSection section,
Sector* frontSec, Sector* backSec, SideDef* frontSideDef,
coord_t* low, coord_t* hi, float matOffset[2]);

/*boolean R_FindBottomTop(LineDef* lineDef, int side, SideDefSection section,
coord_t matOffsetX, coord_t matOffsetY,
const Plane* ffloor, const Plane* fceil, const Plane* bfloor, const Plane* bceil,
boolean unpegBottom, boolean unpegTop, boolean stretchMiddle, boolean isSelfRef,
coord_t* bottom, coord_t* top, float texOffset[2], float* clippedY);*/

boolean R_FindBottomTop2(LineDef* line, byte side, SideDefSection section,
Sector* frontSec, Sector* backSec, SideDef* frontSideDef,
coord_t* low, coord_t* hi, float matOffset[2]);

Plane* R_NewPlaneForSector(Sector* sec);
void R_DestroyPlaneOfSector(uint id, Sector* sec);

Expand Down
128 changes: 15 additions & 113 deletions doomsday/engine/portable/src/r_world.c
Expand Up @@ -922,7 +922,7 @@ static boolean findBottomTop(LineDef* lineDef, int side, SideDefSection section,
const Plane* bfloor, const Plane* bceil,
boolean unpegBottom, boolean unpegTop,
boolean stretchMiddle, boolean isSelfRef,
coord_t* bottom, coord_t* top, float texOffset[2], float* clippedY)
coord_t* bottom, coord_t* top, float texOffset[2])
{
switch(section)
{
Expand All @@ -937,12 +937,12 @@ static boolean findBottomTop(LineDef* lineDef, int side, SideDefSection section,
{
if(texOffset)
{
texOffset[VX] = matOffsetX;
texOffset[VY] = matOffsetY;
texOffset[0] = matOffsetX;
texOffset[1] = matOffsetY;

// Align with normal middle texture?
if(!unpegTop)
texOffset[VY] += -(fceil->visHeight - bceil->visHeight);
texOffset[1] += -(fceil->visHeight - bceil->visHeight);
}
return true;
}
Expand All @@ -968,15 +968,15 @@ static boolean findBottomTop(LineDef* lineDef, int side, SideDefSection section,
{
if(texOffset)
{
texOffset[VX] = matOffsetX;
texOffset[VY] = matOffsetY;
texOffset[0] = matOffsetX;
texOffset[1] = matOffsetY;

if(bfloor->visHeight > fceil->visHeight)
texOffset[VY] += -((raiseToBackFloor? t : fceil->visHeight) - bfloor->visHeight);
texOffset[1] += -((raiseToBackFloor? t : fceil->visHeight) - bfloor->visHeight);

// Align with normal middle texture?
if(unpegBottom)
texOffset[VY] += (raiseToBackFloor? t : fceil->visHeight) - bfloor->visHeight;
texOffset[1] += (raiseToBackFloor? t : fceil->visHeight) - bfloor->visHeight;
}
return true;
}
Expand Down Expand Up @@ -1005,8 +1005,8 @@ static boolean findBottomTop(LineDef* lineDef, int side, SideDefSection section,
{
if(texOffset)
{
texOffset[VX] = matOffsetX;
texOffset[VY] = 0;
texOffset[0] = matOffsetX;
texOffset[1] = 0;
}
return true;
}
Expand All @@ -1024,14 +1024,13 @@ static boolean findBottomTop(LineDef* lineDef, int side, SideDefSection section,
}

if(LineDef_MiddleMaterialCoords(lineDef, side, bottom, &vR_ZBottom, top,
&vR_ZTop, clippedY, unpegBottom,
clipTop, clipBottom))
&vR_ZTop, texOffset? &texOffset[1] : NULL,
unpegBottom, clipTop, clipBottom))
{
if(texOffset)
{
texOffset[VX] = matOffsetX;
texOffset[VY] = *clippedY;
if(!clipTop) texOffset[VY] = 0;
texOffset[0] = matOffsetX;
if(!clipTop) texOffset[1] = 0;
}
return true;
}
Expand Down Expand Up @@ -1074,7 +1073,6 @@ boolean R_FindBottomTop(LineDef* line, int side, SideDefSection section,
Plane* bfloor = backSec->SP_plane(PLN_FLOOR);
Plane* bceil = backSec->SP_plane(PLN_CEILING);
Surface* suf = &frontSideDef->SW_surface(section);
float clippedY;

visible = findBottomTop(line, side, section,
suf->visOffset[VX], suf->visOffset[VY],
Expand All @@ -1083,103 +1081,7 @@ boolean R_FindBottomTop(LineDef* line, int side, SideDefSection section,
(line->flags & DDLF_DONTPEGTOP)? true : false,
(frontSideDef->flags & SDF_MIDDLE_STRETCH)? true : false,
LINE_SELFREF(line)? true : false,
low, hi, matOffset, &clippedY);
}
return visible;
}

boolean R_FindBottomTop2(LineDef* line, byte side, SideDefSection section,
Sector* frontSec, Sector* backSec, SideDef* frontSideDef,
coord_t* low, coord_t* hi, float matOffset[2])
{
boolean visible = false;

// Single sided?
if(!frontSec || !backSec || !line->L_sidedef(side^1)/*front side of a "window"*/)
{
*low = frontSec->SP_floorvisheight;
*hi = frontSec->SP_ceilvisheight;

if(matOffset)
{
matOffset[0] = matOffset[1] = 0;
if(line->flags & DDLF_DONTPEGBOTTOM)
{
matOffset[1] += (*hi) - (*low);
}
}

visible = *hi > *low;
}
else
{
Plane* ffloor = frontSec->SP_plane(PLN_FLOOR);
Plane* fceil = frontSec->SP_plane(PLN_CEILING);
Plane* bfloor = backSec->SP_plane(PLN_FLOOR);
Plane* bceil = backSec->SP_plane(PLN_CEILING);
Surface* suf = &frontSideDef->SW_surface(section);

switch(section)
{
case SS_MIDDLE: {
float texOffset[2], clippedY;

visible = findBottomTop(line, side, section,
suf->visOffset[VX], suf->visOffset[VY],
ffloor, fceil, bfloor, bceil,
(line->flags & DDLF_DONTPEGBOTTOM)? true : false,
(line->flags & DDLF_DONTPEGTOP)? true : false,
(frontSideDef->flags & SDF_MIDDLE_STRETCH)? true : false,
LINE_SELFREF(line)? true : false,
low, hi, texOffset, &clippedY);
if(matOffset)
{
matOffset[0] = matOffset[1] = 0;
if(line->flags & DDLF_DONTPEGBOTTOM)
{
// Counteract surface material offset (interpreted as geometry offset).
matOffset[1] += suf->visOffset[VY];
matOffset[1] -= clippedY;
}
}
break; }

case SS_TOP:
if(line->L_backsidedef && bceil->visHeight < fceil->visHeight &&
(!Surface_IsSkyMasked(&bceil->surface) || !Surface_IsSkyMasked(&fceil->surface)))
{
*hi = fceil->visHeight;
*low = bceil->visHeight;
if(matOffset)
{
matOffset[0] = matOffset[1] = 0;
if(!(line->flags & DDLF_DONTPEGTOP))
{
matOffset[1] += fceil->visHeight - bceil->visHeight;
}
}
}
visible = *hi > *low;
break;

case SS_BOTTOM:
if(line->L_backsidedef && bfloor->visHeight > ffloor->visHeight &&
(!Surface_IsSkyMasked(&bfloor->surface) || !Surface_IsSkyMasked(&ffloor->surface)))
{
*hi = bfloor->visHeight;
*low = ffloor->visHeight;
if(matOffset)
{
matOffset[0] = matOffset[1] = 0;
if(line->flags & DDLF_DONTPEGBOTTOM)
{
matOffset[1] -= fceil->visHeight - bfloor->visHeight;
}
}
}
visible = *hi > *low;
break;
}
low, hi, matOffset);
}
return visible;
}
Expand Down
16 changes: 8 additions & 8 deletions doomsday/engine/portable/src/rend_decor.c
Expand Up @@ -444,13 +444,13 @@ static uint generateDecorLights(const ded_decorlight_t* def, Surface* suf,
V3d_Sum(originBase, originBase, v1);

// Let's see where the top left light is.
s = M_CycleIntoRange(def->pos[0] - suf->visOffset[0] -
s = M_CycleIntoRange(def->pos[0] -
Material_Width(mat) * def->patternOffset[0] +
offsetS, patternW);
num = 0;
for(; s < width; s += patternW)
{
t = M_CycleIntoRange(def->pos[1] - suf->visOffset[1] -
t = M_CycleIntoRange(def->pos[1] -
Material_Height(mat) * def->patternOffset[1] +
offsetT, patternH);

Expand Down Expand Up @@ -555,8 +555,8 @@ static void updatePlaneDecorations(Plane* pln)
V3d_Set(v2, sec->aaBox.maxX, sec->aaBox.maxY, pln->visHeight);
}

offsetS = -fmod(sec->aaBox.minX, 64);
offsetT = -fmod(sec->aaBox.minY, 64);
offsetS = -fmod(sec->aaBox.minX, 64) - suf->visOffset[0];
offsetT = -fmod(sec->aaBox.minY, 64) - suf->visOffset[1];

updateSurfaceDecorations2(suf, offsetS, offsetT, v1, v2, sec, suf->material? true : false);
}
Expand All @@ -574,17 +574,17 @@ static void updateSideSectionDecorations(LineDef* line, byte side, SideDefSectio
if(surface->material)
{
coord_t low, hi;
visible = R_FindBottomTop2(line, side, section,
line->L_sector(side), line->L_sector(side^1), line->L_sidedef(side),
&low, &hi, matOffset);
visible = R_FindBottomTop(line, side, section,
line->L_sector(side), line->L_sector(side^1), line->L_sidedef(side),
&low, &hi, matOffset);
if(visible)
{
V3d_Set(v1, line->L_vorigin(side )[VX], line->L_vorigin(side )[VY], hi);
V3d_Set(v2, line->L_vorigin(side^1)[VX], line->L_vorigin(side^1)[VY], low);
}
}

updateSurfaceDecorations2(surface, matOffset[0], matOffset[1], v1, v2, NULL, visible);
updateSurfaceDecorations2(surface, -matOffset[0], -matOffset[1], v1, v2, NULL, visible);
}

/**
Expand Down

0 comments on commit 849baff

Please sign in to comment.