Skip to content

Commit

Permalink
Refactor|World|Client: Objlink blockmap refactoring continues...
Browse files Browse the repository at this point in the history
In the absence of better alternative I've opted to rename these as
"ContactBlockmaps" for now.
  • Loading branch information
danij-deng committed Oct 6, 2013
1 parent 0a14f07 commit b898b81
Show file tree
Hide file tree
Showing 6 changed files with 206 additions and 209 deletions.
36 changes: 12 additions & 24 deletions doomsday/client/include/world/p_objlink.h
Expand Up @@ -33,55 +33,43 @@ class Lumobj;
* the Zone with a >= PU_MAP purge level and access to them is handled
* with global pointers.
*
* @todo Encapsulate allocation of and access to the objlink blockmaps
* within de::Map
* @todo Encapsulate allocation of and access to the blockmaps in de::Map
*/
void R_DestroyObjlinkBlockmap();
void R_DestroyContactBlockmaps();

/**
* Construct the objlink blockmap for the current map.
*/
void R_InitObjlinkBlockmapForMap(de::Map &map);
void R_InitContactBlockmaps(de::Map &map);

/**
* Initialize the object => BspLeaf contact lists, ready for linking to
* objects. To be called at the beginning of a new world frame.
*/
void R_InitForNewFrame(de::Map &map);

/**
* To be called at the begining of a render frame to clear the objlink
* blockmap prior to linking objects for the new viewer.
*/
void R_ClearObjlinksForFrame();
void R_ClearContacts(de::Map &map);

/**
* Create a new object link of the specified @a type in the objlink blockmap.
*/
void R_ObjlinkCreate(struct mobj_s &mobj);
void R_AddContact(struct mobj_s &mobj);

/// @copydoc R_ObjlinkCreate()
void R_ObjlinkCreate(Lumobj &lumobj);
void R_AddContact(Lumobj &lumobj);

/**
* To be called at the beginning of a render frame to link all objects
* into the objlink blockmap.
* To be called at the beginning of a render frame to link all objects into the
* objlink blockmap.
*
* @todo Why don't we link contacts immediately? -ds
*/
void R_LinkObjs();
void R_LinkContacts();

/**
* Spread object => BspLeaf links for the given @a BspLeaf. Note that all object
* types will be spread at this time. It is assumed that the BSP leaf is @em not
* degenerate.
*/
void R_InitForBspLeaf(BspLeaf &bspLeaf);

/**
* Create a new object => BspLeaf contact.
*/
void R_LinkObjToBspLeaf(BspLeaf &bspLeaf, struct mobj_s &mobj);
/// @copydoc R_LinkObjToBspLeaf()
void R_LinkObjToBspLeaf(BspLeaf &bspLeaf, Lumobj &lumobj);
void R_SpreadContacts(BspLeaf &bspLeaf);

/**
* Traverse the list of mobj contacts which have been linked with @a bspLeaf for
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/dd_main.cpp
Expand Up @@ -1500,7 +1500,7 @@ bool App_ChangeGame(Game &game, bool allowReload)

#ifdef __CLIENT__
R_ClearViewData();
R_DestroyObjlinkBlockmap();
R_DestroyContactBlockmaps();
P_ControlShutdown();

Con_Execute(CMDS_DDAY, "clearbindings", true, false);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/render/rend_main.cpp
Expand Up @@ -2499,7 +2499,7 @@ static void drawCurrentLeaf()
leaf->markVisible();

markLeafFrontFacingWalls();
R_InitForBspLeaf(*leaf);
R_SpreadContacts(*leaf);
Rend_RadioBspLeafEdges(*leaf);

/*
Expand Down
16 changes: 7 additions & 9 deletions doomsday/client/src/world/map.cpp
Expand Up @@ -1144,12 +1144,12 @@ DENG2_OBSERVES(bsp::Partitioner, UnclosedSectorFound)
/**
* Create new objlinks for mobj => BSP leaf contact spreading.
*/
void createMobjLinks()
void createMobjContacts()
{
foreach(Sector *sector, sectors)
for(mobj_t *iter = sector->firstMobj(); iter; iter = iter->sNext)
{
R_ObjlinkCreate(*iter);
R_AddContact(*iter);
}
}

Expand Down Expand Up @@ -2694,7 +2694,7 @@ Lumobj &Map::addLumobj(Lumobj const &lumobj)
lum.setIndexInMap(d->lumobjs.count() - 1);

lum.bspLeafAtOrigin().link(lum);
R_ObjlinkCreate(lum); // For spreading purposes.
R_AddContact(lum); // For spreading purposes.

return lum;
}
Expand Down Expand Up @@ -2902,10 +2902,8 @@ void Map::worldFrameBegins(World &world, bool resetNextViewer)

removeAllLumobjs();

R_ClearObjlinksForFrame(); // Zeroes the links.

// Clear the objlinks.
R_InitForNewFrame(*this);
// Clear the "contact" blockmaps (BSP leaf => object).
R_ClearContacts(*this);

// Generate surface decorations for the frame.
if(useLightDecorations)
Expand Down Expand Up @@ -2942,13 +2940,13 @@ void Map::worldFrameBegins(World &world, bool resetNextViewer)
}

// Create objlinks for mobjs.
d->createMobjLinks();
d->createMobjContacts();

// Link all active particle generators into the world.
P_CreatePtcGenLinks();

// Link objs to all contacted surfaces.
R_LinkObjs();
R_LinkContacts();
}
}

Expand Down

0 comments on commit b898b81

Please sign in to comment.