From 6144a2e18cbbe550317c5a83c54212683ddc8a21 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Thu, 15 Nov 2012 14:28:44 +0000 Subject: [PATCH] Split r3159..r3161, part 13: Poly{mer,most}, engine changes. git-svn-id: https://svn.eduke32.com/eduke32@3179 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/engine.c | 2 +- polymer/eduke32/build/src/polymer.c | 62 +++++++++++++++++++--------- polymer/eduke32/build/src/polymost.c | 2 +- 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 890631659..84c2e3c05 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -4362,7 +4362,7 @@ static void parascan(int32_t dax1, int32_t dax2, int32_t sectnum, char dastat, i int32_t dapyscale; int16_t dapskybits; - static const int16_t zeropskyoff[MAXPSKYTILES]; + static const int16_t zeropskyoff[MAXPSKYTILES] = { 0 }; const int16_t *dapskyoff; UNREFERENCED_PARAMETER(dax1); diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index 3d0c6da29..8d3aa0d4c 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -782,9 +782,7 @@ void polymer_uninit(void) void polymer_setaspect(int32_t ang) { float aspect; - float fang = ang; - - fang *= atanf((float)viewingrange/65536.0f)/(PI/4); + float fang = (float)ang * atanf((float)viewingrange/65536.0f)/(PI/4); if (pr_customaspect != 0.0f) aspect = pr_customaspect; @@ -3467,7 +3465,7 @@ void polymer_updatesprite(int32_t snum) { int32_t curpicnum, xsize, ysize, tilexoff, tileyoff, xoff, yoff, i, j, cs; spritetype *tspr = tspriteptr[snum]; - float xratio, yratio, ang; + float xratio, yratio, ang, f; float spos[3]; const GLfloat *inbuffer; uint8_t flipu, flipv; @@ -3523,7 +3521,8 @@ void polymer_updatesprite(int32_t snum) s->plane.material.diffusemodulation[3] = 0xAA; } - s->plane.material.diffusemodulation[3] *= (1.0f - spriteext[tspr->owner].alpha); + f = s->plane.material.diffusemodulation[3] * (1.0f - spriteext[tspr->owner].alpha); + s->plane.material.diffusemodulation[3] = (GLubyte)f; if (searchit == 2) { @@ -4098,7 +4097,7 @@ static void polymer_drawmdsprite(spritetype *tspr) color = mdspritematerial.diffusemodulation; color[0] = color[1] = color[2] = - ((float)(numshades-min(max((tspr->shade * shadescale)+m->shadeoff,0),numshades)))/((float)numshades) * 0xFF; + (GLubyte)(((float)(numshades-min(max((tspr->shade * shadescale)+m->shadeoff,0),numshades)))/((float)numshades) * 0xFF); usinghighpal = (pr_highpalookups && prhighpalookups[curbasepal][tspr->pal].map); @@ -4109,9 +4108,14 @@ static void polymer_drawmdsprite(spritetype *tspr) { if (!(m->flags&1) || (!(tspr->owner >= MAXSPRITES) && sector[sprite[tspr->owner].sectnum].floorpal!=0)) { - color[0] *= (float)hictinting[tspr->pal].r / 255.0; - color[1] *= (float)hictinting[tspr->pal].g / 255.0; - color[2] *= (float)hictinting[tspr->pal].b / 255.0; + double f; + + f = color[0] * (float)hictinting[tspr->pal].r / 255.0; + color[0] = (GLubyte)f; + f = color[1] * (float)hictinting[tspr->pal].g / 255.0; + color[1] = (GLubyte)f; + f = color[2] * (float)hictinting[tspr->pal].b / 255.0; + color[2] = (GLubyte)f; } else globalnoeffect=1; //mdloadskin reads this } @@ -4122,9 +4126,14 @@ static void polymer_drawmdsprite(spritetype *tspr) hictinting[MAXPALOOKUPS-1].g != 255 || hictinting[MAXPALOOKUPS-1].b != 255)) { - color[0] *= hictinting[MAXPALOOKUPS-1].r / 255.0; - color[1] *= hictinting[MAXPALOOKUPS-1].g / 255.0; - color[2] *= hictinting[MAXPALOOKUPS-1].b / 255.0; + double f; + + f = color[0] * hictinting[MAXPALOOKUPS-1].r / 255.0; + color[0] = (GLubyte)f; + f = color[1] * hictinting[MAXPALOOKUPS-1].g / 255.0; + color[1] = (GLubyte)f; + f = color[2] * hictinting[MAXPALOOKUPS-1].b / 255.0; + color[2] = (GLubyte)f; } if (tspr->cstat & 2) @@ -4136,7 +4145,10 @@ static void polymer_drawmdsprite(spritetype *tspr) } else color[3] = 0xFF; - color[3] *= (1.0f - spriteext[tspr->owner].alpha); + { + double f = color[3] * (1.0f - spriteext[tspr->owner].alpha); + color[3] = (GLubyte)f; + } if (searchit == 2) { @@ -4481,24 +4493,34 @@ static void polymer_getbuildmaterial(_prmaterial* material, int16_t tile material->diffusemodulation[0] = material->diffusemodulation[1] = material->diffusemodulation[2] = - ((float)(numshades-min(max((shade * shadescale),0),numshades)))/((float)numshades) * 0xFF; + (GLubyte)(((float)(numshades-min(max((shade * shadescale),0),numshades)))/((float)numshades) * 0xFF); if (pth->flags & 2) { if (pth->palnum != pal) { - material->diffusemodulation[0] *= (float)hictinting[pal].r / 255.0; - material->diffusemodulation[1] *= (float)hictinting[pal].g / 255.0; - material->diffusemodulation[2] *= (float)hictinting[pal].b / 255.0; + double f; + + f = material->diffusemodulation[0] * (float)hictinting[pal].r / 255.0; + material->diffusemodulation[0] = (GLubyte)f; + f = material->diffusemodulation[1] * (float)hictinting[pal].g / 255.0; + material->diffusemodulation[1] = (GLubyte)f; + f = material->diffusemodulation[2] * (float)hictinting[pal].b / 255.0; + material->diffusemodulation[2] = (GLubyte)f; } // fullscreen tint on global palette change... this is used for nightvision and underwater tinting // if ((hictinting[MAXPALOOKUPS-1].r + hictinting[MAXPALOOKUPS-1].g + hictinting[MAXPALOOKUPS-1].b) != 0x2FD) if (!usinghighpal && ((uint32_t)hictinting[MAXPALOOKUPS-1].r & 0xFFFFFF00) != 0xFFFFFF00) { - material->diffusemodulation[0] *= hictinting[MAXPALOOKUPS-1].r / 255.0; - material->diffusemodulation[1] *= hictinting[MAXPALOOKUPS-1].g / 255.0; - material->diffusemodulation[2] *= hictinting[MAXPALOOKUPS-1].b / 255.0; + double f; + + f = material->diffusemodulation[0] * hictinting[MAXPALOOKUPS-1].r / 255.0; + material->diffusemodulation[0] = (GLubyte)f; + f = material->diffusemodulation[1] * hictinting[MAXPALOOKUPS-1].g / 255.0; + material->diffusemodulation[1] = (GLubyte)f; + f = material->diffusemodulation[2] * hictinting[MAXPALOOKUPS-1].b / 255.0; + material->diffusemodulation[2] = (GLubyte)f; } } diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index 2c894670a..eb6dbac46 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -3372,7 +3372,7 @@ static void polymost_drawalls(int32_t bunch) int32_t i, x, y, z, cz, fz, wallnum, sectnum, nextsectnum; int16_t dapskybits; - static const int16_t zeropskyoff[MAXPSKYTILES]; + static const int16_t zeropskyoff[MAXPSKYTILES] = { 0 }; const int16_t *dapskyoff; sectnum = thesector[bunchfirst[bunch]]; sec = §or[sectnum];