From 849bafff21b982fd265e8f56c2db616aaa952bfe Mon Sep 17 00:00:00 2001 From: danij Date: Sun, 27 May 2012 08:33:53 +0100 Subject: [PATCH] Map Renderer|Refactor: Completed merging geometry calculations for surfaces and light decorations --- doomsday/engine/portable/include/r_world.h | 10 -- doomsday/engine/portable/src/r_world.c | 128 +++------------------ doomsday/engine/portable/src/rend_decor.c | 16 +-- 3 files changed, 23 insertions(+), 131 deletions(-) diff --git a/doomsday/engine/portable/include/r_world.h b/doomsday/engine/portable/include/r_world.h index 7cbcb197fb..b87c299341 100644 --- a/doomsday/engine/portable/include/r_world.h +++ b/doomsday/engine/portable/include/r_world.h @@ -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); diff --git a/doomsday/engine/portable/src/r_world.c b/doomsday/engine/portable/src/r_world.c index 876ec0720b..7c659736dd 100644 --- a/doomsday/engine/portable/src/r_world.c +++ b/doomsday/engine/portable/src/r_world.c @@ -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) { @@ -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; } @@ -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; } @@ -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; } @@ -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; } @@ -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], @@ -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; } diff --git a/doomsday/engine/portable/src/rend_decor.c b/doomsday/engine/portable/src/rend_decor.c index a891eb7b96..08bc8aef56 100644 --- a/doomsday/engine/portable/src/rend_decor.c +++ b/doomsday/engine/portable/src/rend_decor.c @@ -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); @@ -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); } @@ -574,9 +574,9 @@ 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); @@ -584,7 +584,7 @@ static void updateSideSectionDecorations(LineDef* line, byte side, SideDefSectio } } - updateSurfaceDecorations2(surface, matOffset[0], matOffset[1], v1, v2, NULL, visible); + updateSurfaceDecorations2(surface, -matOffset[0], -matOffset[1], v1, v2, NULL, visible); } /**