mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 23:12:24 +00:00
- moved most of gl_setup.cpp to r_data as this is only some data setup in the main map data structures.
- made currentmapsections array something nicer to look at and made it a member of the scene drawer class.
This commit is contained in:
parent
202d209eb8
commit
8080e039e0
12 changed files with 101 additions and 40 deletions
|
@ -1043,7 +1043,6 @@ set (PCH_SOURCES
|
||||||
g_statusbar/sbar_mugshot.cpp
|
g_statusbar/sbar_mugshot.cpp
|
||||||
g_statusbar/shared_sbar.cpp
|
g_statusbar/shared_sbar.cpp
|
||||||
gl/compatibility/gl_20.cpp
|
gl/compatibility/gl_20.cpp
|
||||||
gl/data/gl_setup.cpp
|
|
||||||
gl/data/gl_vertexbuffer.cpp
|
gl/data/gl_vertexbuffer.cpp
|
||||||
gl/dynlights/gl_glow.cpp
|
gl/dynlights/gl_glow.cpp
|
||||||
gl/dynlights/gl_lightbuffer.cpp
|
gl/dynlights/gl_lightbuffer.cpp
|
||||||
|
@ -1150,6 +1149,7 @@ set (PCH_SOURCES
|
||||||
r_data/sprites.cpp
|
r_data/sprites.cpp
|
||||||
r_data/portalgroups.cpp
|
r_data/portalgroups.cpp
|
||||||
r_data/voxels.cpp
|
r_data/voxels.cpp
|
||||||
|
r_data/renderinfo.cpp
|
||||||
r_data/renderstyle.cpp
|
r_data/renderstyle.cpp
|
||||||
r_data/r_interpolate.cpp
|
r_data/r_interpolate.cpp
|
||||||
r_data/r_vanillatrans.cpp
|
r_data/r_vanillatrans.cpp
|
||||||
|
|
|
@ -91,6 +91,7 @@ struct FLevelLocals
|
||||||
TArray<FLinePortal*> linkedPortals; // only the linked portals, this is used to speed up looking for them in P_CollectConnectedGroups.
|
TArray<FLinePortal*> linkedPortals; // only the linked portals, this is used to speed up looking for them in P_CollectConnectedGroups.
|
||||||
TArray<FSectorPortalGroup *> portalGroups;
|
TArray<FSectorPortalGroup *> portalGroups;
|
||||||
TArray<FLinePortalSpan> linePortalSpans;
|
TArray<FLinePortalSpan> linePortalSpans;
|
||||||
|
int NumMapSections;
|
||||||
|
|
||||||
TArray<zone_t> Zones;
|
TArray<zone_t> Zones;
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,4 @@ inline int getExtraLight()
|
||||||
return r_viewpoint.extralight * gl_weaponlight;
|
return r_viewpoint.extralight * gl_weaponlight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct GLSectorStackPortal;
|
|
||||||
|
|
||||||
extern TArray<uint8_t> currentmapsection;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -423,7 +423,7 @@ void GLSceneDrawer::DoSubsector(subsector_t * sub)
|
||||||
if (!sector) return;
|
if (!sector) return;
|
||||||
|
|
||||||
// If the mapsections differ this subsector can't possibly be visible from the current view point
|
// If the mapsections differ this subsector can't possibly be visible from the current view point
|
||||||
if (!(currentmapsection[sub->mapsection>>3] & (1 << (sub->mapsection & 7)))) return;
|
if (!CurrentMapSections[sub->mapsection]) return;
|
||||||
if (sub->flags & SSECF_POLYORG) return; // never render polyobject origin subsectors because their vertices no longer are where one may expect.
|
if (sub->flags & SSECF_POLYORG) return; // never render polyobject origin subsectors because their vertices no longer are where one may expect.
|
||||||
|
|
||||||
if (gl_drawinfo->ss_renderflags[sub->Index()] & SSRF_SEEN)
|
if (gl_drawinfo->ss_renderflags[sub->Index()] & SSRF_SEEN)
|
||||||
|
|
|
@ -579,20 +579,22 @@ GLPortal * GLPortal::FindPortal(const void * src)
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
//
|
// Save/RestoreMapSection
|
||||||
|
//
|
||||||
|
// saves CurrentMapSection for a recursive call of SceneDrawer::DrawScene
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void GLPortal::SaveMapSection()
|
void GLPortal::SaveMapSection()
|
||||||
{
|
{
|
||||||
savedmapsection.Resize(currentmapsection.Size());
|
SavedMapSection = std::move(drawer->CurrentMapSections);
|
||||||
memcpy(&savedmapsection[0], ¤tmapsection[0], currentmapsection.Size());
|
drawer->CurrentMapSections.Resize(SavedMapSection.Size());
|
||||||
memset(¤tmapsection[0], 0, currentmapsection.Size());
|
drawer->CurrentMapSections.Zero();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLPortal::RestoreMapSection()
|
void GLPortal::RestoreMapSection()
|
||||||
{
|
{
|
||||||
memcpy(¤tmapsection[0], &savedmapsection[0], currentmapsection.Size());
|
drawer->CurrentMapSections = std::move(SavedMapSection);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -650,7 +652,7 @@ void GLSkyboxPortal::DrawContents()
|
||||||
int mapsection = R_PointInSubsector(r_viewpoint.Pos)->mapsection;
|
int mapsection = R_PointInSubsector(r_viewpoint.Pos)->mapsection;
|
||||||
|
|
||||||
SaveMapSection();
|
SaveMapSection();
|
||||||
currentmapsection[mapsection >> 3] |= 1 << (mapsection & 7);
|
drawer->CurrentMapSections.Set(mapsection);
|
||||||
|
|
||||||
drawer->DrawScene(DM_SKYPORTAL);
|
drawer->DrawScene(DM_SKYPORTAL);
|
||||||
portal->mFlags &= ~PORTSF_INSKYBOX;
|
portal->mFlags &= ~PORTSF_INSKYBOX;
|
||||||
|
@ -732,7 +734,7 @@ void GLSectorStackPortal::SetupCoverage()
|
||||||
for(int j=0;j<sub->portalcoverage[plane].sscount; j++)
|
for(int j=0;j<sub->portalcoverage[plane].sscount; j++)
|
||||||
{
|
{
|
||||||
subsector_t *dsub = &::level.subsectors[sub->portalcoverage[plane].subsectors[j]];
|
subsector_t *dsub = &::level.subsectors[sub->portalcoverage[plane].subsectors[j]];
|
||||||
currentmapsection[dsub->mapsection>>3] |= 1 << (dsub->mapsection&7);
|
drawer->CurrentMapSections.Set(dsub->mapsection);
|
||||||
gl_drawinfo->ss_renderflags[dsub->Index()] |= SSRF_SEEN;
|
gl_drawinfo->ss_renderflags[dsub->Index()] |= SSRF_SEEN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1055,8 +1057,7 @@ void GLLineToLinePortal::DrawContents()
|
||||||
if (line->sidedef[0]->Flags & WALLF_POLYOBJ)
|
if (line->sidedef[0]->Flags & WALLF_POLYOBJ)
|
||||||
sub = R_PointInSubsector(line->v1->fixX(), line->v1->fixY());
|
sub = R_PointInSubsector(line->v1->fixX(), line->v1->fixY());
|
||||||
else sub = line->frontsector->subsectors[0];
|
else sub = line->frontsector->subsectors[0];
|
||||||
int mapsection = sub->mapsection;
|
drawer->CurrentMapSections.Set(sub->mapsection);
|
||||||
currentmapsection[mapsection >> 3] |= 1 << (mapsection & 7);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLRenderer->mViewActor = nullptr;
|
GLRenderer->mViewActor = nullptr;
|
||||||
|
|
|
@ -109,7 +109,7 @@ private:
|
||||||
ActorRenderFlags savedvisibility;
|
ActorRenderFlags savedvisibility;
|
||||||
GLPortal *PrevPortal;
|
GLPortal *PrevPortal;
|
||||||
GLPortal *PrevClipPortal;
|
GLPortal *PrevClipPortal;
|
||||||
TArray<uint8_t> savedmapsection;
|
BitArray SavedMapSection;
|
||||||
TArray<unsigned int> mPrimIndices;
|
TArray<unsigned int> mPrimIndices;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -88,7 +88,6 @@ EXTERN_CVAR (Bool, r_drawvoxels)
|
||||||
extern bool NoInterpolateView;
|
extern bool NoInterpolateView;
|
||||||
|
|
||||||
area_t in_area;
|
area_t in_area;
|
||||||
TArray<uint8_t> currentmapsection;
|
|
||||||
int camtexcount;
|
int camtexcount;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -737,8 +736,9 @@ void GLSceneDrawer::ProcessScene(bool toscreen)
|
||||||
GLPortal::BeginScene();
|
GLPortal::BeginScene();
|
||||||
|
|
||||||
int mapsection = R_PointInSubsector(r_viewpoint.Pos)->mapsection;
|
int mapsection = R_PointInSubsector(r_viewpoint.Pos)->mapsection;
|
||||||
memset(¤tmapsection[0], 0, currentmapsection.Size());
|
CurrentMapSections.Resize(level.NumMapSections);
|
||||||
currentmapsection[mapsection>>3] |= 1 << (mapsection & 7);
|
CurrentMapSections.Zero();
|
||||||
|
CurrentMapSections.Set(mapsection);
|
||||||
DrawScene(toscreen ? DM_MAINVIEW : DM_OFFSCREEN);
|
DrawScene(toscreen ? DM_MAINVIEW : DM_OFFSCREEN);
|
||||||
FDrawInfo::EndDrawInfo();
|
FDrawInfo::EndDrawInfo();
|
||||||
|
|
||||||
|
@ -1129,10 +1129,12 @@ void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, do
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void gl_PreprocessLevel();
|
|
||||||
void FGLInterface::PreprocessLevel()
|
void FGLInterface::PreprocessLevel()
|
||||||
{
|
{
|
||||||
gl_PreprocessLevel();
|
if (GLRenderer != NULL)
|
||||||
|
{
|
||||||
|
GLRenderer->SetupLevel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t FGLInterface::GetCaps()
|
uint32_t FGLInterface::GetCaps()
|
||||||
|
|
|
@ -45,6 +45,7 @@ public:
|
||||||
Clipper clipper;
|
Clipper clipper;
|
||||||
int FixedColormap;
|
int FixedColormap;
|
||||||
area_t in_area;
|
area_t in_area;
|
||||||
|
BitArray CurrentMapSections; // this cannot be a single number, because a group of portals with the same displacement may link different sections.
|
||||||
|
|
||||||
angle_t FrustumAngle();
|
angle_t FrustumAngle();
|
||||||
void SetViewMatrix(float vx, float vy, float vz, bool mirror, bool planemirror);
|
void SetViewMatrix(float vx, float vy, float vz, bool mirror, bool planemirror);
|
||||||
|
@ -71,7 +72,7 @@ public:
|
||||||
void DrawPSprite(player_t * player, DPSprite *psp, float sx, float sy, bool hudModelStep, int OverrideShader, bool alphatexture);
|
void DrawPSprite(player_t * player, DPSprite *psp, float sx, float sy, bool hudModelStep, int OverrideShader, bool alphatexture);
|
||||||
void DrawPlayerSprites(sector_t * viewsector, bool hudModelStep);
|
void DrawPlayerSprites(sector_t * viewsector, bool hudModelStep);
|
||||||
void DrawTargeterSprites();
|
void DrawTargeterSprites();
|
||||||
|
|
||||||
void InitClipper(angle_t a1, angle_t a2)
|
void InitClipper(angle_t a1, angle_t a2)
|
||||||
{
|
{
|
||||||
clipper.Clear();
|
clipper.Clear();
|
||||||
|
|
|
@ -721,7 +721,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this thing is in a map section that's not in view it can't possibly be visible
|
// If this thing is in a map section that's not in view it can't possibly be visible
|
||||||
if (!thruportal && !(currentmapsection[thing->subsector->mapsection >> 3] & (1 << (thing->subsector->mapsection & 7)))) return;
|
if (!thruportal && !mDrawer->CurrentMapSections[thing->subsector->mapsection]) return;
|
||||||
|
|
||||||
// [RH] Interpolate the sprite's position to make it look smooth
|
// [RH] Interpolate the sprite's position to make it look smooth
|
||||||
DVector3 thingpos = thing->InterpolatedPosition(r_viewpoint.TicFrac);
|
DVector3 thingpos = thing->InterpolatedPosition(r_viewpoint.TicFrac);
|
||||||
|
|
|
@ -129,6 +129,7 @@ void P_SetSlopes ();
|
||||||
void P_CopySlopes();
|
void P_CopySlopes();
|
||||||
void BloodCrypt (void *data, int key, int len);
|
void BloodCrypt (void *data, int key, int len);
|
||||||
void P_ClearUDMFKeys();
|
void P_ClearUDMFKeys();
|
||||||
|
void InitRenderInfo();
|
||||||
|
|
||||||
extern AActor *P_SpawnMapThing (FMapThing *mthing, int position);
|
extern AActor *P_SpawnMapThing (FMapThing *mthing, int position);
|
||||||
|
|
||||||
|
@ -4120,6 +4121,7 @@ void P_SetupLevel (const char *lumpname, int position)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This must be done BEFORE the PolyObj Spawn!!!
|
// This must be done BEFORE the PolyObj Spawn!!!
|
||||||
|
InitRenderInfo();
|
||||||
Renderer->PreprocessLevel();
|
Renderer->PreprocessLevel();
|
||||||
InitPortalGroups();
|
InitPortalGroups();
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
//
|
//
|
||||||
/*
|
/*
|
||||||
** gl_setup.cpp
|
** gl_setup.cpp
|
||||||
** Initializes the data structures required by the GL renderer to handle
|
** Initializes the data structures required by the hardware renderer to handle
|
||||||
** a level
|
** render hacks and optimization.
|
||||||
**
|
**
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
@ -42,13 +42,6 @@
|
||||||
#include "g_level.h"
|
#include "g_level.h"
|
||||||
#include "g_levellocals.h"
|
#include "g_levellocals.h"
|
||||||
|
|
||||||
#include "gl/renderer/gl_renderer.h"
|
|
||||||
#include "gl/data/gl_data.h"
|
|
||||||
#include "gl/data/gl_vertexbuffer.h"
|
|
||||||
#include "gl/dynlights/gl_dynlight.h"
|
|
||||||
#include "gl/dynlights/gl_glow.h"
|
|
||||||
#include "gl/utility/gl_clock.h"
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// Map section generation
|
// Map section generation
|
||||||
|
@ -208,7 +201,7 @@ struct MapSectionGenerator
|
||||||
}
|
}
|
||||||
while (set);
|
while (set);
|
||||||
num = MergeMapSections(num);
|
num = MergeMapSections(num);
|
||||||
currentmapsection.Resize(1 + num/8);
|
level.NumMapSections = num;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Printf("%d map sections found\n", num);
|
Printf("%d map sections found\n", num);
|
||||||
#endif
|
#endif
|
||||||
|
@ -544,7 +537,7 @@ static void PrepareSegs()
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void gl_PreprocessLevel()
|
void InitRenderInfo()
|
||||||
{
|
{
|
||||||
PrepareSegs();
|
PrepareSegs();
|
||||||
PrepareSectorData();
|
PrepareSectorData();
|
||||||
|
@ -581,11 +574,6 @@ void gl_PreprocessLevel()
|
||||||
}
|
}
|
||||||
delete[] checkmap;
|
delete[] checkmap;
|
||||||
|
|
||||||
if (GLRenderer != NULL)
|
|
||||||
{
|
|
||||||
GLRenderer->SetupLevel();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
gl_CreateSections();
|
gl_CreateSections();
|
||||||
#endif
|
#endif
|
71
src/tarray.h
71
src/tarray.h
|
@ -1259,3 +1259,74 @@ public:
|
||||||
Clear();
|
Clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class BitArray
|
||||||
|
{
|
||||||
|
TArray<uint8_t> bytes;
|
||||||
|
unsigned size;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void Resize(unsigned elem)
|
||||||
|
{
|
||||||
|
bytes.Resize((elem + 7) / 8);
|
||||||
|
size = elem;
|
||||||
|
}
|
||||||
|
|
||||||
|
BitArray() : size(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
BitArray(const BitArray & arr)
|
||||||
|
{
|
||||||
|
bytes = arr.bytes;
|
||||||
|
size = arr.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
BitArray &operator=(const BitArray & arr)
|
||||||
|
{
|
||||||
|
bytes = arr.bytes;
|
||||||
|
size = arr.size;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
BitArray(BitArray && arr)
|
||||||
|
{
|
||||||
|
bytes = std::move(arr.bytes);
|
||||||
|
size = arr.size;
|
||||||
|
arr.size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BitArray &operator=(BitArray && arr)
|
||||||
|
{
|
||||||
|
bytes = std::move(arr.bytes);
|
||||||
|
size = arr.size;
|
||||||
|
arr.size = 0;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator[](size_t index) const
|
||||||
|
{
|
||||||
|
return !!(bytes[index >> 3] & (1 << (index & 7)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Set(size_t index)
|
||||||
|
{
|
||||||
|
bytes[index >> 3] |= (1 << (index & 7));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clear(size_t index)
|
||||||
|
{
|
||||||
|
bytes[index >> 3] &= ~(1 << (index & 7));
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned Size() const
|
||||||
|
{
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Zero()
|
||||||
|
{
|
||||||
|
memset(&bytes[0], 0, bytes.Size());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue