Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refactor|World|ContactBlockmap|Client: Renamed source files for Conta…
…ctBlockmap
  • Loading branch information
danij-deng committed Oct 6, 2013
1 parent b2c291f commit 581a39d
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 59 deletions.
5 changes: 3 additions & 2 deletions doomsday/client/client.pro
Expand Up @@ -119,6 +119,7 @@ DENG_CONVENIENCE_HEADERS += \
include/BspNode \
include/CommandAction \
include/ChildWidgetOrganizer \
include/ContactBlockmap \
include/Decoration \
include/DialogContentStylist \
include/EntityDatabase \
Expand Down Expand Up @@ -464,6 +465,7 @@ DENG_HEADERS += \
include/world/bsp/superblockmap.h \
include/world/bspleaf.h \
include/world/bspnode.h \
include/world/contactblockmap.h \
include/world/dmuargs.h \
include/world/entitydatabase.h \
include/world/entitydef.h \
Expand All @@ -480,7 +482,6 @@ DENG_HEADERS += \
include/world/maputil.h \
include/world/p_intercept.h \
include/world/p_object.h \
include/world/p_objlink.h \
include/world/p_particle.h \
include/world/p_players.h \
include/world/p_ticker.h \
Expand Down Expand Up @@ -803,6 +804,7 @@ SOURCES += \
src/world/bsp/superblockmap.cpp \
src/world/bspleaf.cpp \
src/world/bspnode.cpp \
src/world/contactblockmap.cpp \
src/world/dmuargs.cpp \
src/world/entitydatabase.cpp \
src/world/entitydef.cpp \
Expand All @@ -818,7 +820,6 @@ SOURCES += \
src/world/maputil.cpp \
src/world/p_intercept.cpp \
src/world/p_mobj.cpp \
src/world/p_objlink.cpp \
src/world/p_particle.cpp \
src/world/p_players.cpp \
src/world/p_ticker.cpp \
Expand Down
1 change: 1 addition & 0 deletions doomsday/client/include/ContactBlockmap
@@ -0,0 +1 @@
#include "world/contactblockmap.h"
2 changes: 1 addition & 1 deletion doomsday/client/include/de_play.h
Expand Up @@ -40,7 +40,7 @@
#include "world/p_ticker.h"
#include "world/p_players.h"
#ifdef __CLIENT__
# include "world/p_objlink.h"
# include "ContactBlockmap"
#endif
#include "Material"
#include "ui/p_control.h"
Expand Down
@@ -1,4 +1,4 @@
/** @file p_objlink.h World object => BSP leaf "contact" blockmap.
/** @file contactblockmap.h World object => BSP leaf "contact" blockmap.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/dd_main.cpp
Expand Up @@ -74,7 +74,7 @@
#include "world/entitydef.h"
#include "world/p_players.h"
#ifdef __CLIENT__
# include "world/p_objlink.h"
# include "ContactBlockmap"
#endif
#include "world/world.h"

Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/render/projector.cpp
Expand Up @@ -26,7 +26,7 @@
#include "BspLeaf"
#include "Surface"
#include "world/p_object.h"
#include "world/p_objlink.h"
#include "ContactBlockmap"

#include "render/projector.h"

Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/render/r_main.cpp
Expand Up @@ -45,7 +45,7 @@

#include "world/linesighttest.h"
#include "world/p_players.h"
#include "world/p_objlink.h"
#include "ContactBlockmap"
#include "world/thinkers.h"
#include "BspLeaf"
#include "Surface"
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/render/rend_main.cpp
Expand Up @@ -54,7 +54,7 @@
#include "world/generators.h"
#include "world/lineowner.h"
#include "world/p_object.h"
#include "world/p_objlink.h"
#include "ContactBlockmap"
#include "world/p_players.h"
#include "world/thinkers.h"

Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/render/vlight.cpp
Expand Up @@ -29,7 +29,7 @@
#include "BspLeaf"
#include "Surface"
#include "world/map.h"
#include "world/p_objlink.h"
#include "ContactBlockmap"

#include "render/vlight.h"

Expand Down
@@ -1,4 +1,4 @@
/** @file p_objlink.cpp World map object => BSP leaf contact blockmap.
/** @file p_objlink.cpp World object => BSP leaf "contact" blockmap.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
Expand Down Expand Up @@ -34,7 +34,7 @@
#include "render/rend_main.h" // Rend_MapSurfaceMaterialSpec
#include "WallEdge"

#include "world/p_objlink.h"
#include "world/contactblockmap.h"

using namespace de;

Expand All @@ -51,11 +51,12 @@ enum ContactType
/// @todo Obviously, polymorphism is a better solution.
struct Contact
{
Contact *nextInBlock; /// Next in the same obj block, or NULL.
Contact *nextUsed;
Contact *next; /// Next in list of ALL objlinks.
ContactType _type;
void *_object;
Contact *nextInBlock; ///< Next in the same blockmap cell (if any, not owned).
Contact *nextUsed; ///< Next in the used list (if any, not owned).
Contact *next; ///< Next in global list of contacts (if any, not owned).

ContactType _type; ///< Logical identifier.
void *_object; ///< The contacted object.

ContactType type() const
{
Expand Down Expand Up @@ -127,7 +128,7 @@ struct Contact
case ContactMobj: return Mobj_BspLeafAtOrigin(objectAs<mobj_t>());

default:
throw Error("oblink_t::objectBspLeafAtOrigin", "Invalid type");
throw Error("Contact::objectBspLeafAtOrigin", "Invalid type");
}
}
};
Expand Down Expand Up @@ -345,31 +346,31 @@ struct ContactList
{
DENG2_ASSERT(object != 0);

ListNode *con;
ListNode *node;
if(!cursor)
{
con = (ListNode *) Z_Malloc(sizeof *con, PU_APPSTATIC, 0);
node = (ListNode *) Z_Malloc(sizeof *node, PU_APPSTATIC, 0);

// Link to the list of objcontact nodes.
con->nextUsed = firstNode;
firstNode = con;
// Link in the global list of used nodes.
node->nextUsed = firstNode;
firstNode = node;
}
else
{
con = cursor;
node = cursor;
cursor = cursor->nextUsed;
}

con->obj = object;
node->obj = object;

return con;
return node;
}

ListNode *_head[ContactTypeCount]; ///< Separate lists for each contact type.
};

static Contact *objlinks;
static Contact *objlinkFirst, *objlinkCursor;
static Contact *contacts;
static Contact *contactFirst, *contactCursor;

// List of contacts for each BSP leaf.
static ContactList *bspLeafContactLists;
Expand All @@ -378,31 +379,31 @@ static Contact *newContact(void *object, ContactType type)
{
DENG2_ASSERT(object != 0);

Contact *link;
if(!objlinkCursor)
Contact *contact;
if(!contactCursor)
{
link = (Contact *) Z_Malloc(sizeof *link, PU_APPSTATIC, 0);
contact = (Contact *) Z_Malloc(sizeof *contact, PU_APPSTATIC, 0);

// Link the link to the global list.
link->nextUsed = objlinkFirst;
objlinkFirst = link;
// Link in the global list of used contacts.
contact->nextUsed = contactFirst;
contactFirst = contact;
}
else
{
link = objlinkCursor;
objlinkCursor = objlinkCursor->nextUsed;
contact = contactCursor;
contactCursor = contactCursor->nextUsed;
}

link->nextInBlock = 0;
contact->nextInBlock = 0;

// Link it to the list of in-use objlinks.
link->next = objlinks;
objlinks = link;
// Link in the list of in-use contacts.
contact->next = contacts;
contacts = contact;

link->_object = object;
link->_type = type;
contact->_object = object;
contact->_type = type;

return link;
return contact;
}

void R_InitContactBlockmaps(Map &map)
Expand Down Expand Up @@ -450,9 +451,9 @@ void R_ClearContacts(Map &map)
blockmap(ContactType(i)).unlinkAll();
}

// Start reusing objlinks.
objlinkCursor = objlinkFirst;
objlinks = 0;
// Start reusing contacts.
contactCursor = contactFirst;
contacts = 0;

// Start reusing nodes from the first one in the list.
ContactList::reset();
Expand All @@ -466,7 +467,7 @@ void R_ClearContacts(Map &map)
static void linkContact(BspLeaf &bspLeaf, Contact *contact)
{
DENG2_ASSERT(contact != 0);
// Never link to a BspLeaf with no geometry.
// BspLeafs with no geometry cannot be contacted (zero world volume).
DENG2_ASSERT(bspLeaf.hasCluster());

contactList(bspLeaf).link(contact);
Expand Down Expand Up @@ -606,7 +607,6 @@ static void maybeSpreadOverEdge(HEdge *hedge, contactfinderparams_t &parms)
// During next step, obj will continue spreading from there.
backLeaf.setValidCount(validCount);

// Link up a new contact with the back BSP leaf.
linkContact(backLeaf, parms.contact);

spreadInBspLeaf(backLeaf, parms);
Expand Down Expand Up @@ -647,16 +647,15 @@ static void spreadContact(Contact *contact)

BspLeaf &bspLeaf = contact->objectBspLeafAtOrigin();

// Do the BSP leaf spread. Begin from the obj's own BspLeaf.
linkContact(bspLeaf, contact);

// Spread to neighboring BSP leafs.
bspLeaf.setValidCount(++validCount);

contactfinderparams_t parms; zap(parms);
parms.contact = contact;
parms.objAABox = contact->objectAABox();

// Always contact the obj's own BspLeaf.
linkContact(bspLeaf, contact);

spreadInBspLeaf(bspLeaf, parms);
}

Expand Down Expand Up @@ -721,7 +720,7 @@ void R_SpreadContacts(BspLeaf &bspLeaf)

void R_AddContact(mobj_t &mobj)
{
// Never link to a BspLeaf with no geometry.
// BspLeafs with no geometry cannot be contacted (zero world volume).
if(Mobj_BspLeafAtOrigin(mobj).hasCluster())
{
newContact(&mobj, ContactMobj);
Expand All @@ -730,7 +729,7 @@ void R_AddContact(mobj_t &mobj)

void R_AddContact(Lumobj &lum)
{
// Never link to a BspLeaf with no geometry.
// BspLeafs with no geometry cannot be contacted (zero world volume).
if(lum.bspLeafAtOrigin().hasCluster())
{
newContact(&lum, ContactLumobj);
Expand All @@ -739,10 +738,10 @@ void R_AddContact(Lumobj &lum)

void R_LinkContacts()
{
// Link object-links into the relevant blockmap.
for(Contact *link = objlinks; link; link = link->next)
// Link contacts into the relevant blockmap.
for(Contact *contact = contacts; contact; contact = contact->next)
{
blockmap(link->type()).link(link);
blockmap(contact->type()).link(contact);
}
}

Expand Down
5 changes: 2 additions & 3 deletions doomsday/client/src/world/map.cpp
Expand Up @@ -50,7 +50,7 @@
#include "world/p_intercept.h"
#include "world/p_object.h"
#ifdef __CLIENT__
# include "world/p_objlink.h"
# include "ContactBlockmap"
#endif
#include "world/thinkers.h"
#include "world/world.h" // ddMapSetup
Expand Down Expand Up @@ -1142,7 +1142,7 @@ DENG2_OBSERVES(bsp::Partitioner, UnclosedSectorFound)
}

/**
* Create new objlinks for mobj => BSP leaf contact spreading.
* Create new mobj => BSP leaf contacts.
*/
void createMobjContacts()
{
Expand Down Expand Up @@ -2939,7 +2939,6 @@ void Map::worldFrameBegins(World &world, bool resetNextViewer)
}
}

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

// Link all active particle generators into the world.
Expand Down

0 comments on commit 581a39d

Please sign in to comment.