Skip to content

Commit

Permalink
Refactor|Client|Server: Split client-specific code from r_main.cpp
Browse files Browse the repository at this point in the history
Most of r_main.cpp is client-specific, so all of that was moved to
render/viewports.cpp.
  • Loading branch information
skyjake committed Nov 12, 2013
1 parent 3e5017b commit ab9625f
Show file tree
Hide file tree
Showing 21 changed files with 1,828 additions and 1,758 deletions.
2 changes: 2 additions & 0 deletions doomsday/client/client.pro
Expand Up @@ -320,6 +320,7 @@ DENG_HEADERS += \
include/render/sprite.h \
include/render/surfacedecorator.h \
include/render/trianglestripbuilder.h \
include/render/viewports.h \
include/render/vignette.h \
include/render/vissprite.h \
include/render/vlight.h \
Expand Down Expand Up @@ -679,6 +680,7 @@ SOURCES += \
src/render/sprite.cpp \
src/render/surfacedecorator.cpp \
src/render/trianglestripbuilder.cpp \
src/render/viewports.cpp \
src/render/vignette.cpp \
src/render/vissprite.cpp \
src/render/vlight.cpp \
Expand Down
1 change: 1 addition & 0 deletions doomsday/client/include/de_render.h
Expand Up @@ -25,6 +25,7 @@
#include "render/r_main.h"

#ifdef __CLIENT__
#include "render/viewports.h"
#include "render/lightgrid.h"
#include "render/projector.h"
#include "render/r_draw.h"
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/include/gl/gl_main.h
Expand Up @@ -34,7 +34,7 @@
#include "sys_opengl.h"

#include "gl/gltextureunit.h"
#include "render/r_main.h"
#include "render/viewports.h"
#include "Texture"

struct colorpalette_s;
Expand Down
8 changes: 8 additions & 0 deletions doomsday/client/include/r_util.h
Expand Up @@ -31,6 +31,8 @@ float R_MovementXYYaw(float momx, float momy);
float R_MovementPitch(float const mom[3]);
float R_MovementXYZPitch(float momx, float momy, float momz);

#ifdef __CLIENT__

/**
* Get a global angle from Cartesian coordinates in the map coordinate space
* relative to the viewer.
Expand All @@ -56,15 +58,21 @@ inline angle_t R_ViewPointToAngle(coord_t x, coord_t y) {
*/
coord_t R_ViewPointDistance(coord_t x, coord_t y);

#endif

de::Vector3d R_ClosestPointOnPlane(de::Vector3f const &planeNormal,
de::Vector3d const &planePoint, de::Vector3d const &origin);

#ifdef __CLIENT__

void R_ProjectViewRelativeLine2D(coord_t const center[2], boolean alignToViewPlane,
coord_t width, coord_t offset, coord_t start[2], coord_t end[2]);

void R_ProjectViewRelativeLine2D(de::Vector2d const center, bool alignToViewPlane,
coord_t width, coord_t offset, de::Vector2d &start, de::Vector2d &end);

#endif

/**
* Scale @a color uniformly so that the highest component becomes one.
*/
Expand Down
183 changes: 0 additions & 183 deletions doomsday/client/include/render/r_main.h
Expand Up @@ -21,56 +21,10 @@
#ifndef LIBDENG_RENDER_R_MAIN_H
#define LIBDENG_RENDER_R_MAIN_H

#include <de/rect.h>
#include "dd_share.h"

#ifdef __CLIENT__
class BspLeaf;
class Lumobj;
#endif

typedef struct viewport_s {
int console;
RectRaw geometry;
} viewport_t;

typedef struct viewer_s {
coord_t origin[3];
angle_t angle;
float pitch;
} viewer_t;

typedef struct viewdata_s {
viewer_t current;
viewer_t lastSharp[2]; ///< For smoothing.
viewer_t latest; ///< "Sharp" values taken from here.

/**
* These vectors are in the DGL coordinate system, which is a left-handed
* one (same as in the game, but Y and Z have been swapped). Anyone who uses
* these must note that it might be necessary to fix the aspect ratio of the
* Y axis by dividing the Y coordinate by 1.2.
*/
float frontVec[3], upVec[3], sideVec[3];

float viewCos, viewSin;

RectRaw window, windowTarget, windowOld;
float windowInter;
} viewdata_t;

typedef enum fontstyle_e {
FS_NORMAL,
FS_BOLD,
FS_LIGHT,
FONTSTYLE_COUNT
} fontstyle_t;

DENG_EXTERN_C float frameTimePos; // 0...1: fractional part for sharp game tics
DENG_EXTERN_C int loadInStartupMode;
DENG_EXTERN_C int validCount;
DENG_EXTERN_C int frameCount;
DENG_EXTERN_C int rendInfoTris;

DENG_EXTERN_C int levelFullBright;

Expand All @@ -80,27 +34,11 @@ DENG_EXTERN_C float weaponOffsetScale, weaponFOVShift;
DENG_EXTERN_C int weaponOffsetScaleY;
DENG_EXTERN_C byte weaponScaleMode; // cvar

DENG_EXTERN_C boolean firstFrameAfterLoad;

DENG_EXTERN_C byte precacheMapMaterials, precacheSprites, precacheSkins;

DENG_EXTERN_C fontid_t fontFixed, fontVariable[FONTSTYLE_COUNT];

DENG_EXTERN_C fixed_t fineTangent[FINEANGLES / 2];

DENG_EXTERN_C byte texGammaLut[256];
#ifdef __CLIENT__
DENG_EXTERN_C boolean loInited;
#endif

#ifdef __cplusplus
extern "C" {
#endif

/**
* Register console variables.
*/
void R_Register(void);

void R_BuildTexGammaLut(void);

Expand All @@ -119,125 +57,4 @@ void R_Update(void);
*/
void R_Shutdown(void);

void R_Ticker(timespan_t time);

namespace ui {
enum ViewPortLayer {
Player3DViewLayer,
HUDLayer
};
}

/**
* Render all view ports in the viewport grid.
*/
void R_RenderViewPorts(ui::ViewPortLayer layer);

/**
* Render a blank view for the specified player.
*/
void R_RenderBlankView(void);

/**
* Draw the border around the view window.
*/
void R_RenderPlayerViewBorder(void);

/// @return Current viewport; otherwise @c NULL.
viewport_t const *R_CurrentViewPort(void);

/**
* Set the current GL viewport.
*/
void R_UseViewPort(viewport_t const *vp);

viewdata_t const *R_ViewData(int consoleNum);

void R_UpdateViewer(int consoleNum);

void R_ResetViewer(void);

int R_NextViewer(void);

#ifdef __CLIENT__

void R_ClearViewData(void);

/**
* To be called at the beginning of a render frame to perform necessary initialization.
*/
void R_BeginFrame(void);

/**
* Returns @c true iff the BSP leaf is marked as visible for the current frame.
*
* @see R_ViewerBspLeafMarkVisible()
*/
bool R_ViewerBspLeafIsVisible(BspLeaf const &bspLeaf);

/**
* Mark the BSP leaf as visible for the current frame.
*
* @see R_ViewerBspLeafIsVisible()
*/
void R_ViewerBspLeafMarkVisible(BspLeaf const &bspLeaf, bool yes = true);

/// @return Distance in map space units between the lumobj and viewer.
double R_ViewerLumobjDistance(int idx);

/// @return @c true if the lumobj is clipped for the viewer.
bool R_ViewerLumobjIsClipped(int idx);

/// @return @c true if the lumobj is hidden for the viewer.
bool R_ViewerLumobjIsHidden(int idx);

/**
* Clipping strategy:
*
* If culling world surfaces with the angle clipper and the viewer is not in the
* void; use the angle clipper. Otherwise, use the BSP-based LOS algorithm.
*/
void R_ViewerClipLumobj(Lumobj *lum);

void R_ViewerClipLumobjBySight(Lumobj *lum, BspLeaf *bspLeaf);

#endif // __CLIENT__

/**
* Update the sharp world data by rotating the stored values of plane
* heights and sharp camera positions.
*/
void R_NewSharpWorld(void);

/**
* Attempt to set up a view grid and calculate the viewports. Set 'numCols' and
* 'numRows' to zero to just update the viewport coordinates.
*/
boolean R_SetViewGrid(int numCols, int numRows);

void R_SetupDefaultViewWindow(int consoleNum);

/**
* Animates the view window towards the target values.
*/
void R_ViewWindowTicker(int consoleNum, timespan_t ticLength);

void R_SetViewPortPlayer(int consoleNum, int viewPlayer);

void R_LoadSystemFonts(void);

#ifdef __CLIENT__
char const *R_ChooseFixedFont(void);
char const *R_ChooseVariableFont(fontstyle_t style, int resX, int resY);
#endif

/**
* Prepare resources for the current Map.
*/
void Rend_CacheForMap(void);

#ifdef __cplusplus
} // extern "C"
#endif

#endif /* LIBDENG_REFRESH_MAIN_H */

0 comments on commit ab9625f

Please sign in to comment.