Commit 8a30576d by James R.

Merge branch 'plane-sorting-fix-part-3' into 'next'

Improved sprite sorting against 3d floors See merge request !1235
parents 6d9e036c 40e95477
...@@ -1084,14 +1084,6 @@ static void R_SplitSprite(vissprite_t *sprite) ...@@ -1084,14 +1084,6 @@ static void R_SplitSprite(vissprite_t *sprite)
sprite->sz = cutfrac; sprite->sz = cutfrac;
newsprite->szt = (INT16)(sprite->sz - 1); newsprite->szt = (INT16)(sprite->sz - 1);
if (testheight < sprite->pzt && testheight > sprite->pz)
sprite->pz = newsprite->pzt = testheight;
else
{
newsprite->pz = newsprite->gz;
newsprite->pzt = newsprite->gzt;
}
newsprite->szt -= 8; newsprite->szt -= 8;
newsprite->cut |= SC_TOP; newsprite->cut |= SC_TOP;
...@@ -1314,16 +1306,12 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, ...@@ -1314,16 +1306,12 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale,
shadow->patch = patch; shadow->patch = patch;
shadow->heightsec = vis->heightsec; shadow->heightsec = vis->heightsec;
shadow->thingheight = FRACUNIT;
shadow->pz = groundz + (isflipped ? -shadow->thingheight : 0);
shadow->pzt = shadow->pz + shadow->thingheight;
shadow->mobjflags = 0; shadow->mobjflags = 0;
shadow->sortscale = vis->sortscale; shadow->sortscale = vis->sortscale;
shadow->dispoffset = vis->dispoffset - 5; shadow->dispoffset = vis->dispoffset - 5;
shadow->gx = thing->x; shadow->gx = thing->x;
shadow->gy = thing->y; shadow->gy = thing->y;
shadow->gzt = (isflipped ? shadow->pzt : shadow->pz) + patch->height * shadowyscale / 2; shadow->gzt = groundz + patch->height * shadowyscale / 2;
shadow->gz = shadow->gzt - patch->height * shadowyscale; shadow->gz = shadow->gzt - patch->height * shadowyscale;
shadow->texturemid = FixedMul(thing->scale, FixedDiv(shadow->gzt - viewz, shadowyscale)); shadow->texturemid = FixedMul(thing->scale, FixedDiv(shadow->gzt - viewz, shadowyscale));
if (thing->skin && ((skin_t *)thing->skin)->flags & SF_HIRES) if (thing->skin && ((skin_t *)thing->skin)->flags & SF_HIRES)
...@@ -1953,9 +1941,6 @@ static void R_ProjectSprite(mobj_t *thing) ...@@ -1953,9 +1941,6 @@ static void R_ProjectSprite(mobj_t *thing)
vis->gy = thing->y; vis->gy = thing->y;
vis->gz = gz; vis->gz = gz;
vis->gzt = gzt; vis->gzt = gzt;
vis->thingheight = thing->height;
vis->pz = thing->z;
vis->pzt = vis->pz + vis->thingheight;
vis->texturemid = FixedDiv(gzt - viewz, spriteyscale); vis->texturemid = FixedDiv(gzt - viewz, spriteyscale);
vis->scalestep = scalestep; vis->scalestep = scalestep;
vis->paperoffset = paperoffset; vis->paperoffset = paperoffset;
...@@ -2172,9 +2157,6 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) ...@@ -2172,9 +2157,6 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
vis->gy = thing->y; vis->gy = thing->y;
vis->gz = gz; vis->gz = gz;
vis->gzt = gzt; vis->gzt = gzt;
vis->thingheight = 4*FRACUNIT;
vis->pz = thing->z;
vis->pzt = vis->pz + vis->thingheight;
vis->texturemid = vis->gzt - viewz; vis->texturemid = vis->gzt - viewz;
vis->scalestep = 0; vis->scalestep = 0;
vis->paperdistance = 0; vis->paperdistance = 0;
...@@ -2568,19 +2550,15 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps ...@@ -2568,19 +2550,15 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps
planeobjectz = P_GetZAt(r2->plane->slope, rover->gx, rover->gy, r2->plane->height); planeobjectz = P_GetZAt(r2->plane->slope, rover->gx, rover->gy, r2->plane->height);
planecameraz = P_GetZAt(r2->plane->slope, viewx, viewy, r2->plane->height); planecameraz = P_GetZAt(r2->plane->slope, viewx, viewy, r2->plane->height);
if (rover->mobjflags & MF_NOCLIPHEIGHT) // bird: if any part of the sprite peeks in front the plane
if (planecameraz < viewz)
{ {
//Objects with NOCLIPHEIGHT can appear halfway in. if (rover->gzt >= planeobjectz)
if (planecameraz < viewz && rover->pz+(rover->thingheight/2) >= planeobjectz)
continue;
if (planecameraz > viewz && rover->pzt-(rover->thingheight/2) <= planeobjectz)
continue; continue;
} }
else else if (planecameraz > viewz)
{ {
if (planecameraz < viewz && rover->pz >= planeobjectz) if (rover->gz <= planeobjectz)
continue;
if (planecameraz > viewz && rover->pzt <= planeobjectz)
continue; continue;
} }
...@@ -2613,7 +2591,7 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps ...@@ -2613,7 +2591,7 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps
} }
else if (r2->thickseg) else if (r2->thickseg)
{ {
fixed_t topplaneobjectz, topplanecameraz, botplaneobjectz, botplanecameraz; //fixed_t topplaneobjectz, topplanecameraz, botplaneobjectz, botplanecameraz;
if (rover->x1 > r2->thickseg->x2 || rover->x2 < r2->thickseg->x1) if (rover->x1 > r2->thickseg->x2 || rover->x2 < r2->thickseg->x1)
continue; continue;
...@@ -2624,6 +2602,11 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps ...@@ -2624,6 +2602,11 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps
if (scale <= rover->sortscale) if (scale <= rover->sortscale)
continue; continue;
// bird: Always sort sprites behind segs. This helps the plane
// sorting above too. Basically if the sprite gets sorted behind
// the seg here, it will be behind the plane too, since planes
// are added after segs in the list.
#if 0
topplaneobjectz = P_GetFFloorTopZAt (r2->ffloor, rover->gx, rover->gy); topplaneobjectz = P_GetFFloorTopZAt (r2->ffloor, rover->gx, rover->gy);
topplanecameraz = P_GetFFloorTopZAt (r2->ffloor, viewx, viewy); topplanecameraz = P_GetFFloorTopZAt (r2->ffloor, viewx, viewy);
botplaneobjectz = P_GetFFloorBottomZAt(r2->ffloor, rover->gx, rover->gy); botplaneobjectz = P_GetFFloorBottomZAt(r2->ffloor, rover->gx, rover->gy);
...@@ -2632,6 +2615,7 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps ...@@ -2632,6 +2615,7 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps
if ((topplanecameraz > viewz && botplanecameraz < viewz) || if ((topplanecameraz > viewz && botplanecameraz < viewz) ||
(topplanecameraz < viewz && rover->gzt < topplaneobjectz) || (topplanecameraz < viewz && rover->gzt < topplaneobjectz) ||
(botplanecameraz > viewz && rover->gz > botplaneobjectz)) (botplanecameraz > viewz && rover->gz > botplaneobjectz))
#endif
{ {
entry = R_CreateDrawNode(NULL); entry = R_CreateDrawNode(NULL);
(entry->prev = r2->prev)->next = entry; (entry->prev = r2->prev)->next = entry;
...@@ -2672,23 +2656,11 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps ...@@ -2672,23 +2656,11 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps
if (!behind) if (!behind)
{ {
fixed_t z1 = 0, z2 = 0; // FIXME: calculate gz and gzt for splats properly and use that
if (rover->mobj->z < viewz)
if (rover->mobj->z - viewz > 0) infront = (r2->sprite->mobj->z >= rover->mobj->z);
{
z1 = rover->pz;
z2 = r2->sprite->pz;
}
else else
{ infront = (r2->sprite->mobj->z <= rover->mobj->z);
z1 = r2->sprite->pz;
z2 = rover->pz;
}
z1 -= viewz;
z2 -= viewz;
infront = (z1 >= z2);
} }
} }
else else
......
...@@ -151,8 +151,7 @@ typedef struct vissprite_s ...@@ -151,8 +151,7 @@ typedef struct vissprite_s
INT32 x1, x2; INT32 x1, x2;
fixed_t gx, gy; // for line side calculation fixed_t gx, gy; // for line side calculation
fixed_t gz, gzt; // global bottom/top for silhouette clipping fixed_t gz, gzt; // global bottom/top for silhouette clipping and sorting with 3D floors
fixed_t pz, pzt; // physical bottom/top for sorting with 3D floors
fixed_t startfrac; // horizontal position of x1 fixed_t startfrac; // horizontal position of x1
fixed_t scale; fixed_t scale;
...@@ -186,7 +185,6 @@ typedef struct vissprite_s ...@@ -186,7 +185,6 @@ typedef struct vissprite_s
fixed_t xscale; fixed_t xscale;
// Precalculated top and bottom screen coords for the sprite. // Precalculated top and bottom screen coords for the sprite.
fixed_t thingheight; // The actual height of the thing (for 3D floors)
sector_t *sector; // The sector containing the thing. sector_t *sector; // The sector containing the thing.
INT16 sz, szt; INT16 sz, szt;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment