Colormaps and splitting

Papersprites are all that remain
This commit is contained in:
yamamama 2026-02-27 05:14:36 -05:00
parent aeadb21ad3
commit 3a81063d7f
6 changed files with 26 additions and 4 deletions

View file

@ -1160,6 +1160,7 @@ typedef struct
affine_bounding_t affinebound;
affine_t affine;
vector2_t affineoffset;
fixed_t frac;
} drawcolumndata_t;

View file

@ -101,7 +101,7 @@ FUNCINLINE static ATTRINLINE constexpr UINT8 R_DrawColumnPixel(drawcolumndata_t*
return R_GetColumnTranslucent<Type>(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));

View file

@ -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

View file

@ -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

View file

@ -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);

View file

@ -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.