Skip to content

Commit

Permalink
Refactor|Map Renderer: Various minor cleanup refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed May 11, 2013
1 parent c7c14bb commit ec3e058
Show file tree
Hide file tree
Showing 15 changed files with 763 additions and 766 deletions.
10 changes: 5 additions & 5 deletions doomsday/client/include/map/line.h
Expand Up @@ -758,11 +758,11 @@ class Line : public de::MapElement
/**
* Change the polyobj attributed to the line.
*
* @param newOwner New polyobj to attribute as the line to. Can be @c 0,
* to clear the attribution. (Note that the polyobj may
* also represent this relationship, so the relevant
* method(s) of Polyobj will also need to be called to
* complete the job of clearing this relationship.)
* @param newPolyobj New polyobj to attribute the line to. Can be @c 0,
* to clear the attribution. (Note that the polyobj may
* also represent this relationship, so the relevant
* method(s) of Polyobj will also need to be called to
* complete the job of clearing this relationship.)
*/
void setPolyobj(Polyobj *newOwner);

Expand Down
16 changes: 11 additions & 5 deletions doomsday/client/include/render/rend_main.h
Expand Up @@ -88,7 +88,10 @@ void Rend_Shutdown();
void Rend_Reset();
void Rend_RenderMap();

void Rend_ModelViewMatrix(boolean use_angles);
/**
* @param useAngles @c true= Apply viewer angle rotation.
*/
void Rend_ModelViewMatrix(bool useAngles = true);

#define Rend_PointDist2D(c) (fabs((vOrigin[VZ]-c[VY])*viewsidex - (vOrigin[VX]-c[VX])*viewsidey))

Expand All @@ -101,9 +104,9 @@ void Rend_ApplyTorchLight(float *color, float distance);

/**
* Apply range compression delta to @a lightValue.
* @param lightValue Address of the value for adaptation.
* @param lightValue The light level value to apply adaptation to.
*/
void Rend_ApplyLightAdaptation(float *lightValue);
void Rend_ApplyLightAdaptation(float &lightValue);

/// Same as Rend_ApplyLightAdaptation except the delta is returned.
float Rend_LightAdaptationDelta(float lightvalue);
Expand Down Expand Up @@ -134,9 +137,12 @@ float Rend_ExtraLightDelta();
* The offsets in the lightRangeModTables are added to the sector->lightLevel
* during rendering (both positive and negative).
*/
void Rend_CalcLightModRange();
void Rend_UpdateLightModMatrix();

void R_DrawLightRange();
/**
* Draws the lightModRange (for debug)
*/
void Rend_DrawLightModMatrix();

/**
* Sector light color may be affected by the sky light color.
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/map/p_data.cpp
Expand Up @@ -199,7 +199,7 @@ DENG_EXTERN_C boolean P_LoadMap(char const *uriCString)
Cl_InitPlayers();

RL_DeleteLists();
Rend_CalcLightModRange();
Rend_UpdateLightModMatrix();
#endif

// Invalidate old cmds and init player values.
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/map/r_world.cpp
Expand Up @@ -533,7 +533,7 @@ DENG_EXTERN_C void R_SetupMap(int mode, int flags)

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

theMap->initPolyobjs();
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/network/net_main.cpp
Expand Up @@ -757,7 +757,7 @@ void Net_Drawer(void)
Rend_BlockmapDebug();

// Draw the light range debug display.
R_DrawLightRange();
Rend_DrawLightModMatrix();

// Draw the input device debug display.
Rend_AllInputDeviceStateVisuals();
Expand Down
7 changes: 5 additions & 2 deletions doomsday/client/src/render/r_main.cpp
Expand Up @@ -577,7 +577,7 @@ static void R_UpdateMap()

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

Expand Down Expand Up @@ -1127,7 +1127,10 @@ DENG_EXTERN_C void R_RenderPlayerView(int num)
// GL is in 3D transformation state only during the frame.
GL_SwitchTo3DState(true, currentViewport, vd);

Rend_RenderMap();
if(theMap)
{
Rend_RenderMap();
}

// Orthogonal projection to the view window.
GL_Restore2DState(1, currentViewport, vd);
Expand Down
3 changes: 3 additions & 0 deletions doomsday/client/src/render/r_shadow.cpp
Expand Up @@ -301,6 +301,9 @@ void R_InitShadowProjectionListsForMap()

void R_InitShadowProjectionListsForNewFrame()
{
// Disabled?
if(!Rend_MobjShadowsEnabled()) return;

// Start reusing nodes from the first one in the list.
cursorNode = firstNode;

Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/render/r_things.cpp
Expand Up @@ -545,7 +545,7 @@ float R_ShadowStrength(mobj_t *mo)
else
{
ambientLightLevel = mo->bspLeaf->sector().lightLevel();
Rend_ApplyLightAdaptation(&ambientLightLevel);
Rend_ApplyLightAdaptation(ambientLightLevel);
}

// Sprites have their own shadow strength factor.
Expand Down Expand Up @@ -939,7 +939,7 @@ void getLightingParams(coord_t x, coord_t y, coord_t z, BspLeaf *bspLeaf,
// Add extra light.
lightLevel += Rend_ExtraLightDelta();

Rend_ApplyLightAdaptation(&lightLevel);
Rend_ApplyLightAdaptation(lightLevel);

// Determine the final ambientColor in affect.
for(int i = 0; i < 3; ++i)
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/render/rend_decor.cpp
Expand Up @@ -106,7 +106,7 @@ static void projectSource(decorsource_t const &src)
float max = decor->lightLevels[1];

float lightLevel = src.bspLeaf->sector().lightLevel();
Rend_ApplyLightAdaptation(&lightLevel);
Rend_ApplyLightAdaptation(lightLevel);

float brightness = checkSectorLightLevel(lightLevel, min, max);
if(!(brightness > 0)) return;
Expand Down Expand Up @@ -200,7 +200,7 @@ static void addLuminousDecoration(decorsource_t &src)
float max = decor->lightLevels[1];

float lightLevel = src.bspLeaf->sector().lightLevel();
Rend_ApplyLightAdaptation(&lightLevel);
Rend_ApplyLightAdaptation(lightLevel);

float brightness = checkSectorLightLevel(lightLevel, min, max);
if(!(brightness > 0)) return;
Expand Down

0 comments on commit ec3e058

Please sign in to comment.