mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-29 15:51:45 +00:00
soft: use separate light3_t
This commit is contained in:
parent
480f278045
commit
3f33522977
5 changed files with 37 additions and 29 deletions
|
@ -77,6 +77,7 @@ typedef unsigned char pixel_t;
|
|||
typedef int shift20_t;
|
||||
typedef int zvalue_t;
|
||||
typedef unsigned int light_t;
|
||||
typedef int light3_t[3];
|
||||
|
||||
// xyz-prescale to 16.16 fixed-point
|
||||
#define SHIFT16XYZ 16
|
||||
|
@ -202,7 +203,7 @@ typedef struct
|
|||
*/
|
||||
typedef struct finalvert_s {
|
||||
int u, v, s, t;
|
||||
int l[3]; // full color light
|
||||
light3_t l; // full color light
|
||||
zvalue_t zi;
|
||||
int flags;
|
||||
float xyz[3]; // eye space
|
||||
|
@ -210,7 +211,7 @@ typedef struct finalvert_s {
|
|||
|
||||
typedef struct compactvert_s {
|
||||
int u, v, s, t;
|
||||
int l[3]; // full color light
|
||||
light3_t l; // full color light
|
||||
zvalue_t zi;
|
||||
} compactvert_t;
|
||||
|
||||
|
@ -502,7 +503,8 @@ extern edge_t **removeedges;
|
|||
typedef struct {
|
||||
int u, v, count;
|
||||
pixel_t *ptex;
|
||||
int sfrac, tfrac, light[3];
|
||||
int sfrac, tfrac;
|
||||
light3_t light;
|
||||
zvalue_t zi;
|
||||
} spanpackage_t;
|
||||
extern spanpackage_t *triangle_spans, *triangles_max;
|
||||
|
@ -590,7 +592,7 @@ image_t *R_FindImage(char *name, imagetype_t type);
|
|||
byte *Get_BestImageSize(const image_t *image, int *req_width, int *req_height);
|
||||
void R_FreeUnusedImages(void);
|
||||
qboolean R_ImageHasFreeSpace(void);
|
||||
pixel_t R_ApplyLight(pixel_t pix, const int light[3]);
|
||||
pixel_t R_ApplyLight(pixel_t pix, const light3_t light);
|
||||
|
||||
void R_InitSkyBox(model_t *loadmodel);
|
||||
void R_IMFlatShadedQuad( const vec3_t a, const vec3_t b, const vec3_t c, const vec3_t d, int color, float alpha );
|
||||
|
|
|
@ -35,7 +35,7 @@ affinetridesc_t r_affinetridesc;
|
|||
static vec3_t r_plightvec;
|
||||
static vec3_t r_lerp_frontv, r_lerp_backv, r_lerp_move;
|
||||
|
||||
static int r_ambientlight[3];
|
||||
static light3_t r_ambientlight;
|
||||
int r_aliasblendcolor;
|
||||
static float r_shadelight[3];
|
||||
|
||||
|
@ -447,7 +447,7 @@ R_AliasTransformFinalVerts(const entity_t *currententity, int numpoints, finalve
|
|||
}
|
||||
}
|
||||
else
|
||||
memcpy(fv->l, r_ambientlight, sizeof(int) * 3); // light;
|
||||
memcpy(fv->l, r_ambientlight, sizeof(light3_t)); // light;
|
||||
|
||||
if ( fv->xyz[2] < ALIAS_Z_CLIP_PLANE )
|
||||
{
|
||||
|
|
|
@ -329,8 +329,13 @@ R_LoadWal (char *name, imagetype_t type)
|
|||
|
||||
static byte *d_16to8table = NULL; // 16 to 8 bit conversion table
|
||||
|
||||
/*
|
||||
* Apply color light to texture pixel
|
||||
*
|
||||
* TODO: -22% fps lost
|
||||
*/
|
||||
pixel_t
|
||||
R_ApplyLight(pixel_t pix, const int light[3])
|
||||
R_ApplyLight(pixel_t pix, const light3_t light)
|
||||
{
|
||||
pixel_t i_r, i_g, i_b;
|
||||
byte b_r, b_g, b_b;
|
||||
|
|
|
@ -68,7 +68,8 @@ static spanpackage_t *d_pedgespanpackage;
|
|||
|
||||
spanpackage_t *triangle_spans, *triangles_max;
|
||||
|
||||
static int d_sfrac, d_tfrac, d_light[3];
|
||||
static int d_sfrac, d_tfrac;
|
||||
static light3_t d_light;
|
||||
static zvalue_t d_zi;
|
||||
static int d_ptexextrastep, d_sfracextrastep;
|
||||
static int d_tfracextrastep, d_lightextrastep[3];
|
||||
|
@ -189,21 +190,21 @@ R_DrawTriangle(const entity_t *currententity, const finalvert_t *a, const finalv
|
|||
r_p0.v = a->v; // v
|
||||
r_p0.s = a->s; // s
|
||||
r_p0.t = a->t; // t
|
||||
memcpy(r_p0.l, a->l, sizeof(int) * 3); // light
|
||||
memcpy(r_p0.l, a->l, sizeof(light3_t)); // light
|
||||
r_p0.zi = a->zi; // iz
|
||||
|
||||
r_p1.u = b->u;
|
||||
r_p1.v = b->v;
|
||||
r_p1.s = b->s;
|
||||
r_p1.t = b->t;
|
||||
memcpy(r_p1.l, b->l, sizeof(int) * 3); // light
|
||||
memcpy(r_p1.l, b->l, sizeof(light3_t)); // light
|
||||
r_p1.zi = b->zi;
|
||||
|
||||
r_p2.u = c->u;
|
||||
r_p2.v = c->v;
|
||||
r_p2.s = c->s;
|
||||
r_p2.t = c->t;
|
||||
memcpy(r_p2.l, c->l, sizeof(int) * 3); // light;
|
||||
memcpy(r_p2.l, c->l, sizeof(light3_t)); // light;
|
||||
r_p2.zi = c->zi;
|
||||
|
||||
R_PolysetSetEdgeTable ();
|
||||
|
@ -213,7 +214,7 @@ R_DrawTriangle(const entity_t *currententity, const finalvert_t *a, const finalv
|
|||
|
||||
static void
|
||||
R_PushEdgesSpan(int u, int v, int count,
|
||||
pixel_t* d_ptex, int d_sfrac, int d_tfrac, int d_light[3], zvalue_t d_zi)
|
||||
pixel_t* d_ptex, int d_sfrac, int d_tfrac, light3_t d_light, zvalue_t d_zi)
|
||||
{
|
||||
if (d_pedgespanpackage >= triangles_max)
|
||||
{
|
||||
|
@ -231,7 +232,7 @@ R_PushEdgesSpan(int u, int v, int count,
|
|||
d_pedgespanpackage->tfrac = d_tfrac;
|
||||
|
||||
// FIXME: need to clamp l, s, t, at both ends?
|
||||
memcpy(d_pedgespanpackage->light, d_light, sizeof(int) * 3);
|
||||
memcpy(d_pedgespanpackage->light, d_light, sizeof(light3_t));
|
||||
d_pedgespanpackage->zi = d_zi;
|
||||
|
||||
d_pedgespanpackage++;
|
||||
|
@ -446,7 +447,7 @@ R_PolysetDrawSpans8_33(const entity_t *currententity, spanpackage_t *pspanpackag
|
|||
pixel_t *lpdest;
|
||||
pixel_t *lptex;
|
||||
int lsfrac, ltfrac;
|
||||
int llight[3];
|
||||
light3_t llight;
|
||||
zvalue_t lzi;
|
||||
zvalue_t *lpz;
|
||||
|
||||
|
@ -475,7 +476,7 @@ R_PolysetDrawSpans8_33(const entity_t *currententity, spanpackage_t *pspanpackag
|
|||
lptex = pspanpackage->ptex;
|
||||
lsfrac = pspanpackage->sfrac;
|
||||
ltfrac = pspanpackage->tfrac;
|
||||
memcpy(llight, pspanpackage->light, sizeof(int) * 3);
|
||||
memcpy(llight, pspanpackage->light, sizeof(light3_t));
|
||||
lzi = pspanpackage->zi;
|
||||
|
||||
do
|
||||
|
@ -563,7 +564,7 @@ R_PolysetDrawSpans8_66(const entity_t *currententity, spanpackage_t *pspanpackag
|
|||
pixel_t *lpdest;
|
||||
pixel_t *lptex;
|
||||
int lsfrac, ltfrac;
|
||||
int llight[3];
|
||||
light3_t llight;
|
||||
zvalue_t lzi;
|
||||
zvalue_t *lpz;
|
||||
|
||||
|
@ -593,7 +594,7 @@ R_PolysetDrawSpans8_66(const entity_t *currententity, spanpackage_t *pspanpackag
|
|||
lptex = pspanpackage->ptex;
|
||||
lsfrac = pspanpackage->sfrac;
|
||||
ltfrac = pspanpackage->tfrac;
|
||||
memcpy(llight, pspanpackage->light, sizeof(int) * 3);
|
||||
memcpy(llight, pspanpackage->light, sizeof(light3_t));
|
||||
lzi = pspanpackage->zi;
|
||||
|
||||
do
|
||||
|
@ -720,7 +721,7 @@ R_PolysetDrawSpans8_Opaque (const entity_t *currententity, spanpackage_t *pspanp
|
|||
int lsfrac, ltfrac;
|
||||
pixel_t *lpdest;
|
||||
pixel_t *lptex;
|
||||
int llight[3];
|
||||
light3_t llight;
|
||||
zvalue_t lzi;
|
||||
zvalue_t *lpz;
|
||||
int pos_shift = (pspanpackage->v * vid_buffer_width) + pspanpackage->u;
|
||||
|
@ -732,7 +733,7 @@ R_PolysetDrawSpans8_Opaque (const entity_t *currententity, spanpackage_t *pspanp
|
|||
lptex = pspanpackage->ptex;
|
||||
lsfrac = pspanpackage->sfrac;
|
||||
ltfrac = pspanpackage->tfrac;
|
||||
memcpy(llight, pspanpackage->light, sizeof(int) * 3);
|
||||
memcpy(llight, pspanpackage->light, sizeof(light3_t));
|
||||
lzi = pspanpackage->zi;
|
||||
|
||||
do
|
||||
|
@ -827,7 +828,7 @@ R_RasterizeAliasPolySmooth(const entity_t *currententity)
|
|||
d_sfrac = plefttop->s & 0xFFFF;
|
||||
d_tfrac = plefttop->t & 0xFFFF;
|
||||
}
|
||||
memcpy(d_light, plefttop->l, sizeof(int) * 3);
|
||||
memcpy(d_light, plefttop->l, sizeof(light3_t));
|
||||
d_zi = plefttop->zi;
|
||||
|
||||
if (initialleftheight == 1)
|
||||
|
@ -853,7 +854,7 @@ R_RasterizeAliasPolySmooth(const entity_t *currententity)
|
|||
working_lstepx[i] = r_lstepx[i] - 1;
|
||||
}
|
||||
else
|
||||
memcpy(working_lstepx, r_lstepx, sizeof(int) * 3);
|
||||
memcpy(working_lstepx, r_lstepx, sizeof(light3_t));
|
||||
|
||||
d_ptexbasestep = ((r_sstepy + r_sstepx * ubasestep) >> SHIFT16XYZ) +
|
||||
((r_tstepy + r_tstepx * ubasestep) >> SHIFT16XYZ) *
|
||||
|
@ -902,7 +903,7 @@ R_RasterizeAliasPolySmooth(const entity_t *currententity)
|
|||
(plefttop->t >> SHIFT16XYZ) * r_affinetridesc.skinwidth;
|
||||
d_sfrac = 0;
|
||||
d_tfrac = 0;
|
||||
memcpy(d_light, plefttop->l, sizeof(int) * 3);
|
||||
memcpy(d_light, plefttop->l, sizeof(light3_t));
|
||||
d_zi = plefttop->zi;
|
||||
|
||||
if (height == 1)
|
||||
|
@ -923,7 +924,7 @@ R_RasterizeAliasPolySmooth(const entity_t *currententity)
|
|||
working_lstepx[i] = r_lstepx[i] - 1;
|
||||
}
|
||||
else
|
||||
memcpy(working_lstepx, r_lstepx, sizeof(int) * 3);
|
||||
memcpy(working_lstepx, r_lstepx, sizeof(light3_t));
|
||||
|
||||
d_ptexbasestep = ((r_sstepy + r_sstepx * ubasestep) >> SHIFT16XYZ) +
|
||||
((r_tstepy + r_tstepx * ubasestep) >> SHIFT16XYZ) *
|
||||
|
|
|
@ -81,12 +81,12 @@ R_DrawSurfaceBlock8_anymip (int level, int surfrowbytes)
|
|||
|
||||
for (v=0 ; v<r_numvblocks ; v++)
|
||||
{
|
||||
int lightleft[3], lightright[3];
|
||||
int lightleftstep[3], lightrightstep[3];
|
||||
light3_t lightleft, lightright;
|
||||
light3_t lightleftstep, lightrightstep;
|
||||
|
||||
// FIXME: use delta rather than both right and left, like ASM?
|
||||
memcpy(lightleft, r_lightptr, sizeof(int) * 3);
|
||||
memcpy(lightright, r_lightptr + 3, sizeof(int) * 3);
|
||||
memcpy(lightleft, r_lightptr, sizeof(light3_t));
|
||||
memcpy(lightright, r_lightptr + 3, sizeof(light3_t));
|
||||
r_lightptr += r_lightwidth * 3;
|
||||
for(i=0; i<3; i++)
|
||||
{
|
||||
|
@ -96,7 +96,7 @@ R_DrawSurfaceBlock8_anymip (int level, int surfrowbytes)
|
|||
|
||||
for (i=0 ; i<size ; i++)
|
||||
{
|
||||
int lightstep[3], light[3];
|
||||
light3_t lightstep, light;
|
||||
int j;
|
||||
|
||||
for(j=0; j<3; j++)
|
||||
|
@ -107,7 +107,7 @@ R_DrawSurfaceBlock8_anymip (int level, int surfrowbytes)
|
|||
lightstep[j] = lighttemp >> level;
|
||||
}
|
||||
|
||||
memcpy(light, lightright, sizeof(int) * 3);
|
||||
memcpy(light, lightright, sizeof(light3_t));
|
||||
|
||||
for (b=(size-1); b>=0; b--)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue