Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refactor: Removed global surface list pointers
Added accessor methods to GameMap for retrieving the lists.
  • Loading branch information
danij-deng committed Mar 9, 2012
1 parent a396126 commit bef21da
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 77 deletions.
24 changes: 24 additions & 0 deletions doomsday/engine/portable/include/gamemap.h
Expand Up @@ -529,6 +529,30 @@ struct clplane_s* GameMap_NewClPlane(GameMap* map, uint sectornum, clplanetype_t
*/
struct generators_s* GameMap_Generators(GameMap* map);

/**
* Retrieve a pointer to the decorated surface list for this map.
*
* @param map GameMap instance.
* @return List of decorated surfaces.
*/
surfacelist_t* GameMap_DecoratedSurfaces(GameMap* map);

/**
* Retrieve a pointer to the glowing surface list for this map.
*
* @param map GameMap instance.
* @return List of glowing surfaces.
*/
surfacelist_t* GameMap_GlowingSurfaces(GameMap* map);

/**
* Retrieve a pointer to the scrolling surface list for this map.
*
* @param map GameMap instance.
* @return List of scrolling surfaces.
*/
surfacelist_t* GameMap_ScrollingSurfaces(GameMap* map);

/**
* Initialize all Polyobjs in the map. To be called after map load.
*
Expand Down
3 changes: 0 additions & 3 deletions doomsday/engine/portable/include/p_mapdata.h
Expand Up @@ -183,9 +183,6 @@ extern sidedef_t* sideDefs;
extern polyobj_t** polyObjs; ///< List of all polyobjs on the current map.

extern watchedplanelist_t* watchedPlaneList;
extern surfacelist_t* movingSurfaceList;
extern surfacelist_t* decoratedSurfaceList;
extern surfacelist_t* glowingSurfaceList;

#include "gamemap.h"

Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/include/r_world.h
Expand Up @@ -127,8 +127,8 @@ void R_AddWatchedPlane(watchedplanelist_t* wpl, plane_t* pln);
boolean R_RemoveWatchedPlane(watchedplanelist_t* wpl,
const plane_t* pln);

void R_UpdateMovingSurfaces(void);
void R_InterpolateMovingSurfaces(boolean resetNextViewer);
void R_UpdateSurfaceScroll(void);
void R_InterpolateSurfaceScroll(boolean resetNextViewer);

/**
* Adds the surface to the given surface list.
Expand Down
18 changes: 18 additions & 0 deletions doomsday/engine/portable/src/gamemap.c
Expand Up @@ -377,6 +377,24 @@ Generators* GameMap_Generators(GameMap* map)
return map->generators;
}

surfacelist_t* GameMap_DecoratedSurfaces(GameMap* map)
{
assert(map);
return &map->decoratedSurfaceList;
}

surfacelist_t* GameMap_GlowingSurfaces(GameMap* map)
{
assert(map);
return &map->glowingSurfaceList;
}

surfacelist_t* GameMap_ScrollingSurfaces(GameMap* map)
{
assert(map);
return &map->movingSurfaceList;
}

void GameMap_InitPolyobjs(GameMap* map)
{
uint i;
Expand Down
9 changes: 0 additions & 9 deletions doomsday/engine/portable/src/p_data.c
Expand Up @@ -60,9 +60,6 @@ sidedef_t* sideDefs = NULL;
polyobj_t** polyObjs = NULL; // List of all poly-objects in the map.

watchedplanelist_t* watchedPlaneList = NULL;
surfacelist_t* movingSurfaceList = NULL;
surfacelist_t* decoratedSurfaceList = NULL;
surfacelist_t* glowingSurfaceList = NULL;

GameMap* theMap = NULL;

Expand Down Expand Up @@ -133,9 +130,6 @@ void P_SetCurrentMap(GameMap* map)
polyObjs = 0;

watchedPlaneList = 0;
movingSurfaceList = 0;
decoratedSurfaceList = 0;
glowingSurfaceList = 0;

theMap = map;
return;
Expand All @@ -153,9 +147,6 @@ void P_SetCurrentMap(GameMap* map)
polyObjs = map->polyObjs;

watchedPlaneList = &map->watchedPlaneList;
movingSurfaceList = &map->movingSurfaceList;
decoratedSurfaceList = &map->decoratedSurfaceList;
glowingSurfaceList = &map->glowingSurfaceList;

theMap = map;
}
Expand Down
35 changes: 23 additions & 12 deletions doomsday/engine/portable/src/p_surface.c
Expand Up @@ -60,17 +60,19 @@ boolean Surface_SetMaterial(surface_t* suf, material_t* mat)

if(!ddMapSetup)
{
GameMap* map = theMap; /// @fixme Do not assume surface is from the CURRENT map.

// If this plane's surface is in the decorated list, remove it.
R_SurfaceListRemove(decoratedSurfaceList, suf);
R_SurfaceListRemove(GameMap_DecoratedSurfaces(map), suf);
// If this plane's surface is in the glowing list, remove it.
R_SurfaceListRemove(glowingSurfaceList, suf);
R_SurfaceListRemove(GameMap_GlowingSurfaces(map), suf);

if(mat)
{
if(Material_HasGlow(mat))
R_SurfaceListAdd(glowingSurfaceList, suf);
R_SurfaceListAdd(GameMap_GlowingSurfaces(map), suf);
if(Materials_HasDecorations(mat))
R_SurfaceListAdd(decoratedSurfaceList, suf);
R_SurfaceListAdd(GameMap_DecoratedSurfaces(map), suf);

if(DMU_GetType(suf->owner) == DMU_PLANE)
{
Expand Down Expand Up @@ -99,7 +101,10 @@ boolean Surface_SetMaterialOriginX(surface_t* suf, float x)
{
suf->inFlags |= SUIF_UPDATE_DECORATIONS;
if(!ddMapSetup)
R_SurfaceListAdd(movingSurfaceList, suf);
{
/// @fixme Do not assume surface is from the CURRENT map.
R_SurfaceListAdd(GameMap_ScrollingSurfaces(theMap), suf);
}
}
}
return true;
Expand All @@ -115,7 +120,10 @@ boolean Surface_SetMaterialOriginY(surface_t* suf, float y)
{
suf->inFlags |= SUIF_UPDATE_DECORATIONS;
if(!ddMapSetup)
R_SurfaceListAdd(movingSurfaceList, suf);
{
/// @fixme Do not assume surface is from the CURRENT map.
R_SurfaceListAdd(GameMap_ScrollingSurfaces(theMap), suf);
}
}
}
return true;
Expand All @@ -132,7 +140,10 @@ boolean Surface_SetMaterialOrigin(surface_t* suf, float x, float y)
{
suf->inFlags |= SUIF_UPDATE_DECORATIONS;
if(!ddMapSetup)
R_SurfaceListAdd(movingSurfaceList, suf);
{
/// @fixme Do not assume surface is from the CURRENT map.
R_SurfaceListAdd(GameMap_ScrollingSurfaces(theMap), suf);
}
}
}
return true;
Expand All @@ -144,7 +155,7 @@ boolean Surface_SetColorRed(surface_t* suf, float r)
r = MINMAX_OF(0, r, 1);
if(suf->rgba[CR] != r)
{
// \todo when surface colours are intergrated with the
// @todo when surface colours are intergrated with the
// bias lighting model we will need to recalculate the
// vertex colours when they are changed.
suf->rgba[CR] = r;
Expand All @@ -158,7 +169,7 @@ boolean Surface_SetColorGreen(surface_t* suf, float g)
g = MINMAX_OF(0, g, 1);
if(suf->rgba[CG] != g)
{
// \todo when surface colours are intergrated with the
// @todo when surface colours are intergrated with the
// bias lighting model we will need to recalculate the
// vertex colours when they are changed.
suf->rgba[CG] = g;
Expand All @@ -172,7 +183,7 @@ boolean Surface_SetColorBlue(surface_t* suf, float b)
b = MINMAX_OF(0, b, 1);
if(suf->rgba[CB] != b)
{
// \todo when surface colours are intergrated with the
// @todo when surface colours are intergrated with the
// bias lighting model we will need to recalculate the
// vertex colours when they are changed.
suf->rgba[CB] = b;
Expand All @@ -186,7 +197,7 @@ boolean Surface_SetAlpha(surface_t* suf, float a)
a = MINMAX_OF(0, a, 1);
if(suf->rgba[CA] != a)
{
// \todo when surface colours are intergrated with the
// @todo when surface colours are intergrated with the
// bias lighting model we will need to recalculate the
// vertex colours when they are changed.
suf->rgba[CA] = a;
Expand All @@ -207,7 +218,7 @@ boolean Surface_SetColorAndAlpha(surface_t* suf, float r, float g, float b, floa
suf->rgba[CA] == a)
return true;

// \todo when surface colours are intergrated with the
// @todo when surface colours are intergrated with the
// bias lighting model we will need to recalculate the
// vertex colours when they are changed.
suf->rgba[CR] = r;
Expand Down
9 changes: 6 additions & 3 deletions doomsday/engine/portable/src/r_lumobjs.c
Expand Up @@ -1021,8 +1021,7 @@ static boolean createGlowLightForSurface(surface_t* suf, void* paramaters)

void LO_AddLuminousMobjs(void)
{
if(!useDynlights && !useWallGlow)
return;
if(!useDynlights && !useWallGlow) return;

BEGIN_PROF( PROF_LUMOBJ_INIT_ADD );

Expand All @@ -1045,7 +1044,11 @@ BEGIN_PROF( PROF_LUMOBJ_INIT_ADD );
// to create dynlights and link them.
if(useWallGlow)
{
R_SurfaceListIterate(glowingSurfaceList, createGlowLightForSurface, 0);
surfacelist_t* slist = GameMap_GlowingSurfaces(theMap);
if(slist)
{
R_SurfaceListIterate(slist, createGlowLightForSurface, 0);
}
}

END_PROF( PROF_LUMOBJ_INIT_ADD );
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/r_main.c
Expand Up @@ -781,7 +781,7 @@ void R_NewSharpWorld(void)
}

R_UpdateWatchedPlanes(watchedPlaneList);
R_UpdateMovingSurfaces();
R_UpdateSurfaceScroll();
}

void R_CreateMobjLinks(void)
Expand Down Expand Up @@ -821,7 +821,7 @@ void R_BeginWorldFrame(void)
R_ClearSectorFlags();

R_InterpolateWatchedPlanes(watchedPlaneList, resetNextViewer);
R_InterpolateMovingSurfaces(resetNextViewer);
R_InterpolateSurfaceScroll(resetNextViewer);

if(!freezeRLs)
{
Expand Down

0 comments on commit bef21da

Please sign in to comment.