mirror of
https://github.com/DrBeef/Raze.git
synced 2025-01-31 13:10:39 +00:00
- Replace scale()
calls with Scale()
from common.
This commit is contained in:
parent
3c5d553456
commit
b36bea7c69
10 changed files with 50 additions and 55 deletions
|
@ -612,7 +612,7 @@ inline char TestBitString(T *pArray, int nIndex)
|
|||
// This is to override the namepace prioritization without altering the actual calls.
|
||||
inline int scale(int a, int b, int c)
|
||||
{
|
||||
return ::scale(a, b, c);
|
||||
return ::Scale(a, b, c);
|
||||
}
|
||||
|
||||
inline int scale(int a1, int a2, int a3, int a4, int a5)
|
||||
|
|
|
@ -262,7 +262,7 @@ EXTERN uint8_t paletteloaded;
|
|||
inline int shadeToLight(int shade)
|
||||
{
|
||||
shade = clamp(shade, 0, numshades-1);
|
||||
int light = scale(numshades-1-shade, 255, numshades-1);
|
||||
int light = Scale(numshades-1-shade, 255, numshades-1);
|
||||
return PalEntry(255,light,light,light);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,11 +10,6 @@
|
|||
#ifndef pragmas_h_
|
||||
#define pragmas_h_
|
||||
|
||||
static inline int32_t scale(int32_t eax, int32_t edx, int32_t ecx)
|
||||
{
|
||||
return int64_t(eax) * edx / ecx;
|
||||
}
|
||||
|
||||
static inline constexpr int ksgn(int32_t a) { return (a > 0) - (a < 0); }
|
||||
|
||||
inline int sgn(int32_t a) { return (a > 0) - (a < 0); }
|
||||
|
|
|
@ -330,7 +330,7 @@ static inline int32_t cliptrace(vec2_t const pos, vec2_t * const goal)
|
|||
return z;
|
||||
}
|
||||
|
||||
n = { pos.x+scale(diff.x, topu, bot), pos.y+scale(diff.y, topu, bot) };
|
||||
n = { pos.x+Scale(diff.x, topu, bot), pos.y+Scale(diff.y, topu, bot) };
|
||||
topu--;
|
||||
} while (area.x*(n.y-p1.y) <= (n.x-p1.x)*area.y);
|
||||
|
||||
|
@ -1187,7 +1187,7 @@ int32_t try_facespr_intersect(uspriteptr_t const spr, vec3_t const in,
|
|||
|
||||
if (!bot) return 0;
|
||||
|
||||
vec3_t newpos = { 0, 0, in.z + scale(vz, topt, bot) };
|
||||
vec3_t newpos = { 0, 0, in.z + Scale(vz, topt, bot) };
|
||||
int32_t siz;
|
||||
int32_t const z1 = sprpos.z + spriteheightofsptr(spr, &siz, 1);
|
||||
|
||||
|
@ -1195,14 +1195,14 @@ int32_t try_facespr_intersect(uspriteptr_t const spr, vec3_t const in,
|
|||
return 0;
|
||||
|
||||
int32_t const topu = vx * (sprpos.y - in.y) - vy * (sprpos.x - in.x);
|
||||
vec2_t const off = { scale(vx, topu, bot), scale(vy, topu, bot) };
|
||||
vec2_t const off = { Scale(vx, topu, bot), Scale(vy, topu, bot) };
|
||||
int32_t const dist = off.x * off.x + off.y * off.y;
|
||||
|
||||
siz = tileWidth(spr->picnum) * spr->xrepeat;
|
||||
|
||||
if (dist > MulScale(siz, siz, 7)) return 0;
|
||||
|
||||
newpos.vec2 = { in.x + scale(vx, topt, bot), in.y + scale(vy, topt, bot) };
|
||||
newpos.vec2 = { in.x + Scale(vx, topt, bot), in.y + Scale(vy, topt, bot) };
|
||||
|
||||
if (abs(newpos.x - in.x) + abs(newpos.y - in.y) + strictly_smaller_than_p >
|
||||
abs(intp->x - in.x) + abs(intp->y - in.y))
|
||||
|
@ -1365,8 +1365,8 @@ int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32
|
|||
{
|
||||
//x1,y1,z1 are temp variables
|
||||
if (vz > 0) z1 = sec->floorz; else z1 = sec->ceilingz;
|
||||
x1 = sv->x + scale(z1-sv->z,vx,vz);
|
||||
y1 = sv->y + scale(z1-sv->z,vy,vz);
|
||||
x1 = sv->x + Scale(z1-sv->z,vx,vz);
|
||||
y1 = sv->y + Scale(z1-sv->z,vy,vz);
|
||||
if (inside(x1,y1,dasector) == 1)
|
||||
{
|
||||
hit_set(hit, dasector, -1, -1, x1, y1, z1);
|
||||
|
@ -1507,14 +1507,14 @@ int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32
|
|||
// signed overflow is undefined behavior in C), but rather the idiv trap when
|
||||
// the resulting quotient doesn't fit into a *signed* 32-bit integer.
|
||||
zz = (uint32_t)(intz-sv->z) * vx;
|
||||
intx = sv->x+scale(zz,1,vz);
|
||||
intx = sv->x+Scale(zz,1,vz);
|
||||
zz = (uint32_t)(intz-sv->z) * vy;
|
||||
inty = sv->y+scale(zz,1,vz);
|
||||
inty = sv->y+Scale(zz,1,vz);
|
||||
}
|
||||
else
|
||||
{
|
||||
intx = sv->x+scale(intz-sv->z,vx,vz);
|
||||
inty = sv->y+scale(intz-sv->z,vy,vz);
|
||||
intx = sv->x+Scale(intz-sv->z,vx,vz);
|
||||
inty = sv->y+Scale(intz-sv->z,vy,vz);
|
||||
}
|
||||
|
||||
if (abs(intx-sv->x)+abs(inty-sv->y) > abs((hit->pos.x)-sv->x)+abs((hit->pos.y)-sv->y))
|
||||
|
|
|
@ -1010,7 +1010,7 @@ int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz,
|
|||
|
||||
global100horiz = dahoriz;
|
||||
|
||||
// xdimenscale is scale(xdimen,yxaspect,320);
|
||||
// xdimenscale is Scale(xdimen,yxaspect,320);
|
||||
// normalization by viewingrange so that center-of-aim doesn't depend on it
|
||||
qglobalhoriz = MulScale(dahoriz, DivScale(xdimenscale, viewingrange, 16), 16)+IntToFixed(ydimen>>1);
|
||||
|
||||
|
@ -1235,7 +1235,7 @@ void renderDrawMasks(void)
|
|||
if (MulScale(labs(xp+yp),xdimen, 24) >= yp)
|
||||
goto killsprite;
|
||||
|
||||
spritesxyz[i].x = scale(xp+yp,xdimen<<7,yp);
|
||||
spritesxyz[i].x = Scale(xp+yp,xdimen<<7,yp);
|
||||
}
|
||||
else if ((tspriteptr[i]->cstat&48) == 0)
|
||||
{
|
||||
|
@ -1540,7 +1540,7 @@ void FillPolygon(int* rx1, int* ry1, int* xb1, int32_t npoints, int picnum, int
|
|||
alpha = GetAlphaFromBlend(maskprops, 0);
|
||||
}
|
||||
int translation = TRANSLATION(Translation_Remap + curbasepal, palette);
|
||||
int light = clamp(scale((numshades - shade), 255, numshades), 0, 255);
|
||||
int light = clamp(Scale((numshades - shade), 255, numshades), 0, 255);
|
||||
PalEntry pe = PalEntry(uint8_t(alpha*255), light, light, light);
|
||||
|
||||
twod->AddPoly(tileGetTexture(picnum), points.Data(), points.Size(), indices.data(), indices.size(), translation, pe, rs, clipx1, clipy1, clipx2, clipy2);
|
||||
|
@ -2085,8 +2085,8 @@ int32_t getangle(int32_t xvect, int32_t yvect)
|
|||
else if (xvect == -yvect)
|
||||
rv = 768 + ((xvect > 0) << 10);
|
||||
else if (abs(xvect) > abs(yvect))
|
||||
rv = ((radarang[640 + scale(160, yvect, xvect)] >> 6) + ((xvect < 0) << 10)) & 2047;
|
||||
else rv = ((radarang[640 - scale(160, xvect, yvect)] >> 6) + 512 + ((yvect < 0) << 10)) & 2047;
|
||||
rv = ((radarang[640 + Scale(160, yvect, xvect)] >> 6) + ((xvect < 0) << 10)) & 2047;
|
||||
else rv = ((radarang[640 - Scale(160, xvect, yvect)] >> 6) + 512 + ((yvect < 0) << 10)) & 2047;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -2106,8 +2106,8 @@ fixed_t gethiq16angle(int32_t xvect, int32_t yvect)
|
|||
else if (xvect == -yvect)
|
||||
rv = IntToFixed(768 + ((xvect > 0) << 10));
|
||||
else if (abs(xvect) > abs(yvect))
|
||||
rv = ((qradarang[5120 + scale(1280, yvect, xvect)] >> 6) + IntToFixed(((xvect < 0) << 10))) & 0x7FFFFFF;
|
||||
else rv = ((qradarang[5120 - scale(1280, xvect, yvect)] >> 6) + IntToFixed(512 + ((yvect < 0) << 10))) & 0x7FFFFFF;
|
||||
rv = ((qradarang[5120 + Scale(1280, yvect, xvect)] >> 6) + IntToFixed(((xvect < 0) << 10))) & 0x7FFFFFF;
|
||||
else rv = ((qradarang[5120 - Scale(1280, xvect, yvect)] >> 6) + IntToFixed(512 + ((yvect < 0) << 10))) & 0x7FFFFFF;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -2897,8 +2897,8 @@ void renderSetAspect(int32_t daxrange, int32_t daaspect)
|
|||
|
||||
yxaspect = daaspect;
|
||||
xyaspect = DivScale(1,yxaspect, 32);
|
||||
xdimenscale = scale(xdimen,yxaspect,320);
|
||||
xdimscale = scale(320,xyaspect,xdimen);
|
||||
xdimenscale = Scale(xdimen,yxaspect,320);
|
||||
xdimscale = Scale(320,xyaspect,xdimen);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2990,8 +2990,8 @@ void renderPrepareMirror(int32_t dax, int32_t day, int32_t daz, fixed_t daang, f
|
|||
|
||||
int i = ((dax-x)*dx + (day-y)*dy)<<1;
|
||||
|
||||
*tposx = (x<<1) + scale(dx,i,j) - dax;
|
||||
*tposy = (y<<1) + scale(dy,i,j) - day;
|
||||
*tposx = (x<<1) + Scale(dx,i,j) - dax;
|
||||
*tposy = (y<<1) + Scale(dy,i,j) - day;
|
||||
*tang = ((gethiq16angle(dx, dy) << 1) - daang) & 0x7FFFFFF;
|
||||
|
||||
inpreparemirror = 1;
|
||||
|
@ -3056,7 +3056,7 @@ int32_t getceilzofslopeptr(usectorptr_t sec, int32_t dax, int32_t day)
|
|||
|
||||
int const j = DMulScale(d.x, day-w.y, -d.y, dax-w.x, 3);
|
||||
int const shift = enginecompatibility_mode != ENGINECOMPATIBILITY_NONE ? 0 : 1;
|
||||
return sec->ceilingz + (scale(sec->ceilingheinum,j>>shift,i)<<shift);
|
||||
return sec->ceilingz + (Scale(sec->ceilingheinum,j>>shift,i)<<shift);
|
||||
}
|
||||
|
||||
int32_t getflorzofslopeptr(usectorptr_t sec, int32_t dax, int32_t day)
|
||||
|
@ -3075,7 +3075,7 @@ int32_t getflorzofslopeptr(usectorptr_t sec, int32_t dax, int32_t day)
|
|||
|
||||
int const j = DMulScale(d.x, day-w.y, -d.y, dax-w.x, 3);
|
||||
int const shift = enginecompatibility_mode != ENGINECOMPATIBILITY_NONE ? 0 : 1;
|
||||
return sec->floorz + (scale(sec->floorheinum,j>>shift,i)<<shift);
|
||||
return sec->floorz + (Scale(sec->floorheinum,j>>shift,i)<<shift);
|
||||
}
|
||||
|
||||
void getzsofslopeptr(usectorptr_t sec, int32_t dax, int32_t day, int32_t *ceilz, int32_t *florz)
|
||||
|
@ -3096,9 +3096,9 @@ void getzsofslopeptr(usectorptr_t sec, int32_t dax, int32_t day, int32_t *ceilz,
|
|||
int const j = DMulScale(d.x,day-wal->y, -d.y,dax-wal->x, 3);
|
||||
int const shift = enginecompatibility_mode != ENGINECOMPATIBILITY_NONE ? 0 : 1;
|
||||
if (sec->ceilingstat&2)
|
||||
*ceilz += scale(sec->ceilingheinum,j>>shift,i)<<shift;
|
||||
*ceilz += Scale(sec->ceilingheinum,j>>shift,i)<<shift;
|
||||
if (sec->floorstat&2)
|
||||
*florz += scale(sec->floorheinum,j>>shift,i)<<shift;
|
||||
*florz += Scale(sec->floorheinum,j>>shift,i)<<shift;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -3114,7 +3114,7 @@ void alignceilslope(int16_t dasect, int32_t x, int32_t y, int32_t z)
|
|||
if (i == 0)
|
||||
return;
|
||||
|
||||
sector[dasect].ceilingheinum = scale((z-sector[dasect].ceilingz)<<8,
|
||||
sector[dasect].ceilingheinum = Scale((z-sector[dasect].ceilingz)<<8,
|
||||
nsqrtasm(uhypsq(dax,day)), i);
|
||||
if (sector[dasect].ceilingheinum == 0)
|
||||
sector[dasect].ceilingstat &= ~2;
|
||||
|
@ -3135,7 +3135,7 @@ void alignflorslope(int16_t dasect, int32_t x, int32_t y, int32_t z)
|
|||
if (i == 0)
|
||||
return;
|
||||
|
||||
sector[dasect].floorheinum = scale((z-sector[dasect].floorz)<<8,
|
||||
sector[dasect].floorheinum = Scale((z-sector[dasect].floorz)<<8,
|
||||
nsqrtasm(uhypsq(dax,day)), i);
|
||||
if (sector[dasect].floorheinum == 0)
|
||||
sector[dasect].floorstat &= ~2;
|
||||
|
|
|
@ -451,7 +451,7 @@ public:
|
|||
framenum++;
|
||||
if (framenum >= numframes) stop = true;
|
||||
|
||||
int soundframe = convdenom ? scale(framenum, convnumer, convdenom) : framenum;
|
||||
int soundframe = convdenom ? Scale(framenum, convnumer, convdenom) : framenum;
|
||||
if (soundframe > lastsoundframe)
|
||||
{
|
||||
if (animSnd && soundtrack == -1) for (int i = 0; animSnd[i].framenum >= 0; i++)
|
||||
|
|
|
@ -336,7 +336,7 @@ DDukeActor* aim(DDukeActor* actor, int aang)
|
|||
if (sdist > 512 && sdist < smax)
|
||||
{
|
||||
if (s->picnum == TILE_APLAYER)
|
||||
a = (abs(scale(sp->z - s->z, 10, sdist) - ps[s->yvel].horizon.sum().asbuild()) < 100);
|
||||
a = (abs(Scale(sp->z - s->z, 10, sdist) - ps[s->yvel].horizon.sum().asbuild()) < 100);
|
||||
else a = 1;
|
||||
|
||||
cans = cansee(sp->x, sp->y, sp->z - (32 << 8) + gs.actorinfo[sp->picnum].aimoffset, sp->sectnum, s->x, s->y, s->z - (32 << 8), s->sectnum);
|
||||
|
|
|
@ -1320,13 +1320,13 @@ void CameraView(PLAYERp pp, int *tx, int *ty, int *tz, short *tsectnum, binangle
|
|||
|
||||
zdiff = sp->z - *tz;
|
||||
if (labs(sp->x - *tx) > 1000)
|
||||
zvect = scale(xvect, zdiff, sp->x - *tx);
|
||||
zvect = Scale(xvect, zdiff, sp->x - *tx);
|
||||
else if (labs(sp->y - *ty) > 1000)
|
||||
zvect = scale(yvect, zdiff, sp->y - *ty);
|
||||
zvect = Scale(yvect, zdiff, sp->y - *ty);
|
||||
else if (sp->x - *tx != 0)
|
||||
zvect = scale(xvect, zdiff, sp->x - *tx);
|
||||
zvect = Scale(xvect, zdiff, sp->x - *tx);
|
||||
else if (sp->y - *ty != 0)
|
||||
zvect = scale(yvect, zdiff, sp->y - *ty);
|
||||
zvect = Scale(yvect, zdiff, sp->y - *ty);
|
||||
else
|
||||
zvect = 0;
|
||||
|
||||
|
|
|
@ -299,9 +299,9 @@ FAFcansee(int32_t xs, int32_t ys, int32_t zs, int16_t sects,
|
|||
if (dist != 0)
|
||||
{
|
||||
if (xe - xs != 0)
|
||||
zvect = scale(xvect, ze - zs, xe - xs);
|
||||
zvect = Scale(xvect, ze - zs, xe - xs);
|
||||
else if (ye - ys != 0)
|
||||
zvect = scale(yvect, ze - zs, ye - ys);
|
||||
zvect = Scale(yvect, ze - zs, ye - ys);
|
||||
else
|
||||
zvect = 0;
|
||||
}
|
||||
|
|
|
@ -8403,7 +8403,7 @@ ComboMissileSeek(int16_t Weapon, int16_t delay_tics, int16_t aware_range/*, int1
|
|||
|
||||
oz = u->zchange;
|
||||
|
||||
u->zchange = scale(sp->xvel, zh - sp->z, dist);
|
||||
u->zchange = Scale(sp->xvel, zh - sp->z, dist);
|
||||
u->zchange = (u->zchange + oz*15)/16;
|
||||
}
|
||||
return 0;
|
||||
|
@ -8486,9 +8486,9 @@ VectorMissileSeek(int16_t Weapon, int16_t delay_tics, int16_t turn_speed, int16_
|
|||
oy = u->ychange;
|
||||
oz = u->zchange;
|
||||
|
||||
u->xchange = scale(sp->xvel, hp->x - sp->x, dist);
|
||||
u->ychange = scale(sp->xvel, hp->y - sp->y, dist);
|
||||
u->zchange = scale(sp->xvel, zh - sp->z, dist);
|
||||
u->xchange = Scale(sp->xvel, hp->x - sp->x, dist);
|
||||
u->ychange = Scale(sp->xvel, hp->y - sp->y, dist);
|
||||
u->zchange = Scale(sp->xvel, zh - sp->z, dist);
|
||||
|
||||
// the large turn_speed is the slower the turn
|
||||
|
||||
|
@ -8555,9 +8555,9 @@ VectorWormSeek(int16_t Weapon, int16_t delay_tics, int16_t aware_range1, int16_t
|
|||
oy = u->ychange;
|
||||
oz = u->zchange;
|
||||
|
||||
u->xchange = scale(sp->xvel, hp->x - sp->x, dist);
|
||||
u->ychange = scale(sp->xvel, hp->y - sp->y, dist);
|
||||
u->zchange = scale(sp->xvel, zh - sp->z, dist);
|
||||
u->xchange = Scale(sp->xvel, hp->x - sp->x, dist);
|
||||
u->ychange = Scale(sp->xvel, hp->y - sp->y, dist);
|
||||
u->zchange = Scale(sp->xvel, zh - sp->z, dist);
|
||||
|
||||
u->xchange = (u->xchange + ox*7)/8;
|
||||
u->ychange = (u->ychange + oy*7)/8;
|
||||
|
@ -14463,10 +14463,10 @@ AimHitscanToTarget(SPRITEp sp, int *z, short *ang, int z_ratio)
|
|||
|
||||
if (hp->x - sp->x != 0)
|
||||
//*z = xvect * ((zh - *z)/(hp->x - sp->x));
|
||||
*z = scale(xvect,zh - *z,hp->x - sp->x);
|
||||
*z = Scale(xvect,zh - *z,hp->x - sp->x);
|
||||
else if (hp->y - sp->y != 0)
|
||||
//*z = yvect * ((zh - *z)/(hp->y - sp->y));
|
||||
*z = scale(yvect,zh - *z,hp->y - sp->y);
|
||||
*z = Scale(yvect,zh - *z,hp->y - sp->y);
|
||||
else
|
||||
*z = 0;
|
||||
|
||||
|
@ -14525,10 +14525,10 @@ WeaponAutoAimHitscan(SPRITEp sp, int *z, short *ang, bool test)
|
|||
|
||||
if (hp->x - sp->x != 0)
|
||||
//*z = xvect * ((zh - *z)/(hp->x - sp->x));
|
||||
*z = scale(xvect,zh - *z,hp->x - sp->x);
|
||||
*z = Scale(xvect,zh - *z,hp->x - sp->x);
|
||||
else if (hp->y - sp->y != 0)
|
||||
//*z = yvect * ((zh - *z)/(hp->y - sp->y));
|
||||
*z = scale(yvect,zh - *z,hp->y - sp->y);
|
||||
*z = Scale(yvect,zh - *z,hp->y - sp->y);
|
||||
else
|
||||
*z = 0;
|
||||
}
|
||||
|
@ -14564,10 +14564,10 @@ WeaponHitscanShootFeet(SPRITEp sp, SPRITEp hp, int *zvect)
|
|||
|
||||
if (hp->x - sp->x != 0)
|
||||
//*z = xvect * ((zh - *z)/(hp->x - sp->x));
|
||||
*zvect = scale(xvect,zh - z, hp->x - sp->x);
|
||||
*zvect = Scale(xvect,zh - z, hp->x - sp->x);
|
||||
else if (hp->y - sp->y != 0)
|
||||
//*z = yvect * ((zh - *z)/(hp->y - sp->y));
|
||||
*zvect = scale(yvect,zh - z, hp->y - sp->y);
|
||||
*zvect = Scale(yvect,zh - z, hp->y - sp->y);
|
||||
else
|
||||
*zvect = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue