mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-31 12:13:16 +00:00
Merge branch 'sprite-offsets' into 'master'
Sprite offsets for horizontal springs See merge request KartKrew/Kart!265
This commit is contained in:
commit
843721cc8f
7 changed files with 94 additions and 34 deletions
|
|
@ -2831,6 +2831,10 @@ static boolean HWR_DoCulling(line_t *cullheight, line_t *viewcullheight, float v
|
|||
|
||||
static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale)
|
||||
{
|
||||
const fixed_t thingxpos = thing->x + thing->sprxoff;
|
||||
const fixed_t thingypos = thing->y + thing->spryoff;
|
||||
const fixed_t thingzpos = thing->z + thing->sprzoff;
|
||||
|
||||
GLPatch_t *gpatch;
|
||||
FOutVector shadowVerts[4];
|
||||
FSurfaceInfo sSurf;
|
||||
|
|
@ -2848,7 +2852,7 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale)
|
|||
pslope_t *floorslope;
|
||||
|
||||
floorz = R_GetShadowZ(thing, &floorslope);
|
||||
floordiff = abs(thing->z - floorz);
|
||||
floordiff = abs(thingzpos - floorz);
|
||||
|
||||
alpha = floordiff / (4*FRACUNIT) + 75;
|
||||
if (alpha >= 255) return;
|
||||
|
|
@ -2872,8 +2876,8 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale)
|
|||
scalemul = FixedMul(scalemul, (thing->radius*2) / gpatch->height);
|
||||
|
||||
fscale = FIXED_TO_FLOAT(scalemul);
|
||||
fx = FIXED_TO_FLOAT(thing->x);
|
||||
fy = FIXED_TO_FLOAT(thing->y);
|
||||
fx = FIXED_TO_FLOAT(thingxpos);
|
||||
fy = FIXED_TO_FLOAT(thingypos);
|
||||
|
||||
// 3--2
|
||||
// | /|
|
||||
|
|
@ -4096,6 +4100,10 @@ void HWR_AddSprites(sector_t *sec)
|
|||
// BP why not use xtoviexangle/viewangletox like in bsp ?....
|
||||
void HWR_ProjectSprite(mobj_t *thing)
|
||||
{
|
||||
const fixed_t thingxpos = thing->x + thing->sprxoff;
|
||||
const fixed_t thingypos = thing->y + thing->spryoff;
|
||||
const fixed_t thingzpos = thing->z + thing->sprzoff;
|
||||
|
||||
gr_vissprite_t *vis;
|
||||
float tr_x, tr_y;
|
||||
float tz;
|
||||
|
|
@ -4120,8 +4128,8 @@ void HWR_ProjectSprite(mobj_t *thing)
|
|||
this_scale = FIXED_TO_FLOAT(thing->scale);
|
||||
|
||||
// transform the origin point
|
||||
tr_x = FIXED_TO_FLOAT(thing->x) - gr_viewx;
|
||||
tr_y = FIXED_TO_FLOAT(thing->y) - gr_viewy;
|
||||
tr_x = FIXED_TO_FLOAT(thingxpos) - gr_viewx;
|
||||
tr_y = FIXED_TO_FLOAT(thingypos) - gr_viewy;
|
||||
|
||||
// rotation around vertical axis
|
||||
tz = (tr_x * gr_viewcos) + (tr_y * gr_viewsin);
|
||||
|
|
@ -4131,8 +4139,8 @@ void HWR_ProjectSprite(mobj_t *thing)
|
|||
return;
|
||||
|
||||
// The above can stay as it works for cutting sprites that are too close
|
||||
tr_x = FIXED_TO_FLOAT(thing->x);
|
||||
tr_y = FIXED_TO_FLOAT(thing->y);
|
||||
tr_x = FIXED_TO_FLOAT(thingxpos);
|
||||
tr_y = FIXED_TO_FLOAT(thingypos);
|
||||
|
||||
// decide which patch to use for sprite relative to player
|
||||
#ifdef RANGECHECK
|
||||
|
|
@ -4168,9 +4176,9 @@ void HWR_ProjectSprite(mobj_t *thing)
|
|||
#endif
|
||||
|
||||
if (thing->player)
|
||||
ang = R_PointToAngle (thing->x, thing->y) - thing->player->frameangle;
|
||||
ang = R_PointToAngle (thingxpos, thingypos) - thing->player->frameangle;
|
||||
else
|
||||
ang = R_PointToAngle (thing->x, thing->y) - thing->angle;
|
||||
ang = R_PointToAngle (thingxpos, thingypos) - thing->angle;
|
||||
|
||||
if (sprframe->rotate == SRF_SINGLE)
|
||||
{
|
||||
|
|
@ -4242,12 +4250,12 @@ void HWR_ProjectSprite(mobj_t *thing)
|
|||
|
||||
if (vflip)
|
||||
{
|
||||
gz = FIXED_TO_FLOAT(thing->z+thing->height) - FIXED_TO_FLOAT(spritecachedinfo[lumpoff].topoffset) * this_scale;
|
||||
gz = FIXED_TO_FLOAT(thingzpos + thing->height) - FIXED_TO_FLOAT(spritecachedinfo[lumpoff].topoffset) * this_scale;
|
||||
gzt = gz + FIXED_TO_FLOAT(spritecachedinfo[lumpoff].height) * this_scale;
|
||||
}
|
||||
else
|
||||
{
|
||||
gzt = FIXED_TO_FLOAT(thing->z) + FIXED_TO_FLOAT(spritecachedinfo[lumpoff].topoffset) * this_scale;
|
||||
gzt = FIXED_TO_FLOAT(thingzpos) + FIXED_TO_FLOAT(spritecachedinfo[lumpoff].topoffset) * this_scale;
|
||||
gz = gzt - FIXED_TO_FLOAT(spritecachedinfo[lumpoff].height) * this_scale;
|
||||
}
|
||||
|
||||
|
|
@ -4266,12 +4274,12 @@ void HWR_ProjectSprite(mobj_t *thing)
|
|||
if (heightsec != -1 && phs != -1) // only clip things which are in special sectors
|
||||
{
|
||||
if (gr_viewz < FIXED_TO_FLOAT(sectors[phs].floorheight) ?
|
||||
FIXED_TO_FLOAT(thing->z) >= FIXED_TO_FLOAT(sectors[heightsec].floorheight) :
|
||||
FIXED_TO_FLOAT(thingzpos) >= FIXED_TO_FLOAT(sectors[heightsec].floorheight) :
|
||||
gzt < FIXED_TO_FLOAT(sectors[heightsec].floorheight))
|
||||
return;
|
||||
if (gr_viewz > FIXED_TO_FLOAT(sectors[phs].ceilingheight) ?
|
||||
gzt < FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) && gr_viewz >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) :
|
||||
FIXED_TO_FLOAT(thing->z) >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight))
|
||||
FIXED_TO_FLOAT(thingzpos) >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight))
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1114,6 +1114,10 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
|
|||
|
||||
// Look at HWR_ProjectSprite for more
|
||||
{
|
||||
const fixed_t thingxpos = spr->mobj->x + spr->mobj->sprxoff;
|
||||
const fixed_t thingypos = spr->mobj->y + spr->mobj->spryoff;
|
||||
const fixed_t thingzpos = spr->mobj->z + spr->mobj->sprzoff;
|
||||
|
||||
GLPatch_t *gpatch;
|
||||
INT32 durs = spr->mobj->state->tics;
|
||||
INT32 tics = spr->mobj->tics;
|
||||
|
|
@ -1259,13 +1263,13 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
|
|||
#endif
|
||||
|
||||
//Hurdler: it seems there is still a small problem with mobj angle
|
||||
p.x = FIXED_TO_FLOAT(spr->mobj->x);
|
||||
p.y = FIXED_TO_FLOAT(spr->mobj->y)+md2->offset;
|
||||
p.x = FIXED_TO_FLOAT(thingxpos);
|
||||
p.y = FIXED_TO_FLOAT(thingypos) + md2->offset;
|
||||
|
||||
if (spr->mobj->eflags & MFE_VERTICALFLIP)
|
||||
p.z = FIXED_TO_FLOAT(spr->mobj->z + spr->mobj->height);
|
||||
p.z = FIXED_TO_FLOAT(thingzpos + spr->mobj->height);
|
||||
else
|
||||
p.z = FIXED_TO_FLOAT(spr->mobj->z);
|
||||
p.z = FIXED_TO_FLOAT(thingzpos);
|
||||
|
||||
if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY)
|
||||
sprdef = &((skin_t *)spr->mobj->skin)->spritedef;
|
||||
|
|
@ -1285,7 +1289,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
|
|||
}
|
||||
else
|
||||
{
|
||||
const fixed_t anglef = AngleFixed((R_PointToAngle(spr->mobj->x, spr->mobj->y))-ANGLE_180);
|
||||
const fixed_t anglef = AngleFixed((R_PointToAngle(thingxpos, thingypos))-ANGLE_180);
|
||||
p.angley = FIXED_TO_FLOAT(anglef);
|
||||
}
|
||||
p.anglex = 0.0f;
|
||||
|
|
|
|||
|
|
@ -87,7 +87,10 @@ enum mobj_e {
|
|||
#endif
|
||||
mobj_colorized,
|
||||
mobj_shadowscale,
|
||||
mobj_whiteshadow
|
||||
mobj_whiteshadow,
|
||||
mobj_sprxoff,
|
||||
mobj_spryoff,
|
||||
mobj_sprzoff
|
||||
};
|
||||
|
||||
static const char *const mobj_opt[] = {
|
||||
|
|
@ -153,6 +156,9 @@ static const char *const mobj_opt[] = {
|
|||
"colorized",
|
||||
"shadowscale",
|
||||
"whiteshadow",
|
||||
"sprxoff",
|
||||
"spryoff",
|
||||
"sprzoff",
|
||||
NULL};
|
||||
|
||||
#define UNIMPLEMENTED luaL_error(L, LUA_QL("mobj_t") " field " LUA_QS " is not implemented for Lua and cannot be accessed.", mobj_opt[field])
|
||||
|
|
@ -370,6 +376,15 @@ static int mobj_get(lua_State *L)
|
|||
case mobj_whiteshadow:
|
||||
lua_pushboolean(L, mo->whiteshadow);
|
||||
break;
|
||||
case mobj_sprxoff:
|
||||
lua_pushfixed(L, mo->sprxoff);
|
||||
break;
|
||||
case mobj_spryoff:
|
||||
lua_pushfixed(L, mo->spryoff);
|
||||
break;
|
||||
case mobj_sprzoff:
|
||||
lua_pushfixed(L, mo->sprzoff);
|
||||
break;
|
||||
default: // extra custom variables in Lua memory
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS);
|
||||
I_Assert(lua_istable(L, -1));
|
||||
|
|
@ -693,6 +708,15 @@ static int mobj_set(lua_State *L)
|
|||
case mobj_whiteshadow:
|
||||
mo->whiteshadow = luaL_checkboolean(L, 3);
|
||||
break;
|
||||
case mobj_sprxoff:
|
||||
mo->sprxoff = luaL_checkfixed(L, 3);
|
||||
break;
|
||||
case mobj_spryoff:
|
||||
mo->spryoff = luaL_checkfixed(L, 3);
|
||||
break;
|
||||
case mobj_sprzoff:
|
||||
mo->sprzoff = luaL_checkfixed(L, 3);
|
||||
break;
|
||||
default:
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS);
|
||||
I_Assert(lua_istable(L, -1));
|
||||
|
|
|
|||
16
src/p_mobj.c
16
src/p_mobj.c
|
|
@ -12974,16 +12974,30 @@ ML_NOCLIMB : Direction not controllable
|
|||
|
||||
mobj->angle = FixedAngle(mthing->angle*FRACUNIT);
|
||||
|
||||
if ((mobj->flags & MF_SPRING)
|
||||
&& mobj->info->damage != 0
|
||||
&& mobj->info->mass == 0)
|
||||
{
|
||||
// Offset sprite of horizontal springs
|
||||
angle_t a = mobj->angle + ANGLE_180;
|
||||
mobj->sprxoff = FixedMul(mobj->radius, FINECOSINE(a >> ANGLETOFINESHIFT));
|
||||
mobj->spryoff = FixedMul(mobj->radius, FINESINE(a >> ANGLETOFINESHIFT));
|
||||
}
|
||||
|
||||
if ((mthing->options & MTF_AMBUSH)
|
||||
&& (mthing->options & MTF_OBJECTSPECIAL)
|
||||
&& (mobj->flags & MF_PUSHABLE))
|
||||
{
|
||||
mobj->flags2 |= MF2_CLASSICPUSH;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mthing->options & MTF_AMBUSH)
|
||||
{
|
||||
if (mobj->flags & MF_SPRING && mobj->info->damage)
|
||||
if ((mobj->flags & MF_SPRING) && mobj->info->damage)
|
||||
{
|
||||
mobj->angle += ANGLE_22h;
|
||||
}
|
||||
|
||||
if (mobj->flags & MF_NIGHTSITEM)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -378,6 +378,8 @@ typedef struct mobj_s
|
|||
fixed_t shadowscale; // If this object casts a shadow, and the size relative to radius
|
||||
boolean whiteshadow; // Use white shadow, set to true by default for fullbright objects
|
||||
|
||||
fixed_t sprxoff, spryoff, sprzoff; // Sprite offsets in real space, does NOT affect position or collision
|
||||
|
||||
// WARNING: New fields must be added separately to savegame and Lua.
|
||||
} mobj_t;
|
||||
|
||||
|
|
|
|||
|
|
@ -1675,6 +1675,10 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj)
|
|||
ghost->modeltilt = mobj->modeltilt;
|
||||
#endif
|
||||
|
||||
ghost->sprxoff = mobj->sprxoff;
|
||||
ghost->spryoff = mobj->spryoff;
|
||||
ghost->sprzoff = mobj->sprzoff;
|
||||
|
||||
if (mobj->flags2 & MF2_OBJECTFLIP)
|
||||
ghost->flags |= MF2_OBJECTFLIP;
|
||||
|
||||
|
|
|
|||
|
|
@ -1436,6 +1436,10 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale,
|
|||
//
|
||||
static void R_ProjectSprite(mobj_t *thing)
|
||||
{
|
||||
const fixed_t thingxpos = thing->x + thing->sprxoff;
|
||||
const fixed_t thingypos = thing->y + thing->spryoff;
|
||||
const fixed_t thingzpos = thing->z + thing->sprzoff;
|
||||
|
||||
fixed_t tr_x, tr_y;
|
||||
fixed_t gxt, gyt;
|
||||
fixed_t tx, tz;
|
||||
|
|
@ -1472,8 +1476,8 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
fixed_t this_scale = thing->scale;
|
||||
|
||||
// transform the origin point
|
||||
tr_x = thing->x - viewx;
|
||||
tr_y = thing->y - viewy;
|
||||
tr_x = thingxpos - viewx;
|
||||
tr_y = thingypos - viewy;
|
||||
|
||||
gxt = FixedMul(tr_x, viewcos);
|
||||
gyt = -FixedMul(tr_y, viewsin);
|
||||
|
|
@ -1539,9 +1543,9 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
if (sprframe->rotate != SRF_SINGLE || papersprite)
|
||||
{
|
||||
if (thing->player)
|
||||
ang = R_PointToAngle (thing->x, thing->y) - thing->player->frameangle;
|
||||
ang = R_PointToAngle (thingxpos, thingypos) - thing->player->frameangle;
|
||||
else
|
||||
ang = R_PointToAngle (thing->x, thing->y) - thing->angle;
|
||||
ang = R_PointToAngle (thingxpos, thingypos) - thing->angle;
|
||||
}
|
||||
|
||||
if (sprframe->rotate == SRF_SINGLE)
|
||||
|
|
@ -1554,7 +1558,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
else
|
||||
{
|
||||
// choose a different rotation based on player view
|
||||
//ang = R_PointToAngle (thing->x, thing->y) - thing->angle;
|
||||
//ang = R_PointToAngle (thingxpos, thingypos) - thing->angle;
|
||||
|
||||
if ((ang < ANGLE_180) && (sprframe->rotate & SRF_RIGHT)) // See from right
|
||||
rot = 6; // F7 slot
|
||||
|
|
@ -1701,7 +1705,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
if (x2 < portalclipstart || x1 > portalclipend)
|
||||
return;
|
||||
|
||||
if (P_PointOnLineSide(thing->x, thing->y, portalclipline) != 0)
|
||||
if (P_PointOnLineSide(thingxpos, thingypos, portalclipline) != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1711,12 +1715,12 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
// When vertical flipped, draw sprites from the top down, at least as far as offsets are concerned.
|
||||
// sprite height - sprite topoffset is the proper inverse of the vertical offset, of course.
|
||||
// remember gz and gzt should be seperated by sprite height, not thing height - thing height can be shorter than the sprite itself sometimes!
|
||||
gz = thing->z + thing->height - FixedMul(spritecachedinfo[lump].topoffset, this_scale);
|
||||
gz = thingzpos + thing->height - FixedMul(spritecachedinfo[lump].topoffset, this_scale);
|
||||
gzt = gz + FixedMul(spritecachedinfo[lump].height, this_scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
gzt = thing->z + FixedMul(spritecachedinfo[lump].topoffset, this_scale);
|
||||
gzt = thingzpos + FixedMul(spritecachedinfo[lump].topoffset, this_scale);
|
||||
gz = gzt - FixedMul(spritecachedinfo[lump].height, this_scale);
|
||||
}
|
||||
|
||||
|
|
@ -1733,7 +1737,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
light = thing->subsector->sector->numlights - 1;
|
||||
|
||||
for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) {
|
||||
fixed_t h = thing->subsector->sector->lightlist[lightnum].slope ? P_GetZAt(thing->subsector->sector->lightlist[lightnum].slope, thing->x, thing->y)
|
||||
fixed_t h = thing->subsector->sector->lightlist[lightnum].slope ? P_GetZAt(thing->subsector->sector->lightlist[lightnum].slope, thingxpos, thingypos)
|
||||
: thing->subsector->sector->lightlist[lightnum].height;
|
||||
if (h <= gzt) {
|
||||
light = lightnum - 1;
|
||||
|
|
@ -1762,12 +1766,12 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
if (heightsec != -1 && phs != -1) // only clip things which are in special sectors
|
||||
{
|
||||
if (viewz < sectors[phs].floorheight ?
|
||||
thing->z >= sectors[heightsec].floorheight :
|
||||
thingzpos >= sectors[heightsec].floorheight :
|
||||
gzt < sectors[heightsec].floorheight)
|
||||
return;
|
||||
if (viewz > sectors[phs].ceilingheight ?
|
||||
gzt < sectors[heightsec].ceilingheight && viewz >= sectors[heightsec].ceilingheight :
|
||||
thing->z >= sectors[heightsec].ceilingheight)
|
||||
thingzpos >= sectors[heightsec].ceilingheight)
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1778,12 +1782,12 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
vis->scale = yscale; //<<detailshift;
|
||||
vis->sortscale = sortscale;
|
||||
vis->dispoffset = thing->info->dispoffset; // Monster Iestyn: 23/11/15
|
||||
vis->gx = thing->x;
|
||||
vis->gy = thing->y;
|
||||
vis->gx = thingxpos;
|
||||
vis->gy = thingypos;
|
||||
vis->gz = gz;
|
||||
vis->gzt = gzt;
|
||||
vis->thingheight = thing->height;
|
||||
vis->pz = thing->z;
|
||||
vis->pz = thingzpos;
|
||||
vis->pzt = vis->pz + vis->thingheight;
|
||||
vis->texturemid = vis->gzt - viewz;
|
||||
vis->scalestep = scalestep;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue