diff --git a/src/r_defs.h b/src/r_defs.h index 6b2fffdb6..bf1b23663 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -1160,6 +1160,7 @@ typedef struct affine_bounding_t affinebound; affine_t affine; + vector2_t affineoffset; fixed_t frac; } drawcolumndata_t; diff --git a/src/r_draw_column.cpp b/src/r_draw_column.cpp index 483dce065..1d02a12ae 100644 --- a/src/r_draw_column.cpp +++ b/src/r_draw_column.cpp @@ -101,7 +101,7 @@ FUNCINLINE static ATTRINLINE constexpr UINT8 R_DrawColumnPixel(drawcolumndata_t* return R_GetColumnTranslucent(dc, dest, bit, col); } -// Function flow: Translation -> Brightmap -> Translucency +// Function flow: Translation -> Brightmap -> Colormap -> Translucency // "Why are these in nested functions for standard columns?" Uhhhhhh iunno lol // I make-a da code-a @@ -123,15 +123,23 @@ FUNCINLINE static ATTRINLINE constexpr UINT8 R_DrawColumnAffinePixel(drawcolumnd col = dc->translation[col]; } + boolean was_brightmapped = false; + if constexpr (Type & DrawColumnType::DC_BRIGHTMAP) { if (dc->brightmap[bit] == BRIGHTPIXEL) { // Pixel is part of the brightmap col = dc->fullbright[col]; + was_brightmapped = true; } } + if (!was_brightmapped) + { + col = dc->colormap[col]; + } + if constexpr (Type & DrawColumnType::DC_TRANSMAP) { // Pixel is translucent @@ -612,8 +620,8 @@ static void R_DrawAffineColumnTemplate(drawcolumndata_t *dc) ydiff -= (ydiff ? FRACUNIT : 0); // Offset our X and Y positions by the bounding differences. - fixed_t cxx = cx + xdiff; - fixed_t cyy = cy + ydiff; + fixed_t cxx = cx + xdiff + dc->affineoffset.x; + fixed_t cyy = cy + ydiff + dc->affineoffset.y; //I_OutputMsg("xdiff: %f, ydiff: %f\n", FIXED_TO_FLOAT(xdiff), FIXED_TO_FLOAT(ydiff)); diff --git a/src/r_main.cpp b/src/r_main.cpp index 1da915fcd..698472381 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -202,6 +202,7 @@ static CV_PossibleValue_t affinetest_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Aut #ifdef AFFINEROT_TESTER consvar_t cv_affineangle = CVAR_INIT ("affineangle", "0", CV_FLOAT, affineangle_cons_t, NULL); +consvar_t cv_affinecuttest = CVAR_INIT ("affinecuttest", "8.0", CV_FLOAT, CV_Signed, NULL); consvar_t cv_affinerottest = CVAR_INIT ("affinerottest", "Off", CV_FLOAT, affinetest_cons_t, NULL); #endif @@ -1822,6 +1823,7 @@ void R_RegisterEngineStuff(void) #ifdef AFFINEROT_TESTER CV_RegisterVar(&cv_affineangle); + CV_RegisterVar(&cv_affinecuttest); CV_RegisterVar(&cv_affinerottest); #endif diff --git a/src/r_main.h b/src/r_main.h index 45c0558c6..7c979da0a 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -164,7 +164,7 @@ extern consvar_t cv_nulldriftefx, cv_nulldrifttilt; #define AFFINEROT_TESTER #ifdef AFFINEROT_TESTER -extern consvar_t cv_affineangle, cv_affinerottest; +extern consvar_t cv_affineangle, cv_affinecuttest, cv_affinerottest; #endif // debugging diff --git a/src/r_things.cpp b/src/r_things.cpp index b11570a3e..185c2a05a 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1178,6 +1178,8 @@ static void R_DrawVisSprite(vissprite_t *vis) dc.affine.d = vis->affine.transform.d; dc.affine.ox = vis->affine.transform.ox; dc.affine.oy = vis->affine.transform.oy; + dc.affineoffset.x = vis->affine.offset.x; + dc.affineoffset.y = vis->affine.offset.y; R_CopyAffineBounds(&vis->affine.bounds, &dc.affinebound); @@ -1434,6 +1436,14 @@ static void R_SplitSprite(vissprite_t *sprite) newsprite->gzt = sprite->gz; + if (sprite->cut & SC_AFFINE) + { + // Affines: Fix splitting alignment errors by applying a pixel offset + fixed_t szt_diff = (newsprite->sz - cutfrac + 9) << FRACBITS; + newsprite->affine.offset.y = -((sprite->affine.bounds.ylen * FRACUNIT) - szt_diff); + } + + sprite->sz = cutfrac; newsprite->szt = (INT16)(sprite->sz - 1); diff --git a/src/r_things.h b/src/r_things.h index 961ae8cb8..7268d3709 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -210,6 +210,7 @@ struct vissprite_t struct { vector2_t scaling; // Affine scaling + vector2_t offset; // Per-pixel offset angle_t rollangle; // Affine rotation angle affine_t transform; // The actual affine transformation. affine_bounding_t bounds; // The "bounding box" (draw area) of the affine sprite.