diff --git a/src/r_things.c b/src/r_things.c index 6130815e7..c31d295a8 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1152,14 +1152,17 @@ fixed_t R_GetShadowZ( mobj_t *thing, pslope_t **shadowslope, fixed_t interpx, fixed_t interpy, fixed_t interpz) { + fixed_t halfHeight = interpz + (thing->height >> 1); boolean isflipped = thing->eflags & MFE_VERTICALFLIP; + fixed_t floorz = P_GetFloorZ(thing, thing->subsector->sector, interpx, interpy, NULL); + fixed_t ceilingz = P_GetCeilingZ(thing, thing->subsector->sector, interpx, interpy, NULL); fixed_t z, groundz = isflipped ? INT32_MAX : INT32_MIN; pslope_t *slope, *groundslope = NULL; msecnode_t *node; sector_t *sector; ffloor_t *rover; -#define CHECKZ (isflipped ? z > interpz+thing->height/2 && z < groundz : z < interpz+thing->height/2 && z > groundz) +#define CHECKZ (isflipped ? z > halfHeight && z < groundz : z < halfHeight && z > groundz) for (node = thing->touching_sectorlist; node; node = node->m_sectorlist_next) { @@ -1194,10 +1197,10 @@ fixed_t R_GetShadowZ( } } - if (isflipped ? (thing->ceilingz < groundz - (!groundslope ? 0 : FixedMul(abs(groundslope->zdelta), thing->radius*3/2))) - : (thing->floorz > groundz + (!groundslope ? 0 : FixedMul(abs(groundslope->zdelta), thing->radius*3/2)))) + if (isflipped ? (ceilingz < groundz - (!groundslope ? 0 : FixedMul(abs(groundslope->zdelta), thing->radius*3/2))) + : (floorz > groundz + (!groundslope ? 0 : FixedMul(abs(groundslope->zdelta), thing->radius*3/2)))) { - groundz = isflipped ? thing->ceilingz : thing->floorz; + groundz = isflipped ? ceilingz : floorz; groundslope = NULL; } @@ -1208,10 +1211,10 @@ fixed_t R_GetShadowZ( { INT32 xl, xh, yl, yh, bx, by; - xl = (unsigned)(thing->x - thing->radius - bmaporgx)>>MAPBLOCKSHIFT; - xh = (unsigned)(thing->x + thing->radius - bmaporgx)>>MAPBLOCKSHIFT; - yl = (unsigned)(thing->y - thing->radius - bmaporgy)>>MAPBLOCKSHIFT; - yh = (unsigned)(thing->y + thing->radius - bmaporgy)>>MAPBLOCKSHIFT; + xl = (unsigned)(interpx - thing->radius - bmaporgx)>>MAPBLOCKSHIFT; + xh = (unsigned)(interpx + thing->radius - bmaporgx)>>MAPBLOCKSHIFT; + yl = (unsigned)(interpy - thing->radius - bmaporgy)>>MAPBLOCKSHIFT; + yh = (unsigned)(interpy + thing->radius - bmaporgy)>>MAPBLOCKSHIFT; BMBOUNDFIX(xl, xh, yl, yh); @@ -1248,7 +1251,7 @@ fixed_t R_GetShadowZ( // We're inside it! Yess... z = po->lines[0]->backsector->ceilingheight; - if (z < thing->z+thing->height/2 && z > groundz) + if (z < halfHeight && z > groundz) { groundz = z; groundslope = NULL;