Skip to content

Commit

Permalink
Server|Refactor: Server executable no longer depends on rend_main.cpp/h
Browse files Browse the repository at this point in the history
Addressed the remaining dependencies and removed said source files
from the server project.
  • Loading branch information
danij-deng committed May 8, 2013
1 parent 2b16ba0 commit 2a56d87
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 87 deletions.
2 changes: 1 addition & 1 deletion doomsday/client/include/de_render.h
Expand Up @@ -24,9 +24,9 @@

#include "render/r_main.h"
#include "render/r_things.h"
#include "render/rend_main.h"

#ifdef __CLIENT__
#include "render/rend_main.h"
#include "render/r_draw.h"
#include "render/r_lgrid.h"
#include "render/lumobj.h"
Expand Down
22 changes: 4 additions & 18 deletions doomsday/client/include/map/r_world.h
Expand Up @@ -48,8 +48,12 @@ extern boolean firstFrameAfterLoad;
*/
de::Vector3f const &R_GetSectorLightColor(Sector const &sector);

#ifdef __CLIENT__

float R_DistAttenuateLightLevel(float distToViewer, float lightLevel);

#endif // __CLIENT__

/**
* The DOOM lighting model applies a light level delta to everything when
* e.g. the player shoots.
Expand All @@ -69,13 +73,6 @@ void R_ClearSectorFlags();

void R_UpdateMissingMaterialsForLinesOfSector(Sector const &sec);

/**
* Returns pointers to the line's vertices in such a fashion that @c verts[0]
* is the leftmost vertex and @c verts[1] is the rightmost vertex, when the
* @a line lies at the edge of @a sector.
*/
void R_OrderVertices(Line *line, Sector const *sector, Vertex *verts[2]);

/**
* Determine the map space Z coordinates of a wall section.
*
Expand Down Expand Up @@ -230,15 +227,4 @@ Line *R_FindLineBackNeighbor(Sector const *sector, Line const *line,
LineOwner const *own, bool antiClockwise, binangle_t *diff = 0);
#endif // __CLIENT__

/**
* @defgroup skyCapFlags Sky Cap Flags
* @ingroup flags
*/
///@{
#define SKYCAP_LOWER 0x1
#define SKYCAP_UPPER 0x2
///@}

coord_t R_SkyCapZ(BspLeaf *bspLeaf, int skyCap);

#endif /* LIBDENG_MAP_WORLD_H */
60 changes: 26 additions & 34 deletions doomsday/client/include/render/rend_main.h
@@ -1,4 +1,4 @@
/** @file rend_main.h
/** @file render/rend_main.h Core of the rendering subsystem.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
Expand All @@ -17,18 +17,22 @@
* http://www.gnu.org/licenses</small>
*/

/**
* Core of the rendering subsystem.
*/
#ifndef DENG_RENDER_MAIN_H
#define DENG_RENDER_MAIN_H

#ifndef LIBDENG_REND_MAIN_H
#define LIBDENG_REND_MAIN_H
#ifndef __CLIENT__
# error "render/rend_main.h only exists in the Client"
#endif

#include <math.h>
#ifdef __CLIENT__
# include "rend_list.h"
#ifndef __cplusplus
# error "render/rend_main.h requires C++"
#endif
#include "r_things.h"

//#include <math.h>

#include "dd_types.h"

#include "MaterialVariantSpec"

#define GLOW_HEIGHT_MAX (1024.f) /// Absolute maximum

Expand All @@ -38,14 +42,17 @@

DENG_EXTERN_C coord_t vOrigin[3];
DENG_EXTERN_C float vang, vpitch, fieldOfView, yfov;
DENG_EXTERN_C byte smoothTexAnim, devMobjVLights;
DENG_EXTERN_C float viewsidex, viewsidey;
DENG_EXTERN_C boolean usingFog;
DENG_EXTERN_C float fogColor[4];

DENG_EXTERN_C byte smoothTexAnim, devMobjVLights;
DENG_EXTERN_C boolean usingFog;

DENG_EXTERN_C int rAmbient;
DENG_EXTERN_C float rendLightDistanceAttenuation;
DENG_EXTERN_C int rendLightAttenuateFixedColormap;
DENG_EXTERN_C float lightModRange[255];

DENG_EXTERN_C int devRendSkyMode;
DENG_EXTERN_C int gameDrawHUD;

Expand All @@ -68,21 +75,13 @@ DENG_EXTERN_C float detailFactor, detailScale;
DENG_EXTERN_C byte devRendSkyAlways;
DENG_EXTERN_C byte freezeRLs;

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __CLIENT__

void Rend_Register(void);
void Rend_Register();

#endif

void Rend_Init(void);
void Rend_Shutdown(void);
void Rend_Reset(void);
void Rend_Init();
void Rend_Shutdown();
void Rend_Reset();
void Rend_RenderMap();

void Rend_RenderMap(void);
void Rend_ModelViewMatrix(boolean use_angles);

#define Rend_PointDist2D(c) (fabs((vOrigin[VZ]-c[VY])*viewsidex - (vOrigin[VX]-c[VX])*viewsidey))
Expand Down Expand Up @@ -113,19 +112,12 @@ float Rend_LightAdaptationDelta(float lightvalue);
*/
void Rend_CalcLightModRange();

void R_DrawLightRange(void);

#ifdef __cplusplus
} // extern "C"
void R_DrawLightRange();

#ifdef __CLIENT__
de::MaterialVariantSpec const &Rend_MapSurfaceMaterialSpec();

texturevariantspecification_t &Rend_MapSurfaceShinyTextureSpec();

texturevariantspecification_t &Rend_MapSurfaceShinyMaskTextureSpec();
#endif

#endif // __cplusplus

#endif // LIBDENG_REND_MAIN_H
#endif // DENG_RENDER_MAIN_H
28 changes: 11 additions & 17 deletions doomsday/client/src/map/r_world.cpp
Expand Up @@ -87,13 +87,6 @@ DENG_EXTERN_C void R_SetupFogDefaults()
Con_Execute(CMDS_DDAY,"fog off", true, false);
}

void R_OrderVertices(Line *line, Sector const *sector, Vertex *verts[2])
{
byte edge = (sector == line->frontSectorPtr()? 0:1);
verts[0] = &line->vertex(edge);
verts[1] = &line->vertex(edge^1);
}

void R_SideSectionCoords(Line::Side const &side, int section,
Sector const *frontSec, Sector const *backSec,
coord_t *retBottom, coord_t *retTop, Vector2f *retMaterialOrigin)
Expand Down Expand Up @@ -195,8 +188,13 @@ void R_SideSectionCoords(Line::Side const &side, int section,

if(surface->hasMaterial() && !stretchMiddle)
{
#ifdef __CLIENT__
bool const clipBottom = !(!(devRendSkyMode || P_IsInVoid(viewPlayer)) && ffloor->surface().hasSkyMaskedMaterial() && bfloor->surface().hasSkyMaskedMaterial());
bool const clipTop = !(!(devRendSkyMode || P_IsInVoid(viewPlayer)) && fceil->surface().hasSkyMaskedMaterial() && bceil->surface().hasSkyMaskedMaterial());
#else
bool const clipBottom = !(ffloor->surface().hasSkyMaskedMaterial() && bfloor->surface().hasSkyMaskedMaterial());
bool const clipTop = !(fceil->surface().hasSkyMaskedMaterial() && bceil->surface().hasSkyMaskedMaterial());
#endif

coord_t const openBottom = bottom;
coord_t const openTop = top;
Expand Down Expand Up @@ -791,8 +789,10 @@ DENG_EXTERN_C void R_SetupMap(int mode, int flags)
Sv_InitPools();
#endif

#ifdef __CLIENT__
// Recalculate the light range mod matrix.
Rend_CalcLightModRange();
#endif

theMap->initPolyobjs();
P_MapSpawnPlaneParticleGens();
Expand Down Expand Up @@ -961,6 +961,8 @@ void R_UpdateSector(Sector &sector, bool forceUpdate)
#endif
}

#ifdef __CLIENT__

/**
* The DOOM lighting model applies distance attenuation to sector light
* levels.
Expand All @@ -987,6 +989,8 @@ float R_DistAttenuateLightLevel(float distToViewer, float lightLevel)
return lightLevel;
}

#endif // __CLIENT__

float R_ExtraLightDelta()
{
return extraLightDelta;
Expand All @@ -996,7 +1000,6 @@ float R_CheckSectorLight(float lightlevel, float min, float max)
{
// Has a limit been set?
if(min == max) return 1;
Rend_ApplyLightAdaptation(&lightlevel);
return MINMAX_OF(0, (lightlevel - min) / (float) (max - min), 1);
}

Expand Down Expand Up @@ -1041,12 +1044,3 @@ Vector3f const &R_GetSectorLightColor(Sector const &sector)
}

#endif // __CLIENT__

coord_t R_SkyCapZ(BspLeaf *bspLeaf, int skyCap)
{
DENG_ASSERT(bspLeaf);
Plane::Type const plane = (skyCap & SKYCAP_UPPER)? Plane::Ceiling : Plane::Floor;
if(!bspLeaf->hasSector() || !P_IsInVoid(viewPlayer))
return theMap->skyFix(plane == Plane::Ceiling);
return bspLeaf->sector().plane(plane).visHeight();
}
6 changes: 5 additions & 1 deletion doomsday/client/src/render/r_main.cpp
Expand Up @@ -500,8 +500,8 @@ void R_Init()
R_InitSvgs();
#ifdef __CLIENT__
R_InitViewWindow();
#endif
Rend_Init();
#endif
frameCount = 0;
}

Expand Down Expand Up @@ -575,8 +575,10 @@ static void R_UpdateMap()

theMap->_effectiveGravity = theMap->_globalGravity;

#ifdef __CLIENT__
// Recalculate the light range mod matrix.
Rend_CalcLightModRange();
#endif
}

void R_Update()
Expand Down Expand Up @@ -1033,7 +1035,9 @@ void R_SetupFrame(player_t *player)
// Why?
validCount++;

#ifdef __CLIENT__
if(!freezeRLs)
#endif
{
R_ClearVisSprites();
}
Expand Down
10 changes: 8 additions & 2 deletions doomsday/client/src/render/rend_decor.cpp
Expand Up @@ -95,7 +95,10 @@ static void projectSource(decorsource_t const &src)
float min = decor->lightLevels[0];
float max = decor->lightLevels[1];

float brightness = R_CheckSectorLight(src.bspLeaf->sector().lightLevel(), min, max);
float lightLevel = src.bspLeaf->sector().lightLevel();
Rend_ApplyLightAdaptation(&lightLevel);

float brightness = R_CheckSectorLight(lightLevel, min, max);
if(!(brightness > 0)) return;

if(src.fadeMul <= 0) return;
Expand Down Expand Up @@ -186,7 +189,10 @@ static void addLuminousDecoration(decorsource_t &src)
float min = decor->lightLevels[0];
float max = decor->lightLevels[1];

float brightness = R_CheckSectorLight(src.bspLeaf->sector().lightLevel(), min, max);
float lightLevel = src.bspLeaf->sector().lightLevel();
Rend_ApplyLightAdaptation(&lightLevel);

float brightness = R_CheckSectorLight(lightLevel, min, max);
if(!(brightness > 0)) return;

// Apply the brightness factor (was calculated using sector lightlevel).
Expand Down
3 changes: 3 additions & 0 deletions doomsday/client/src/render/rend_halo.cpp
Expand Up @@ -23,8 +23,11 @@
#include "de_console.h"
#include "de_graphics.h"
#include "de_misc.h"

#include "map/p_players.h"

#include "render/rend_main.h"
#include "render/rend_list.h"

#include "render/rend_halo.h"

Expand Down
31 changes: 20 additions & 11 deletions doomsday/client/src/render/rend_main.cpp
Expand Up @@ -36,10 +36,8 @@
#include "edit_bias.h" /// @todo remove me
#include "network/net_main.h" /// @todo remove me

#ifdef __CLIENT__
# include "MaterialSnapshot"
# include "MaterialVariantSpec"
#endif
#include "MaterialSnapshot"
#include "MaterialVariantSpec"
#include "Texture"
#include "SectionEdge"

Expand Down Expand Up @@ -148,7 +146,6 @@ byte devSoundOrigins = 0; ///< cvar @c 1= Draw sound origin debug display.
byte devSurfaceVectors = 0;
byte devNoTexFix = 0;

#ifdef __CLIENT__
static void Rend_RenderBoundingBoxes();
static DGLuint constructBBox(DGLuint name, float br);
static uint buildLeafPlaneGeometry(BspLeaf const &leaf, bool antiClockwise,
Expand Down Expand Up @@ -609,8 +606,6 @@ static void flatShinyTexCoords(rtexcoord_t *tc, float const xyz[3])
tc->st[1] = shinyVertical(vOrigin[VY] - xyz[VZ], distance);
}

#ifdef __CLIENT__

struct rendworldpoly_params_t
{
bool isWall;
Expand Down Expand Up @@ -1753,7 +1748,23 @@ static void writeLeafPlane(Plane &plane)
R_FreeRendVertices(rvertices);
}

#endif // __CLIENT__
/**
* @defgroup skyCapFlags Sky Cap Flags
* @ingroup flags
*/
///@{
#define SKYCAP_LOWER 0x1
#define SKYCAP_UPPER 0x2
///@}

static coord_t skyCapZ(BspLeaf *bspLeaf, int skyCap)
{
DENG_ASSERT(bspLeaf);
Plane::Type const plane = (skyCap & SKYCAP_UPPER)? Plane::Ceiling : Plane::Floor;
if(!bspLeaf->hasSector() || !P_IsInVoid(viewPlayer))
return theMap->skyFix(plane == Plane::Ceiling);
return bspLeaf->sector().plane(plane).visHeight();
}

static coord_t skyFixFloorZ(Plane const *frontFloor, Plane const *backFloor)
{
Expand Down Expand Up @@ -2169,7 +2180,7 @@ static void writeLeafSkyMaskCap(int skyCap)

rvertex_t *verts;
uint numVerts;
buildLeafPlaneGeometry(*bspLeaf, (skyCap & SKYCAP_UPPER) != 0, R_SkyCapZ(bspLeaf, skyCap),
buildLeafPlaneGeometry(*bspLeaf, (skyCap & SKYCAP_UPPER) != 0, skyCapZ(bspLeaf, skyCap),
&verts, &numVerts);

RL_AddPoly(PT_FAN, RPF_DEFAULT | RPF_SKYMASK, numVerts, verts, NULL);
Expand Down Expand Up @@ -3781,5 +3792,3 @@ texturevariantspecification_t &Rend_MapSurfaceShinyMaskTextureSpec()
0, 0, 0, GL_REPEAT, GL_REPEAT, -1, -1, -1,
true, false, false, false);
}

#endif // __CLIENT__
2 changes: 1 addition & 1 deletion doomsday/server/include/server_dummies.h
Expand Up @@ -61,7 +61,7 @@ DENG_EXTERN_C void Rend_Init(void);
//DENG_EXTERN_C void Rend_DecorInitForMap();
//DENG_EXTERN_C void Rend_CacheForMap();
DENG_EXTERN_C void Rend_CacheForMobjType(int num);
DENG_EXTERN_C void Rend_CalcLightModRange();
//DENG_EXTERN_C void Rend_CalcLightModRange();
DENG_EXTERN_C void Rend_ConsoleInit();
DENG_EXTERN_C void Rend_ConsoleResize(int force);
DENG_EXTERN_C void Rend_ConsoleOpen(int yes);
Expand Down

0 comments on commit 2a56d87

Please sign in to comment.