From 47ca45bf18054173396bafc44fcc7e8cdd274e5b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 4 Jan 2017 19:03:33 +0100 Subject: [PATCH] Convert FakeSide to enum class --- src/swrenderer/scene/r_bsp.cpp | 8 ++++---- src/swrenderer/scene/r_bsp.h | 16 ++++++++-------- src/swrenderer/scene/r_things.cpp | 16 ++++++++-------- src/swrenderer/scene/r_things.h | 3 ++- src/swrenderer/things/r_particle.cpp | 6 +++--- src/swrenderer/things/r_particle.h | 3 ++- src/swrenderer/things/r_visiblesprite.h | 3 ++- src/swrenderer/things/r_wallsprite.cpp | 2 +- 8 files changed, 30 insertions(+), 27 deletions(-) diff --git a/src/swrenderer/scene/r_bsp.cpp b/src/swrenderer/scene/r_bsp.cpp index 5b7daa8b2..90866a3a4 100644 --- a/src/swrenderer/scene/r_bsp.cpp +++ b/src/swrenderer/scene/r_bsp.cpp @@ -85,7 +85,7 @@ namespace swrenderer *ceilinglightlevel = sec->GetCeilingLight(); } - FakeSide = FAKED_Center; + FakeSide = WaterFakeSide::Center; const sector_t *s = sec->GetHeightSec(); if (s != NULL) @@ -125,7 +125,7 @@ namespace swrenderer *ceilinglightlevel = s->GetCeilingLight(); } } - FakeSide = FAKED_BelowFloor; + FakeSide = WaterFakeSide::BelowFloor; return tempsec; } return sec; @@ -224,7 +224,7 @@ namespace swrenderer *ceilinglightlevel = s->GetCeilingLight(); } } - FakeSide = FAKED_BelowFloor; + FakeSide = WaterFakeSide::BelowFloor; } else if (heightsec && heightsec->ceilingplane.PointOnSide(ViewPos) <= 0 && orgceilz > refceilz && !(s->MoreFlags & SECF_FAKEFLOORONLY)) @@ -261,7 +261,7 @@ namespace swrenderer *ceilinglightlevel = s->GetCeilingLight(); } } - FakeSide = FAKED_AboveCeiling; + FakeSide = WaterFakeSide::AboveCeiling; } sec = tempsec; // Use other sector } diff --git a/src/swrenderer/scene/r_bsp.h b/src/swrenderer/scene/r_bsp.h index b8e2a5081..4a47da593 100644 --- a/src/swrenderer/scene/r_bsp.h +++ b/src/swrenderer/scene/r_bsp.h @@ -28,11 +28,11 @@ namespace swrenderer // the texture calculations. #define TOO_CLOSE_Z (3072.0 / (1<<12)) - enum + enum class WaterFakeSide { - FAKED_Center, - FAKED_BelowFloor, - FAKED_AboveCeiling + Center, + BelowFloor, + AboveCeiling }; class RenderBSP @@ -57,10 +57,10 @@ namespace swrenderer void AddPolyobjs(subsector_t *sub); void FakeDrawLoop(subsector_t *sub, visplane_t *floorplane, visplane_t *ceilingplane); - subsector_t *InSubsector; - sector_t *frontsector; - uint8_t FakeSide; - bool r_fakingunderwater; + subsector_t *InSubsector = nullptr; + sector_t *frontsector = nullptr; + WaterFakeSide FakeSide = WaterFakeSide::Center; + bool r_fakingunderwater = false; SWRenderLine renderline; }; diff --git a/src/swrenderer/scene/r_things.cpp b/src/swrenderer/scene/r_things.cpp index bd4e9b02b..3b00ccbd4 100644 --- a/src/swrenderer/scene/r_things.cpp +++ b/src/swrenderer/scene/r_things.cpp @@ -602,7 +602,7 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop // R_ProjectSprite // Generates a vissprite for a thing if it might be visible. // -void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling, sector_t *current_sector) +void R_ProjectSprite (AActor *thing, WaterFakeSide fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling, sector_t *current_sector) { double tr_x; double tr_y; @@ -817,12 +817,12 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor if (heightsec != NULL) // only clip things which are in special sectors { - if (fakeside == FAKED_AboveCeiling) + if (fakeside == WaterFakeSide::AboveCeiling) { if (gzt < heightsec->ceilingplane.ZatPoint(pos)) return; } - else if (fakeside == FAKED_BelowFloor) + else if (fakeside == WaterFakeSide::BelowFloor) { if (gzb >= heightsec->floorplane.ZatPoint(pos)) return; @@ -1035,7 +1035,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor // // killough 9/18/98: add lightlevel as parameter, fixing underwater lighting // [RH] Save which side of heightsec sprite is on here. -void R_AddSprites (sector_t *sec, int lightlevel, int fakeside) +void R_AddSprites (sector_t *sec, int lightlevel, WaterFakeSide fakeside) { F3DFloor *fakeceiling = NULL; F3DFloor *fakefloor = NULL; @@ -1447,12 +1447,12 @@ void R_DrawSprite (vissprite_t *spr) if (spr->heightsec && !(spr->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) { // only things in specially marked sectors - if (spr->FakeFlatStat != FAKED_AboveCeiling) + if (spr->FakeFlatStat != WaterFakeSide::AboveCeiling) { double hz = spr->heightsec->floorplane.ZatPoint(spr->gpos); int h = xs_RoundToInt(CenterY - (hz - ViewPos.Z) * scale); - if (spr->FakeFlatStat == FAKED_BelowFloor) + if (spr->FakeFlatStat == WaterFakeSide::BelowFloor) { // seen below floor: clip top if (!spr->bIsVoxel && h > topclip) { @@ -1469,12 +1469,12 @@ void R_DrawSprite (vissprite_t *spr) hzb = MAX(hzb, hz); } } - if (spr->FakeFlatStat != FAKED_BelowFloor && !(spr->heightsec->MoreFlags & SECF_FAKEFLOORONLY)) + if (spr->FakeFlatStat != WaterFakeSide::BelowFloor && !(spr->heightsec->MoreFlags & SECF_FAKEFLOORONLY)) { double hz = spr->heightsec->ceilingplane.ZatPoint(spr->gpos); int h = xs_RoundToInt(CenterY - (hz - ViewPos.Z) * scale); - if (spr->FakeFlatStat == FAKED_AboveCeiling) + if (spr->FakeFlatStat == WaterFakeSide::AboveCeiling) { // seen above ceiling: clip bottom if (!spr->bIsVoxel && h < botclip) { diff --git a/src/swrenderer/scene/r_things.h b/src/swrenderer/scene/r_things.h index 2354f7c0f..5782ea02b 100644 --- a/src/swrenderer/scene/r_things.h +++ b/src/swrenderer/scene/r_things.h @@ -24,6 +24,7 @@ #define __R_THINGS__ #include "swrenderer/things/r_visiblesprite.h" +#include "swrenderer/scene/r_bsp.h" struct particle_t; struct FVoxel; @@ -63,7 +64,7 @@ void R_DrawMaskedColumn (FTexture *texture, fixed_t column, bool unmasked = fals void R_CacheSprite (spritedef_t *sprite); void R_SortVisSprites (int (*compare)(const void *, const void *), size_t first); -void R_AddSprites (sector_t *sec, int lightlevel, int fakeside); +void R_AddSprites (sector_t *sec, int lightlevel, WaterFakeSide fakeside); void R_DrawSprites (); void R_ClearSprites (); void R_DrawMasked (); diff --git a/src/swrenderer/things/r_particle.cpp b/src/swrenderer/things/r_particle.cpp index 9878d362b..489793790 100644 --- a/src/swrenderer/things/r_particle.cpp +++ b/src/swrenderer/things/r_particle.cpp @@ -56,7 +56,7 @@ namespace swrenderer { - void R_ProjectParticle(particle_t *particle, const sector_t *sector, int shade, int fakeside) + void R_ProjectParticle(particle_t *particle, const sector_t *sector, int shade, WaterFakeSide fakeside) { double tr_x, tr_y; double tx, ty; @@ -134,7 +134,7 @@ namespace swrenderer if (heightsec) // only clip things which are in special sectors { - if (fakeside == FAKED_AboveCeiling) + if (fakeside == WaterFakeSide::AboveCeiling) { topplane = §or->ceilingplane; botplane = &heightsec->ceilingplane; @@ -142,7 +142,7 @@ namespace swrenderer botpic = heightsec->GetTexture(sector_t::ceiling); map = heightsec->ColorMap; } - else if (fakeside == FAKED_BelowFloor) + else if (fakeside == WaterFakeSide::BelowFloor) { topplane = &heightsec->floorplane; botplane = §or->floorplane; diff --git a/src/swrenderer/things/r_particle.h b/src/swrenderer/things/r_particle.h index a0413d388..257a96aa3 100644 --- a/src/swrenderer/things/r_particle.h +++ b/src/swrenderer/things/r_particle.h @@ -14,10 +14,11 @@ #pragma once #include "r_visiblesprite.h" +#include "swrenderer/scene/r_bsp.h" namespace swrenderer { - void R_ProjectParticle(particle_t *, const sector_t *sector, int shade, int fakeside); + void R_ProjectParticle(particle_t *, const sector_t *sector, int shade, WaterFakeSide fakeside); void R_DrawParticle(vissprite_t *); void R_DrawMaskedSegsBehindParticle(const vissprite_t *vis); } diff --git a/src/swrenderer/things/r_visiblesprite.h b/src/swrenderer/things/r_visiblesprite.h index 04ef665e6..96eda392c 100644 --- a/src/swrenderer/things/r_visiblesprite.h +++ b/src/swrenderer/things/r_visiblesprite.h @@ -14,6 +14,7 @@ #pragma once #include "swrenderer/line/r_line.h" +#include "swrenderer/scene/r_bsp.h" struct particle_t; struct FVoxel; @@ -76,7 +77,7 @@ namespace swrenderer uint8_t bWallSprite : 1; // [RH] This is a wall sprite uint8_t bSplitSprite : 1; // [RH] Sprite was split by a drawseg uint8_t bInMirror : 1; // [RH] Sprite is "inside" a mirror - uint8_t FakeFlatStat; // [RH] which side of fake/floor ceiling sprite is on + WaterFakeSide FakeFlatStat; // [RH] which side of fake/floor ceiling sprite is on short renderflags; uint32_t Translation; // [RH] for color translation visstyle_t Style; diff --git a/src/swrenderer/things/r_wallsprite.cpp b/src/swrenderer/things/r_wallsprite.cpp index b4c60cb95..34c398c64 100644 --- a/src/swrenderer/things/r_wallsprite.cpp +++ b/src/swrenderer/things/r_wallsprite.cpp @@ -118,7 +118,7 @@ namespace swrenderer vis->Style.RenderStyle = thing->RenderStyle; vis->FillColor = thing->fillcolor; vis->Translation = thing->Translation; - vis->FakeFlatStat = 0; + vis->FakeFlatStat = WaterFakeSide::Center; vis->Style.Alpha = float(thing->Alpha); vis->fakefloor = NULL; vis->fakeceiling = NULL;