mirror of
https://github.com/ZDoom/gzdoom-last-svn.git
synced 2025-06-04 03:00:47 +00:00
- Updated to ZDoom r3124 (software 3D floors).
- Adapted GZDoom code to changes. git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@1184 b0f79afe-0144-0410-b225-9a4edf0717df
This commit is contained in:
parent
ced25f823f
commit
3764a7484d
32 changed files with 1800 additions and 426 deletions
324
src/r_bsp.cpp
324
src/r_bsp.cpp
|
@ -42,6 +42,7 @@
|
|||
#include "r_plane.h"
|
||||
#include "r_draw.h"
|
||||
#include "r_things.h"
|
||||
#include "r_3dfloors.h"
|
||||
#include "a_sharedglobal.h"
|
||||
#include "g_level.h"
|
||||
#include "nodebuild.h"
|
||||
|
@ -189,6 +190,10 @@ bool R_ClipWallSegment (int first, int last, bool solid)
|
|||
{
|
||||
// Post is entirely visible (above start).
|
||||
R_StoreWallRange (first, last);
|
||||
if (fake3D & FAKE3D_FAKEMASK)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Insert a new clippost for solid walls.
|
||||
if (solid)
|
||||
|
@ -217,7 +222,7 @@ bool R_ClipWallSegment (int first, int last, bool solid)
|
|||
R_StoreWallRange (first, start->first);
|
||||
|
||||
// Adjust the clip size for solid walls
|
||||
if (solid)
|
||||
if (solid && !(fake3D & FAKE3D_FAKEMASK))
|
||||
{
|
||||
start->first = first;
|
||||
}
|
||||
|
@ -246,6 +251,10 @@ bool R_ClipWallSegment (int first, int last, bool solid)
|
|||
R_StoreWallRange (next->last, last);
|
||||
|
||||
crunch:
|
||||
if (fake3D & FAKE3D_FAKEMASK)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (solid)
|
||||
{
|
||||
// Adjust the clip size.
|
||||
|
@ -715,8 +724,10 @@ void R_AddLine (seg_t *line)
|
|||
WallDepthScale = WallInvZstep * WallTMapScale2;
|
||||
WallDepthOrg = -WallUoverZstep * WallTMapScale2;
|
||||
|
||||
backsector = line->backsector;
|
||||
|
||||
if (!(fake3D & FAKE3D_FAKEBACK))
|
||||
{
|
||||
backsector = line->backsector;
|
||||
}
|
||||
rw_frontcz1 = frontsector->ceilingplane.ZatPoint (line->v1->x, line->v1->y);
|
||||
rw_frontfz1 = frontsector->floorplane.ZatPoint (line->v1->x, line->v1->y);
|
||||
rw_frontcz2 = frontsector->ceilingplane.ZatPoint (line->v2->x, line->v2->y);
|
||||
|
@ -732,9 +743,11 @@ void R_AddLine (seg_t *line)
|
|||
}
|
||||
else
|
||||
{
|
||||
// killough 3/8/98, 4/4/98: hack for invisible ceilings / deep water
|
||||
backsector = R_FakeFlat (backsector, &tempsec, NULL, NULL, true);
|
||||
|
||||
// kg3D - its fake, no transfer_heights
|
||||
if (!(fake3D & FAKE3D_FAKEBACK))
|
||||
{ // killough 3/8/98, 4/4/98: hack for invisible ceilings / deep water
|
||||
backsector = R_FakeFlat (backsector, &tempsec, NULL, NULL, true);
|
||||
}
|
||||
doorclosed = 0; // killough 4/16/98
|
||||
|
||||
rw_backcz1 = backsector->ceilingplane.ZatPoint (line->v1->x, line->v1->y);
|
||||
|
@ -817,6 +830,10 @@ void R_AddLine (seg_t *line)
|
|||
// [RH] and rotation
|
||||
|| backsector->GetAngle(sector_t::floor) != frontsector->GetAngle(sector_t::floor)
|
||||
|| backsector->GetAngle(sector_t::ceiling) != frontsector->GetAngle(sector_t::ceiling)
|
||||
|
||||
// kg3D - and fake lights
|
||||
|| (frontsector->e && frontsector->e->XFloor.lightlist.Size())
|
||||
|| (backsector->e && backsector->e->XFloor.lightlist.Size())
|
||||
)
|
||||
{
|
||||
solid = false;
|
||||
|
@ -1003,65 +1020,6 @@ static bool R_CheckBBox (fixed_t *bspcoord) // killough 1/28/98: static
|
|||
return true;
|
||||
}
|
||||
|
||||
void R_GetExtraLight (int *light, const secplane_t &plane, FExtraLight *el)
|
||||
{
|
||||
FDynamicColormap *floodcolormap;
|
||||
int floodlight;
|
||||
bool flooding;
|
||||
vertex_t **triangle;
|
||||
int i, j;
|
||||
fixed_t diff;
|
||||
|
||||
if (el == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
triangle = frontsector->Triangle;
|
||||
flooding = false;
|
||||
floodcolormap = basecolormap;
|
||||
floodlight = *light;
|
||||
|
||||
for (i = 0; i < el->NumUsedLights; ++i)
|
||||
{
|
||||
for (j = 0; j < 3; ++j)
|
||||
{
|
||||
diff = plane.ZatPoint (triangle[j]) - el->Lights[i].Plane.ZatPoint (triangle[j]);
|
||||
if (diff != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (diff >= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (!flooding || el->Lights[i].bFlooder)
|
||||
{
|
||||
if (el->Lights[i].Master == NULL)
|
||||
{
|
||||
basecolormap = floodcolormap;
|
||||
*light = floodlight;
|
||||
}
|
||||
else
|
||||
{
|
||||
basecolormap = el->Lights[i].Master->ColorMap;
|
||||
*light = el->Lights[i].Master->lightlevel;
|
||||
if (el->Lights[i].bFlooder)
|
||||
{
|
||||
flooding = true;
|
||||
floodcolormap = basecolormap;
|
||||
floodlight = *light;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FMiniBSP Constructor
|
||||
|
@ -1129,6 +1087,24 @@ static void R_AddPolyobjs(subsector_t *sub)
|
|||
}
|
||||
}
|
||||
|
||||
// kg3D - add fake segs, never rendered
|
||||
void R_FakeDrawLoop(subsector_t *sub)
|
||||
{
|
||||
int count;
|
||||
seg_t* line;
|
||||
|
||||
count = sub->numlines;
|
||||
line = sub->firstline;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
if ((line->sidedef) && !(line->sidedef->Flags & WALLF_POLYOBJ))
|
||||
{
|
||||
R_AddLine (line);
|
||||
}
|
||||
line++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// R_Subsector
|
||||
|
@ -1144,6 +1120,13 @@ void R_Subsector (subsector_t *sub)
|
|||
int floorlightlevel; // killough 3/16/98: set floor lightlevel
|
||||
int ceilinglightlevel; // killough 4/11/98
|
||||
bool outersubsector;
|
||||
int fll, cll;
|
||||
|
||||
// kg3D - fake floor stuff
|
||||
visplane_t *backupfp;
|
||||
visplane_t *backupcp;
|
||||
//secplane_t templane;
|
||||
lightlist_t *light;
|
||||
|
||||
if (InSubsector != NULL)
|
||||
{ // InSubsector is not NULL. This means we are rendering from a mini-BSP.
|
||||
|
@ -1181,13 +1164,26 @@ void R_Subsector (subsector_t *sub)
|
|||
frontsector = R_FakeFlat(frontsector, &tempsec, &floorlightlevel,
|
||||
&ceilinglightlevel, false); // killough 4/11/98
|
||||
|
||||
basecolormap = frontsector->ColorMap;
|
||||
R_GetExtraLight (&ceilinglightlevel, frontsector->ceilingplane, frontsector->ExtraLights);
|
||||
fll = floorlightlevel;
|
||||
cll = ceilinglightlevel;
|
||||
|
||||
// [RH] set foggy flag
|
||||
foggy = level.fadeto || frontsector->ColorMap->Fade || (level.flags & LEVEL_HASFADETABLE);
|
||||
r_actualextralight = foggy ? 0 : extralight << 4;
|
||||
basecolormap = frontsector->ColorMap;
|
||||
|
||||
// kg3D - fake lights
|
||||
if (fixedlightlev < 0 && frontsector->e && frontsector->e->XFloor.lightlist.Size())
|
||||
{
|
||||
light = P_GetPlaneLight(frontsector, &frontsector->ceilingplane, false);
|
||||
basecolormap = light->extra_colormap;
|
||||
ceilinglightlevel = *light->p_lightlevel;
|
||||
}
|
||||
else
|
||||
{
|
||||
basecolormap = frontsector->ColorMap;
|
||||
ceilinglightlevel = frontsector->lightlevel;
|
||||
}
|
||||
|
||||
ceilingplane = frontsector->ceilingplane.ZatPoint (viewx, viewy) > viewz ||
|
||||
frontsector->GetTexture(sector_t::ceiling) == skyflatnum ||
|
||||
(frontsector->CeilingSkyBox != NULL && frontsector->CeilingSkyBox->bAlways) ||
|
||||
|
@ -1207,8 +1203,17 @@ void R_Subsector (subsector_t *sub)
|
|||
frontsector->CeilingSkyBox
|
||||
) : NULL;
|
||||
|
||||
basecolormap = frontsector->ColorMap;
|
||||
R_GetExtraLight (&floorlightlevel, frontsector->floorplane, frontsector->ExtraLights);
|
||||
if (fixedlightlev < 0 && frontsector->e && frontsector->e->XFloor.lightlist.Size())
|
||||
{
|
||||
light = P_GetPlaneLight(frontsector, &frontsector->floorplane, false);
|
||||
basecolormap = light->extra_colormap;
|
||||
floorlightlevel = *light->p_lightlevel;
|
||||
}
|
||||
else
|
||||
{
|
||||
basecolormap = frontsector->ColorMap;
|
||||
floorlightlevel = frontsector->lightlevel;
|
||||
}
|
||||
|
||||
// killough 3/7/98: Add (x,y) offsets to flats, add deep water check
|
||||
// killough 3/16/98: add floorlightlevel
|
||||
|
@ -1232,6 +1237,142 @@ void R_Subsector (subsector_t *sub)
|
|||
frontsector->FloorSkyBox
|
||||
) : NULL;
|
||||
|
||||
// kg3D - fake planes rendering
|
||||
if (frontsector->e && frontsector->e->XFloor.ffloors.Size())
|
||||
{
|
||||
backupfp = floorplane;
|
||||
backupcp = ceilingplane;
|
||||
// first check all floors
|
||||
for (int i = 0; i < (int)frontsector->e->XFloor.ffloors.Size(); i++)
|
||||
{
|
||||
fakeFloor = frontsector->e->XFloor.ffloors[i];
|
||||
if (!(fakeFloor->flags & FF_EXISTS)) continue;
|
||||
if (!fakeFloor->model) continue;
|
||||
if (fakeFloor->bottom.plane->a || fakeFloor->bottom.plane->b) continue;
|
||||
if (!(fakeFloor->flags & FF_NOSHADE) || (fakeFloor->flags & (FF_RENDERPLANES|FF_RENDERSIDES)))
|
||||
{
|
||||
R_3D_AddHeight(fakeFloor->top.plane, frontsector);
|
||||
}
|
||||
if (!(fakeFloor->flags & FF_RENDERPLANES)) continue;
|
||||
if (fakeFloor->alpha == 0) continue;
|
||||
if (fakeFloor->flags & FF_THISINSIDE && fakeFloor->flags & FF_INVERTSECTOR) continue;
|
||||
fakeAlpha = MIN(Scale(fakeFloor->alpha, OPAQUE, 255), OPAQUE);
|
||||
if (fakeFloor->validcount != validcount)
|
||||
{
|
||||
fakeFloor->validcount = validcount;
|
||||
R_3D_NewClip();
|
||||
}
|
||||
fakeHeight = fakeFloor->top.plane->ZatPoint(frontsector->soundorg[0], frontsector->soundorg[0]);
|
||||
if (fakeHeight < viewz &&
|
||||
fakeHeight > frontsector->floorplane.ZatPoint(frontsector->soundorg[0], frontsector->soundorg[1]))
|
||||
{
|
||||
fake3D = FAKE3D_FAKEFLOOR;
|
||||
tempsec = *fakeFloor->model;
|
||||
tempsec.floorplane = *fakeFloor->top.plane;
|
||||
if (!(fakeFloor->flags & FF_THISINSIDE) && !(fakeFloor->flags & FF_INVERTSECTOR))
|
||||
{
|
||||
tempsec.SetTexture(sector_t::floor, tempsec.GetTexture(sector_t::ceiling));
|
||||
}
|
||||
frontsector = &tempsec;
|
||||
|
||||
if (fixedlightlev < 0 && sub->sector->e->XFloor.lightlist.Size())
|
||||
{
|
||||
light = P_GetPlaneLight(sub->sector, &frontsector->floorplane, false);
|
||||
basecolormap = light->extra_colormap;
|
||||
floorlightlevel = *light->p_lightlevel;
|
||||
}
|
||||
|
||||
ceilingplane = NULL;
|
||||
floorplane = R_FindPlane(frontsector->floorplane,
|
||||
frontsector->GetTexture(sector_t::floor),
|
||||
floorlightlevel + r_actualextralight, // killough 3/16/98
|
||||
frontsector->GetAlpha(sector_t::floor),
|
||||
frontsector->GetXOffset(sector_t::floor), // killough 3/7/98
|
||||
frontsector->GetYOffset(sector_t::floor), // killough 3/7/98
|
||||
frontsector->GetXScale(sector_t::floor),
|
||||
frontsector->GetYScale(sector_t::floor),
|
||||
frontsector->GetAngle(sector_t::floor),
|
||||
frontsector->sky,
|
||||
NULL);
|
||||
|
||||
R_FakeDrawLoop(sub);
|
||||
fake3D = 0;
|
||||
frontsector = sub->sector;
|
||||
}
|
||||
}
|
||||
// and now ceilings
|
||||
for (unsigned int i = 0; i < frontsector->e->XFloor.ffloors.Size(); i++)
|
||||
{
|
||||
fakeFloor = frontsector->e->XFloor.ffloors[i];
|
||||
if (!(fakeFloor->flags & FF_EXISTS)) continue;
|
||||
if (!fakeFloor->model) continue;
|
||||
if (fakeFloor->top.plane->a || fakeFloor->top.plane->b) continue;
|
||||
if (!(fakeFloor->flags & FF_NOSHADE) || (fakeFloor->flags & (FF_RENDERPLANES|FF_RENDERSIDES)))
|
||||
{
|
||||
R_3D_AddHeight(fakeFloor->bottom.plane, frontsector);
|
||||
}
|
||||
if (!(fakeFloor->flags & FF_RENDERPLANES)) continue;
|
||||
if (fakeFloor->alpha == 0) continue;
|
||||
if (!(fakeFloor->flags & FF_THISINSIDE) && (fakeFloor->flags & (FF_SWIMMABLE|FF_INVERTSECTOR)) == (FF_SWIMMABLE|FF_INVERTSECTOR)) continue;
|
||||
fakeAlpha = MIN(Scale(fakeFloor->alpha, OPAQUE, 255), OPAQUE);
|
||||
|
||||
if (fakeFloor->validcount != validcount)
|
||||
{
|
||||
fakeFloor->validcount = validcount;
|
||||
R_3D_NewClip();
|
||||
}
|
||||
fakeHeight = fakeFloor->bottom.plane->ZatPoint(frontsector->soundorg[0], frontsector->soundorg[1]);
|
||||
if (fakeHeight > viewz &&
|
||||
fakeHeight < frontsector->ceilingplane.ZatPoint(frontsector->soundorg[0], frontsector->soundorg[1]))
|
||||
{
|
||||
fake3D = FAKE3D_FAKECEILING;
|
||||
tempsec = *fakeFloor->model;
|
||||
tempsec.ceilingplane = *fakeFloor->bottom.plane;
|
||||
if (!(fakeFloor->flags & FF_THISINSIDE) &&
|
||||
!(fakeFloor->flags & FF_INVERTSECTOR) ||
|
||||
fakeFloor->flags & FF_THISINSIDE &&
|
||||
fakeFloor->flags & FF_INVERTSECTOR)
|
||||
{
|
||||
tempsec.SetTexture(sector_t::ceiling, tempsec.GetTexture(sector_t::floor));
|
||||
}
|
||||
frontsector = &tempsec;
|
||||
|
||||
tempsec.ceilingplane.ChangeHeight(-1);
|
||||
if (fixedlightlev < 0 && sub->sector->e->XFloor.lightlist.Size())
|
||||
{
|
||||
light = P_GetPlaneLight(sub->sector, &frontsector->ceilingplane, false);
|
||||
basecolormap = light->extra_colormap;
|
||||
ceilinglightlevel = *light->p_lightlevel;
|
||||
}
|
||||
tempsec.ceilingplane.ChangeHeight(1);
|
||||
|
||||
floorplane = NULL;
|
||||
ceilingplane = R_FindPlane(frontsector->ceilingplane, // killough 3/8/98
|
||||
frontsector->GetTexture(sector_t::ceiling),
|
||||
ceilinglightlevel + r_actualextralight, // killough 4/11/98
|
||||
frontsector->GetAlpha(sector_t::ceiling),
|
||||
frontsector->GetXOffset(sector_t::ceiling), // killough 3/7/98
|
||||
frontsector->GetYOffset(sector_t::ceiling), // killough 3/7/98
|
||||
frontsector->GetXScale(sector_t::ceiling),
|
||||
frontsector->GetYScale(sector_t::ceiling),
|
||||
frontsector->GetAngle(sector_t::ceiling),
|
||||
frontsector->sky,
|
||||
NULL);
|
||||
|
||||
R_FakeDrawLoop(sub);
|
||||
fake3D = 0;
|
||||
frontsector = sub->sector;
|
||||
}
|
||||
}
|
||||
fakeFloor = NULL;
|
||||
floorplane = backupfp;
|
||||
ceilingplane = backupcp;
|
||||
}
|
||||
|
||||
basecolormap = frontsector->ColorMap;
|
||||
floorlightlevel = fll;
|
||||
ceilinglightlevel = cll;
|
||||
|
||||
// killough 9/18/98: Fix underwater slowdown, by passing real sector
|
||||
// instead of fake one. Improve sprite lighting by basing sprite
|
||||
// lightlevels on floor & ceiling lightlevels in the surrounding area.
|
||||
|
@ -1250,11 +1391,52 @@ void R_Subsector (subsector_t *sub)
|
|||
}
|
||||
}
|
||||
|
||||
count = sub->numlines;
|
||||
line = sub->firstline;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
if (!outersubsector || line->sidedef == NULL || !(line->sidedef->Flags & WALLF_POLYOBJ))
|
||||
{
|
||||
R_AddLine (line);
|
||||
// kg3D - fake planes bounding calculation
|
||||
if (line->backsector && frontsector->e && line->backsector->e->XFloor.ffloors.Size())
|
||||
{
|
||||
backupfp = floorplane;
|
||||
backupcp = ceilingplane;
|
||||
floorplane = NULL;
|
||||
ceilingplane = NULL;
|
||||
for (unsigned int i = 0; i < line->backsector->e->XFloor.ffloors.Size(); i++)
|
||||
{
|
||||
fakeFloor = line->backsector->e->XFloor.ffloors[i];
|
||||
if (!(fakeFloor->flags & FF_EXISTS)) continue;
|
||||
if (!(fakeFloor->flags & FF_RENDERPLANES)) continue;
|
||||
if (!fakeFloor->model) continue;
|
||||
fake3D = FAKE3D_FAKEBACK;
|
||||
tempsec = *fakeFloor->model;
|
||||
tempsec.floorplane = *fakeFloor->top.plane;
|
||||
tempsec.ceilingplane = *fakeFloor->bottom.plane;
|
||||
backsector = &tempsec;
|
||||
if (fakeFloor->validcount != validcount)
|
||||
{
|
||||
fakeFloor->validcount = validcount;
|
||||
R_3D_NewClip();
|
||||
}
|
||||
if (frontsector->CenterFloor() >= backsector->CenterFloor())
|
||||
{
|
||||
fake3D |= FAKE3D_DOWN2UP;
|
||||
}
|
||||
if (frontsector->CenterCeiling() <= backsector->CenterCeiling())
|
||||
{
|
||||
fake3D |= FAKE3D_16;
|
||||
}
|
||||
R_AddLine(line); // fake
|
||||
}
|
||||
fakeFloor = NULL;
|
||||
fake3D = 0;
|
||||
floorplane = backupfp;
|
||||
ceilingplane = backupcp;
|
||||
}
|
||||
R_AddLine (line); // now real
|
||||
}
|
||||
line++;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue