- some work on sector rendering code for new renderer.

git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@426 b0f79afe-0144-0410-b225-9a4edf0717df
This commit is contained in:
Christoph Oelckers 2009-08-30 19:23:52 +00:00
parent 82a658fbfe
commit 317ac991b7
11 changed files with 334 additions and 110 deletions

View file

@ -298,7 +298,7 @@ static bool CopyPlaneIfValid (secplane_t *dest, const secplane_t *source, const
// by hardware rendering
//
//==========================================================================
sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, bool back)
sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool back)
{
if (!sec->heightsec || sec->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC || sec->heightsec==sec) return sec;
@ -311,8 +311,6 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, bool back)
#endif
#endif
area_t in_area = ::in_area;
if (in_area==area_above)
{
if (sec->heightsec->MoreFlags&SECF_FAKEFLOORONLY || sec->GetTexture(sector_t::ceiling)==skyflatnum) in_area=area_normal;

View file

@ -112,14 +112,6 @@ FTextureID gl_GetSpriteFrame(unsigned sprite, int frame, int rot, angle_t angle,
void gl_RenderBSPNode (void *node);
bool gl_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsector);
void gl_CheckViewArea(vertex_t *v1, vertex_t *v2, sector_t *frontsector, sector_t *backsector);
sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, bool back);
void gl_GetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblending,
int *tm, int *sb, int *db, int *be);
void gl_SetFogParams(int _fogdensity, PalEntry _outsidefogcolor, int _outsidefogdensity, int _skyfog);
int gl_CalcLightLevel(int lightlevel, int rellight, bool weapon);
PalEntry gl_CalcLightColor(int lightlevel, PalEntry pe, int blendfactor);
float gl_GetFogDensity(int lightlevel, PalEntry fogcolor);
typedef enum
{
@ -131,6 +123,21 @@ typedef enum
extern area_t in_area;
sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool back);
inline sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, bool back)
{
return gl_FakeFlat(sec, dest, in_area, back);
}
void gl_GetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblending,
int *tm, int *sb, int *db, int *be);
void gl_SetFogParams(int _fogdensity, PalEntry _outsidefogcolor, int _outsidefogdensity, int _skyfog);
int gl_CalcLightLevel(int lightlevel, int rellight, bool weapon);
PalEntry gl_CalcLightColor(int lightlevel, PalEntry pe, int blendfactor);
float gl_GetFogDensity(int lightlevel, PalEntry fogcolor);
struct TexFilter_s
{
int minfilter;

View file

@ -68,7 +68,7 @@ static glcycle_t totalssms;
static sector_t fakesec;
void FRenderHackInfo::StartScene()
void FDrawInfo::StartScene()
{
sectorrenderflags.Resize(numsectors);
ss_renderflags.Resize(numsubsectors);
@ -117,7 +117,7 @@ void FRenderHackInfo::StartScene()
//
//==========================================================================
void FRenderHackInfo::AddOtherFloorPlane(int sector, gl_subsectorrendernode * node)
void FDrawInfo::AddOtherFloorPlane(int sector, gl_subsectorrendernode * node)
{
int oldcnt = otherfloorplanes.Size();
@ -130,7 +130,7 @@ void FRenderHackInfo::AddOtherFloorPlane(int sector, gl_subsectorrendernode * no
otherfloorplanes[sector] = node;
}
void FRenderHackInfo::AddOtherCeilingPlane(int sector, gl_subsectorrendernode * node)
void FDrawInfo::AddOtherCeilingPlane(int sector, gl_subsectorrendernode * node)
{
int oldcnt = otherceilingplanes.Size();
@ -149,7 +149,7 @@ void FRenderHackInfo::AddOtherCeilingPlane(int sector, gl_subsectorrendernode *
// Collects all sectors that might need a fake ceiling
//
//==========================================================================
void FRenderHackInfo::AddUpperMissingTexture(seg_t * seg, fixed_t backheight)
void FDrawInfo::AddUpperMissingTexture(seg_t * seg, fixed_t backheight)
{
if (!seg->backsector) return;
@ -206,7 +206,7 @@ void FRenderHackInfo::AddUpperMissingTexture(seg_t * seg, fixed_t backheight)
// Collects all sectors that might need a fake floor
//
//==========================================================================
void FRenderHackInfo::AddLowerMissingTexture(seg_t * seg, fixed_t backheight)
void FDrawInfo::AddLowerMissingTexture(seg_t * seg, fixed_t backheight)
{
if (!seg->backsector) return;
if (seg->backsector->transdoor)
@ -275,7 +275,7 @@ void FRenderHackInfo::AddLowerMissingTexture(seg_t * seg, fixed_t backheight)
//
//
//==========================================================================
bool FRenderHackInfo::DoOneSectorUpper(subsector_t * subsec, fixed_t planez)
bool FDrawInfo::DoOneSectorUpper(subsector_t * subsec, fixed_t planez)
{
// Is there a one-sided wall in this sector?
// Do this first to avoid unnecessary recursion
@ -333,7 +333,7 @@ bool FRenderHackInfo::DoOneSectorUpper(subsector_t * subsec, fixed_t planez)
//
//
//==========================================================================
bool FRenderHackInfo::DoOneSectorLower(subsector_t * subsec, fixed_t planez)
bool FDrawInfo::DoOneSectorLower(subsector_t * subsec, fixed_t planez)
{
// Is there a one-sided wall in this subsector?
// Do this first to avoid unnecessary recursion
@ -392,7 +392,7 @@ bool FRenderHackInfo::DoOneSectorLower(subsector_t * subsec, fixed_t planez)
//
//
//==========================================================================
bool FRenderHackInfo::DoFakeBridge(subsector_t * subsec, fixed_t planez)
bool FDrawInfo::DoFakeBridge(subsector_t * subsec, fixed_t planez)
{
// Is there a one-sided wall in this sector?
// Do this first to avoid unnecessary recursion
@ -445,7 +445,7 @@ bool FRenderHackInfo::DoFakeBridge(subsector_t * subsec, fixed_t planez)
//
//
//==========================================================================
bool FRenderHackInfo::DoFakeCeilingBridge(subsector_t * subsec, fixed_t planez)
bool FDrawInfo::DoFakeCeilingBridge(subsector_t * subsec, fixed_t planez)
{
// Is there a one-sided wall in this sector?
// Do this first to avoid unnecessary recursion
@ -499,7 +499,7 @@ bool FRenderHackInfo::DoFakeCeilingBridge(subsector_t * subsec, fixed_t planez)
// Draws the fake planes
//
//==========================================================================
void FRenderHackInfo::HandleMissingTextures()
void FDrawInfo::HandleMissingTextures()
{
sector_t fake;
totalms.Clock();
@ -659,7 +659,7 @@ void FRenderHackInfo::HandleMissingTextures()
//
//==========================================================================
void FRenderHackInfo::DrawUnhandledMissingTextures()
void FDrawInfo::DrawUnhandledMissingTextures()
{
validcount++;
for(int i=MissingUpperSegs.Size()-1; i>=0; i--)
@ -725,7 +725,7 @@ ADD_STAT(missingtextures)
//
//==========================================================================
void FRenderHackInfo::AddHackedSubsector(subsector_t * sub)
void FDrawInfo::AddHackedSubsector(subsector_t * sub)
{
if (!(level.flags & LEVEL_HEXENFORMAT))
{
@ -740,7 +740,7 @@ void FRenderHackInfo::AddHackedSubsector(subsector_t * sub)
//
//==========================================================================
bool FRenderHackInfo::CheckAnchorFloor(subsector_t * sub)
bool FDrawInfo::CheckAnchorFloor(subsector_t * sub)
{
// This subsector has a one sided wall and can be used.
if (sub->hacked==3) return true;
@ -782,7 +782,7 @@ static bool inview;
static subsector_t * viewsubsector;
static TArray<seg_t *> lowersegs;
bool FRenderHackInfo::CollectSubsectorsFloor(subsector_t * sub, sector_t * anchor)
bool FDrawInfo::CollectSubsectorsFloor(subsector_t * sub, sector_t * anchor)
{
// mark it checked
@ -846,7 +846,7 @@ bool FRenderHackInfo::CollectSubsectorsFloor(subsector_t * sub, sector_t * ancho
//
//==========================================================================
bool FRenderHackInfo::CheckAnchorCeiling(subsector_t * sub)
bool FDrawInfo::CheckAnchorCeiling(subsector_t * sub)
{
// This subsector has a one sided wall and can be used.
if (sub->hacked==3) return true;
@ -885,7 +885,7 @@ bool FRenderHackInfo::CheckAnchorCeiling(subsector_t * sub)
//
//==========================================================================
bool FRenderHackInfo::CollectSubsectorsCeiling(subsector_t * sub, sector_t * anchor)
bool FDrawInfo::CollectSubsectorsCeiling(subsector_t * sub, sector_t * anchor)
{
// mark it checked
sub->validcount=validcount;
@ -945,7 +945,7 @@ bool FRenderHackInfo::CollectSubsectorsCeiling(subsector_t * sub, sector_t * anc
//
//==========================================================================
void FRenderHackInfo::HandleHackedSubsectors()
void FDrawInfo::HandleHackedSubsectors()
{
lowershcount=uppershcount=0;
totalssms.Reset();
@ -1026,12 +1026,12 @@ ADD_STAT(sectorhacks)
//
//==========================================================================
void FRenderHackInfo::AddFloorStack(subsector_t * sub)
void FDrawInfo::AddFloorStack(subsector_t * sub)
{
FloorStacks.Push(sub);
}
void FRenderHackInfo::AddCeilingStack(subsector_t * sub)
void FDrawInfo::AddCeilingStack(subsector_t * sub)
{
CeilingStacks.Push(sub);
}
@ -1042,7 +1042,7 @@ void FRenderHackInfo::AddCeilingStack(subsector_t * sub)
//
//==========================================================================
void FRenderHackInfo::CollectSectorStacksCeiling(subsector_t * sub, sector_t * anchor)
void FDrawInfo::CollectSectorStacksCeiling(subsector_t * sub, sector_t * anchor)
{
// mark it checked
sub->validcount=validcount;
@ -1089,7 +1089,7 @@ void FRenderHackInfo::CollectSectorStacksCeiling(subsector_t * sub, sector_t * a
//
//==========================================================================
void FRenderHackInfo::CollectSectorStacksFloor(subsector_t * sub, sector_t * anchor)
void FDrawInfo::CollectSectorStacksFloor(subsector_t * sub, sector_t * anchor)
{
// mark it checked
sub->validcount=validcount;
@ -1136,7 +1136,7 @@ void FRenderHackInfo::CollectSectorStacksFloor(subsector_t * sub, sector_t * anc
//
//==========================================================================
void FRenderHackInfo::ProcessSectorStacks()
void FDrawInfo::ProcessSectorStacks()
{
unsigned int i;

View file

@ -13,7 +13,7 @@ struct gl_subsectorrendernode
};
struct FRenderHackInfo
struct FDrawInfo
{
struct MissingTextureInfo

View file

@ -31,6 +31,7 @@
#include "r_state.h"
#include "v_palette.h"
#include "a_sharedglobal.h"
#include "r_sky.h"
#include "gl/common/glc_geometric.h"
#include "gl/common/glc_convert.h"
#include "gl/new_renderer/gl2_renderer.h"
@ -66,7 +67,7 @@ void MakeTextureMatrix(GLSectorPlane &splane, FMaterial *mat, Matrix3x4 &matx)
//
//===========================================================================
void FGLSectorRenderData::AddDependency(sector_t *sec, BYTE *vertexmap, BYTE *sectormap)
void FSectorRenderData::AddDependency(sector_t *sec, BYTE *vertexmap, BYTE *sectormap)
{
int secnum = sec - sectors;
if (sectormap != NULL) sectormap[secnum>>3] |= (secnum&7);
@ -88,7 +89,7 @@ void FGLSectorRenderData::AddDependency(sector_t *sec, BYTE *vertexmap, BYTE *se
//
//===========================================================================
void FGLSectorRenderData::SetupDependencies()
void FSectorRenderData::SetupDependencies()
{
BYTE *vertexmap = new BYTE[numvertexes/8+1];
BYTE *linemap = new BYTE[numlines/8+1];
@ -169,7 +170,7 @@ void FGLSectorRenderData::SetupDependencies()
//
//===========================================================================
void FGLSectorRenderData::Init(int sector)
void FSectorRenderData::Init(int sector)
{
mSector = &sectors[sector];
SetupDependencies();
@ -181,11 +182,11 @@ void FGLSectorRenderData::Init(int sector)
//
//===========================================================================
void FGLSectorRenderData::CreatePlane(int in_area, sector_t *sec, GLSectorPlane &splane,
void FSectorRenderData::CreatePlane(FSectorPlaneObject *plane,
int in_area, sector_t *sec, GLSectorPlane &splane,
int lightlevel, FDynamicColormap *cm,
float alpha, bool additive, int whichplanes, bool opaque)
float alpha, bool additive, bool upside, bool opaque)
{
FGLSectorPlaneRenderData &Plane = mPlanes[in_area][mPlanes[in_area].Reserve(1)];
FTexture *tex = TexMan[splane.texture];
FMaterial *mat = GLRenderer2->GetMaterial(tex, false, 0);
@ -225,43 +226,49 @@ void FGLSectorRenderData::CreatePlane(int in_area, sector_t *sec, GLSectorPlane
BasicProps.mAlphaThreshold = 0;
}
plane->mMat = mat;
plane->mAlpha = alpha < 1.0 - FLT_EPSILON;
plane->mSector = &sectors[sec->sectornum];
BasicProps.SetRenderStyle(style, opaque);
BasicProps.mMaterial = mat;
BasicProps.mPrimitiveType = GL_TRIANGLE_FAN; // all subsectors are drawn as triangle fans
BasicProps.mDesaturation = cm->Desaturate;
BasicVertexProps.SetLighting(lightlevel, cm, 0/*rellight*/, additive, tex);
BasicVertexProps.a = quickertoint(alpha*255);
BasicVertexProps.a = (unsigned char)quickertoint(alpha*255);
Plane.mPlane = splane.plane;
Plane.mUpside = !!(whichplanes&1);
Plane.mDownside = !!(whichplanes&2);
Plane.mLightEffect = !splane.texture.Exists();
Plane.mSubsectorData.Resize(sec->subsectorcount);
for(int i=0;i<sec->subsectorcount;i++)
plane->mPlane = splane.plane;
plane->mUpside = upside;
plane->mLightEffect = !splane.texture.Exists();
plane->mPrimitiveIndex = mPrimitives.Reserve(sec->subsectorcount);
FSubsectorPrimitive *prim = &mPrimitives[plane->mPrimitiveIndex];
for(int i=0;i<sec->subsectorcount;i++, prim++)
{
FGLSubsectorPlaneRenderData *ssrd = &Plane.mSubsectorData[i];
subsector_t *sub = sec->subsectors[i];
ssrd->mPrimitive = BasicProps;
ssrd->mPrimitive.mVertexCount = sub->numlines;
ssrd->mVertices.Resize(sub->numlines);
for(int j=0; j<sub->numlines; j++)
prim->mPrimitive = BasicProps;
prim->mPrimitive.mVertexCount = sub->numlines;
prim->mPrimitive.mVertexStart = mVertices.Reserve(sub->numlines);
FVertex3D *vert = &mVertices[prim->mPrimitive.mVertexStart];
for(int j=0; j<sub->numlines; j++, vert++)
{
vertex_t *v = segs[sub->firstline + j].v1;
ssrd->mVertices[j] = BasicVertexProps;
ssrd->mVertices[j].x = v->fx;
ssrd->mVertices[j].y = v->fy;
ssrd->mVertices[j].z = splane.plane.ZatPoint(v->fx, v->fy);
*vert = BasicVertexProps;
vert->x = v->fx;
vert->y = v->fy;
vert->z = splane.plane.ZatPoint(v->fx, v->fy);
Vector uv(v->fx, -v->fy, 0);
uv = matx * uv;
ssrd->mVertices[j].x = uv.X();
ssrd->mVertices[j].y = uv.Y();
vert->u = uv.X();
vert->v = uv.Y();
}
}
}
@ -271,11 +278,11 @@ void FGLSectorRenderData::CreatePlane(int in_area, sector_t *sec, GLSectorPlane
//
//===========================================================================
void FGLSectorRenderData::Invalidate()
void FSectorRenderData::Invalidate()
{
mPlanes[0].Clear();
mPlanes[1].Clear();
mPlanes[2].Clear();
mAreas[0].valid =
mAreas[1].valid =
mAreas[2].valid = false;
}
@ -308,7 +315,7 @@ void FGLSectorRenderData::Invalidate()
//
//===========================================================================
void FGLSectorRenderData::Validate(int in_area)
void FSectorRenderData::Validate(area_t in_area)
{
sector_t copy;
sector_t *sec;
@ -318,13 +325,17 @@ void FGLSectorRenderData::Validate(int in_area)
FDynamicColormap Colormap;
GLSectorPlane splane;
if (mPlanes[in_area].Size() == 0)
if (in_area >= area_above) return;
FSectorAreaData *area = &mAreas[in_area];
if (!area->valid)
{
area->m3DFloorsC.Clear();
area->m3DFloorsF.Clear();
extsector_t::xfloor &x = mSector->e->XFloor;
TArray<FGLSectorPlaneRenderData> &plane = mPlanes[in_area];
::in_area = area_t(in_area);
sec = gl_FakeFlat(mSector, &copy, false);
sec = gl_FakeFlat(mSector, &copy, in_area, false);
// create ceiling plane
@ -332,7 +343,7 @@ void FGLSectorRenderData::Validate(int in_area)
Colormap = *sec->ColorMap;
bool stack = sec->CeilingSkyBox && sec->CeilingSkyBox->bAlways;
float alpha = stack ? sec->CeilingSkyBox->PlaneAlpha/65536.0f : 1.0f-sec->GetCeilingReflect();
if (alpha != 0.0f)
if (alpha != 0.0f && sec->GetTexture(sector_t::ceiling) != skyflatnum)
{
if (x.ffloors.Size())
{
@ -343,8 +354,9 @@ void FGLSectorRenderData::Validate(int in_area)
Colormap.Desaturate = (*light->p_extra_colormap)->Desaturate;
}
splane.GetFromSector(sec, true);
CreatePlane(in_area, sec, splane, lightlevel, &Colormap, alpha, false, 1, !stack);
CreatePlane(&area->mCeiling, in_area, sec, splane, lightlevel, &Colormap, alpha, false, false, !stack);
}
else area->mCeiling.mPrimitiveIndex = -1;
// create floor plane
@ -352,7 +364,7 @@ void FGLSectorRenderData::Validate(int in_area)
Colormap = *sec->ColorMap;
stack = sec->FloorSkyBox && sec->FloorSkyBox->bAlways;
alpha = stack ? sec->FloorSkyBox->PlaneAlpha/65536.0f : 1.0f-sec->GetFloorReflect();
if (alpha != 0.0f)
if (alpha != 0.0f && sec->GetTexture(sector_t::ceiling) != skyflatnum)
{
if (x.ffloors.Size())
{
@ -365,8 +377,10 @@ void FGLSectorRenderData::Validate(int in_area)
Colormap.Desaturate = (*light->p_extra_colormap)->Desaturate;
}
splane.GetFromSector(sec, false);
CreatePlane(in_area, sec, splane, lightlevel, &Colormap, alpha, false, 2, !stack);
if (sec->transdoor) splane.plane.d -= 1;
CreatePlane(&area->mFloor, in_area, sec, splane, lightlevel, &Colormap, alpha, false, true, !stack);
}
else area->mFloor.mPrimitiveIndex = -1;
// create 3d floor planes
@ -402,8 +416,9 @@ void FGLSectorRenderData::Validate(int in_area)
SET_COLOR();
CreatePlane(in_area, sec, splane, lightlevel, &Colormap, rover->alpha/255.f,
!!(rover->flags&FF_ADDITIVETRANS), 1, false);
FSectorPlaneObject *obj = &area->m3DFloorsC[area->m3DFloorsC.Reserve(1)];
CreatePlane(obj, in_area, sec, splane, lightlevel, &Colormap, rover->alpha/255.f,
!!(rover->flags&FF_ADDITIVETRANS), false, false);
lastceilingheight = ff_top;
}
}
@ -419,8 +434,9 @@ void FGLSectorRenderData::Validate(int in_area)
SET_COLOR();
CreatePlane(in_area, sec, splane, lightlevel, &Colormap, rover->alpha/255.f,
!!(rover->flags&FF_ADDITIVETRANS), 1, false);
FSectorPlaneObject *obj = &area->m3DFloorsC[area->m3DFloorsC.Reserve(1)];
CreatePlane(obj, in_area, sec, splane, lightlevel, &Colormap, rover->alpha/255.f,
!!(rover->flags&FF_ADDITIVETRANS), false, false);
lastceilingheight = ff_bottom;
if (rover->alpha<255) lastceilingheight++;
@ -458,8 +474,9 @@ void FGLSectorRenderData::Validate(int in_area)
SET_COLOR();
}
CreatePlane(in_area, sec, splane, lightlevel, &Colormap, rover->alpha/255.f,
!!(rover->flags&FF_ADDITIVETRANS), 2, false);
FSectorPlaneObject *obj = &area->m3DFloorsF[area->m3DFloorsF.Reserve(1)];
CreatePlane(obj, in_area, sec, splane, lightlevel, &Colormap, rover->alpha/255.f,
!!(rover->flags&FF_ADDITIVETRANS), true, false);
lastfloorheight = ff_bottom;
}
@ -477,8 +494,9 @@ void FGLSectorRenderData::Validate(int in_area)
SET_COLOR();
CreatePlane(in_area, sec, splane, lightlevel, &Colormap, rover->alpha/255.f,
!!(rover->flags&FF_ADDITIVETRANS), 2, false);
FSectorPlaneObject *obj = &area->m3DFloorsF[area->m3DFloorsF.Reserve(1)];
CreatePlane(obj, in_area, sec, splane, lightlevel, &Colormap, rover->alpha/255.f,
!!(rover->flags&FF_ADDITIVETRANS), true, false);
lastfloorheight = ff_top;
if (rover->alpha < 255) lastfloorheight--;
@ -491,6 +509,110 @@ void FGLSectorRenderData::Validate(int in_area)
}
//===========================================================================
//
//
//
//===========================================================================
void FSectorRenderData::Process(subsector_t *sub, area_t in_area)
{
extsector_t::xfloor &x = mSector->e->XFloor;
GLDrawInfo *di = GLRenderer2->mDrawInfo;
int subno = sub - subsectors;
di->ss_renderflags[subno] |= SSRF_PROCESSED;
if (sub->hacked & 1) di->AddHackedSubsector(sub);
if (sub->degenerate) return;
Validate(in_area);
FSectorAreaData *area = &mAreas[in_area];
byte &srf = di->sectorrenderflags[mSector->sectornum];
//
//
//
// do floors
//
//
//
if ((srf&SSRF_RENDERFLOOR) || area->mFloor.isVisible(di->mViewpoint, true))
{
di->ss_renderflags[subno] |= SSRF_RENDERFLOOR;
// process the original floor first.
if (mSector->FloorSkyBox && mSector->FloorSkyBox->bAlways) di->AddFloorStack(sub);
if (!(srf & SSRF_RENDERFLOOR))
{
srf |= SSRF_RENDERFLOOR;
if (area->mFloor.mPrimitiveIndex >= 0) di->AddObject(&area->mFloor);
}
}
//
//
//
// do ceilings
//
//
//
if ((srf & SSRF_RENDERCEILING) || area->mCeiling.isVisible(di->mViewpoint, false))
{
di->ss_renderflags[subno]|=SSRF_RENDERCEILING;
// process the original ceiling first.
if (mSector->CeilingSkyBox && mSector->CeilingSkyBox->bAlways) di->AddCeilingStack(sub);
if (!(srf & SSRF_RENDERCEILING))
{
srf |= SSRF_RENDERCEILING;
if (area->mCeiling.mPrimitiveIndex >= 0) di->AddObject(&area->mCeiling);
}
}
//
//
//
// do 3D floors
//
//
//
if (x.ffloors.Size())
{
player_t * player=players[consoleplayer].camera->player;
// do the plane setup only once and just mark all subsectors that have to be processed
di->ss_renderflags[sub-subsectors]|=SSRF_RENDER3DPLANES;
if (!(srf & SSRF_RENDER3DPLANES))
{
srf |= SSRF_RENDER3DPLANES;
for(unsigned k = 0; k < area->m3DFloorsC.Size(); k++)
{
if (area->m3DFloorsC[k].isVisible(di->mViewpoint, false))
{
di->AddObject(&area->m3DFloorsC[k]);
}
else break; // 3D floors are ordered so if one is not visible the remaining ones are neither.
}
for(unsigned k = 0; k < area->m3DFloorsF.Size(); k++)
{
if (area->m3DFloorsF[k].isVisible(di->mViewpoint, true))
{
di->AddObject(&area->m3DFloorsF[k]);
}
else break; // 3D floors are ordered so if one is not visible the remaining ones are neither.
}
}
}
}
}// namespace

View file

@ -11,27 +11,55 @@ struct FDynamicColormap;
namespace GLRendererNew
{
struct FGLSubsectorPlaneRenderData
struct FRenderObject
{
int mIndex;
TArray<FVertex3D> mVertices;
FMaterial *mMat; // this is needed for sorting geometry on a higher level than single primitives
bool mAlpha;
};
//==========================================================================
//
// Flats
//
//==========================================================================
struct FSubsectorPrimitive
{
int mSubsector;
FPrimitive3D mPrimitive;
};
struct FGLSectorPlaneRenderData
{
secplane_t mPlane;
bool mUpside;
bool mDownside;
bool mLightEffect; // do not render when a fullbright effect is on
TArray<FGLSubsectorPlaneRenderData> mSubsectorData;
};
struct FGLSectorRenderData
struct FSectorPlaneObject : public FRenderObject
{
sector_t *mSector;
TArray<FGLSectorPlaneRenderData> mPlanes[3];
secplane_t mPlane;
bool mUpside;
bool mLightEffect; // do not render when a fullbright effect is on
int mPrimitiveIndex;
bool isVisible(const FVector3 &viewpoint, bool upside) // upside must be passed for optimization
{
if (upside) return mPlane.ZatPoint(viewpoint.X, viewpoint.Y) > viewpoint.Z;
else return mPlane.ZatPoint(viewpoint.X, viewpoint.Y) < viewpoint.Z;
}
};
struct FSectorAreaData
{
bool valid;
FSectorPlaneObject mCeiling;
FSectorPlaneObject mFloor;
TArray<FSectorPlaneObject> m3DFloorsC;
TArray<FSectorPlaneObject> m3DFloorsF;
};
struct FSectorRenderData
{
sector_t *mSector;
FSectorAreaData mAreas[3];
TArray<FVertex3D> mVertices;
TArray<FSubsectorPrimitive> mPrimitives;
TArray<sector_t *> SectorDependencies;
TArray<line_t *> LineDependencies;
@ -41,13 +69,15 @@ struct FGLSectorRenderData
void SetupDependencies();
void CreatePlane(int in_area, sector_t *sec, GLSectorPlane &splane,
void CreatePlane(FSectorPlaneObject *plane,
int in_area, sector_t *sec, GLSectorPlane &splane,
int lightlevel, FDynamicColormap *cm,
float alpha, bool additive, int whichplanes, bool opaque);
float alpha, bool additive, bool upside, bool opaque);
void Init(int sector);
void Invalidate();
void Validate(int in_area);
void Validate(area_t in_area);
void Process(subsector_t *sub, area_t in_area);
};

View file

@ -164,8 +164,10 @@ void GL2Renderer::ProcessParticle(particle_t *part, sector_t *sector)
//
//===========================================================================
void GL2Renderer::ProcessSector(sector_t *fakesector, subsector_t *sub)
void GL2Renderer::ProcessSector(sector_t *sec, subsector_t *sub)
{
FSectorRenderData *srd = &mSectorData[sec->sectornum];
srd->Process(sub, in_area);
}
//===========================================================================
@ -729,6 +731,11 @@ void GL2Renderer::SetViewMatrix(bool mirror, bool planemirror)
}
//-----------------------------------------------------------------------------
//
//
//-----------------------------------------------------------------------------
void GL2Renderer::ProcessScene()
{
// for testing. The sky must be rendered with depth buffer disabled.
@ -744,22 +751,39 @@ void GL2Renderer::ProcessScene()
}
}
//-----------------------------------------------------------------------------
//
//
//-----------------------------------------------------------------------------
void GL2Renderer::InvalidateSector(sector_t *sec, int mode)
{
// mode == 0: only invalidate this sector
// mode == 1: invalidate all attached sectors
// mode == 2: invalidate everything that depends on this sector
if (mode = 0)
mSectorData[sec-sectors].Invalidate();
if (mode > 0)
{
mSectorData[sec-sectors].Invalidate();
}
else
{
FGLSectorRenderData *srd = &mSectorData[sec-sectors];
FSectorRenderData *srd = &mSectorData[sec->sectornum];
for(unsigned i = 0; i < srd->SectorDependencies.Size(); i++)
{
int secno = srd->SectorDependencies[i]->sectornum;
mSectorData[secno].Invalidate();
}
if (mode == 2)
{
// invalidate lines and vertices
}
}
}
//-----------------------------------------------------------------------------
//
//
//-----------------------------------------------------------------------------
void GL2Renderer::InvalidateSidedef(side_t *side, int mode)
{
}

View file

@ -3,6 +3,7 @@
#include "tarray.h"
#include "gl/common/glc_renderer.h"
#include "gl/common/glc_renderhacks.h"
#include "gl/new_renderer/gl2_geom.h"
namespace GLRendererNew
@ -15,7 +16,7 @@ class FShader;
class FGLTexture;
class FPrimitiveBuffer2D;
class FSkyDrawer;
struct FGLSubsectorData;
struct GLDrawInfo;
class GL2Renderer : public GLRendererBase
@ -27,8 +28,9 @@ public:
FPrimitiveBuffer2D *mRender2D;
FMaterialContainer *mDefaultMaterial;
FSkyDrawer *mSkyDrawer;
GLDrawInfo *mDrawInfo;
TArray<FGLSectorRenderData> mSectorData;
TArray<FSectorRenderData> mSectorData;
GL2Renderer()
{
@ -37,6 +39,7 @@ public:
mRender2D = NULL;
mDefaultMaterial = NULL;
mSkyDrawer = NULL;
mDrawInfo = NULL;
}
~GL2Renderer();
@ -89,6 +92,46 @@ public:
FShader *GetShader(const char *name);
};
//==========================================================================
//
// The draw info for one viewpoint
//
//==========================================================================
struct GLDrawInfo : public FDrawInfo
{
FVector3 mViewpoint;
bool temporary;
GLDrawInfo * next;
void StartScene()
{
mDrawLists[0].Clear();
mDrawLists[1].Clear();
}
//void SetupFloodStencil(wallseg * ws) [;
//void ClearFloodStencil(wallseg * ws);
//void DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, bool ceiling);
void FloodUpperGap(seg_t * seg) {}
void FloodLowerGap(seg_t * seg) {}
public:
TArray<FRenderObject*> mDrawLists[2]; // one for opaque, one for translucent
void AddObject(FRenderObject *obj)
{
mDrawLists[obj->mAlpha].Push(obj);
}
//static void StartDrawInfo(GLDrawInfo * hi);
//static void EndDrawInfo();
};
// same as GLRenderer but with another type because this will be needed throughout the
// new renderer.
extern GL2Renderer *GLRenderer2;

View file

@ -898,7 +898,7 @@ void GLDrawInfo::StartDrawInfo(GLDrawInfo * di)
void GLDrawInfo::StartScene()
{
FRenderHackInfo::StartScene();
FDrawInfo::StartScene();
next=gl_drawinfo;
gl_drawinfo=this;
for(int i=0;i<GLDL_TYPES;i++) drawlists[i].Reset();

View file

@ -105,7 +105,7 @@ public:
//
//==========================================================================
class GLDrawInfo : public FRenderHackInfo
class GLDrawInfo : public FDrawInfo
{
friend class GLFlat;

View file

@ -71,7 +71,7 @@ extern void ChildSigHandler (int signum);
#include "tempfiles.h"
#include "templates.h"
#include "stats.h"
#include "timidity/timidity.h"
#include "timidity2/timidity.h"
#define GZIP_ID1 31
#define GZIP_ID2 139