From 670854c4e89f3a8ff9b5e093fd37eb331e486b69 Mon Sep 17 00:00:00 2001 From: danij Date: Sat, 10 Mar 2012 00:31:37 +0000 Subject: [PATCH] Refactor: Renamed subsector_t as BspLeaf --- doomsday/engine/api/dd_maptypes.h | 16 +- doomsday/engine/api/dd_share.h | 8 +- doomsday/engine/api/dd_types.h | 2 +- doomsday/engine/api/doomsday.def | 4 +- doomsday/engine/api/doomsday.h | 8 +- doomsday/engine/data/cphelp.txt | 6 +- doomsday/engine/portable/include/bsp_edge.h | 2 +- doomsday/engine/portable/include/dam_main.h | 2 +- doomsday/engine/portable/include/gamemap.h | 60 ++-- doomsday/engine/portable/include/mapdata.hs | 18 +- doomsday/engine/portable/include/p_mapdata.h | 12 +- doomsday/engine/portable/include/p_maptypes.h | 20 +- doomsday/engine/portable/include/p_maputil.h | 22 +- doomsday/engine/portable/include/p_objlink.h | 22 +- .../engine/portable/include/p_subsector.h | 18 +- doomsday/engine/portable/include/r_data.h | 2 +- .../engine/portable/include/r_fakeradio.h | 6 +- doomsday/engine/portable/include/r_lumobjs.h | 52 ++-- doomsday/engine/portable/include/r_shadow.h | 8 +- doomsday/engine/portable/include/r_things.h | 10 +- doomsday/engine/portable/include/r_world.h | 4 +- doomsday/engine/portable/include/rend_clip.h | 4 +- .../engine/portable/include/rend_fakeradio.h | 4 +- doomsday/engine/portable/src/blockmapvisual.c | 32 +-- doomsday/engine/portable/src/bsp_main.c | 4 +- doomsday/engine/portable/src/bsp_map.c | 48 ++-- doomsday/engine/portable/src/bsp_node.c | 22 +- doomsday/engine/portable/src/cl_player.c | 8 +- doomsday/engine/portable/src/dam_file.c | 94 +++---- doomsday/engine/portable/src/dam_main.c | 8 +- doomsday/engine/portable/src/dd_main.c | 4 +- doomsday/engine/portable/src/edit_bias.c | 8 +- doomsday/engine/portable/src/edit_map.c | 52 ++-- doomsday/engine/portable/src/gamemap.c | 140 +++++----- doomsday/engine/portable/src/net_main.c | 2 +- doomsday/engine/portable/src/p_data.c | 6 +- doomsday/engine/portable/src/p_dmu.c | 62 ++--- doomsday/engine/portable/src/p_maputil.c | 48 ++-- doomsday/engine/portable/src/p_mobj.c | 8 +- doomsday/engine/portable/src/p_objlink.c | 128 ++++----- doomsday/engine/portable/src/p_particle.c | 16 +- doomsday/engine/portable/src/p_players.c | 8 +- doomsday/engine/portable/src/p_sight.c | 28 +- doomsday/engine/portable/src/p_subsector.c | 20 +- doomsday/engine/portable/src/p_surface.c | 2 +- doomsday/engine/portable/src/r_fakeradio.c | 46 ++-- doomsday/engine/portable/src/r_lgrid.c | 6 +- doomsday/engine/portable/src/r_lumobjs.c | 93 ++++--- doomsday/engine/portable/src/r_shadow.c | 8 +- doomsday/engine/portable/src/r_things.c | 58 ++-- doomsday/engine/portable/src/r_world.c | 118 ++++---- doomsday/engine/portable/src/rend_bias.c | 36 +-- doomsday/engine/portable/src/rend_clip.c | 30 +- doomsday/engine/portable/src/rend_decor.c | 22 +- doomsday/engine/portable/src/rend_fakeradio.c | 51 ++-- doomsday/engine/portable/src/rend_main.c | 260 +++++++++--------- doomsday/engine/portable/src/rend_particle.c | 6 +- doomsday/engine/portable/src/rend_sprite.c | 12 +- doomsday/engine/portable/src/s_environ.c | 120 ++++---- doomsday/engine/portable/src/s_sfx.c | 4 +- doomsday/engine/portable/src/sv_pool.c | 4 +- doomsday/plugins/common/include/p_mapsetup.h | 6 +- doomsday/plugins/common/src/hu_automap.c | 10 +- doomsday/plugins/common/src/mobj.c | 4 +- doomsday/plugins/common/src/p_map.c | 42 +-- doomsday/plugins/common/src/p_mapsetup.c | 15 +- doomsday/plugins/common/src/p_saveg.c | 6 +- doomsday/plugins/common/src/p_user.c | 4 +- doomsday/plugins/common/src/p_xgline.c | 2 +- doomsday/plugins/common/src/p_xgsec.c | 18 +- doomsday/plugins/jdoom/include/r_defs.h | 2 +- doomsday/plugins/jdoom/src/m_cheat.c | 6 +- doomsday/plugins/jdoom/src/p_enemy.c | 6 +- doomsday/plugins/jdoom/src/p_inter.c | 2 +- doomsday/plugins/jdoom/src/p_mobj.c | 22 +- doomsday/plugins/jdoom/src/p_oldsvg.c | 4 +- doomsday/plugins/jdoom/src/p_spec.c | 2 +- doomsday/plugins/jdoom/src/p_telept.c | 4 +- doomsday/plugins/jdoom64/include/p_mobj.h | 12 +- doomsday/plugins/jdoom64/include/r_defs.h | 2 +- doomsday/plugins/jdoom64/src/m_cheat.c | 6 +- doomsday/plugins/jdoom64/src/p_enemy.c | 6 +- doomsday/plugins/jdoom64/src/p_inter.c | 2 +- doomsday/plugins/jdoom64/src/p_mobj.c | 22 +- doomsday/plugins/jdoom64/src/p_spec.c | 2 +- doomsday/plugins/jdoom64/src/p_telept.c | 8 +- doomsday/plugins/jheretic/include/r_defs.h | 2 +- doomsday/plugins/jheretic/src/m_cheat.c | 6 +- doomsday/plugins/jheretic/src/p_enemy.c | 8 +- doomsday/plugins/jheretic/src/p_mobj.c | 24 +- doomsday/plugins/jheretic/src/p_oldsvg.c | 6 +- doomsday/plugins/jheretic/src/p_spec.c | 4 +- doomsday/plugins/jheretic/src/p_telept.c | 4 +- doomsday/plugins/jhexen/include/r_defs.h | 2 +- doomsday/plugins/jhexen/src/hrefresh.c | 2 +- doomsday/plugins/jhexen/src/m_cheat.c | 6 +- doomsday/plugins/jhexen/src/p_enemy.c | 8 +- doomsday/plugins/jhexen/src/p_mobj.c | 19 +- doomsday/plugins/jhexen/src/p_spec.c | 4 +- doomsday/plugins/jhexen/src/p_telept.c | 2 +- 100 files changed, 1115 insertions(+), 1129 deletions(-) diff --git a/doomsday/engine/api/dd_maptypes.h b/doomsday/engine/api/dd_maptypes.h index 5df1a34327..312b3870d8 100644 --- a/doomsday/engine/api/dd_maptypes.h +++ b/doomsday/engine/api/dd_maptypes.h @@ -11,7 +11,7 @@ #define DMT_HEDGE_V DDVT_PTR // [Start, End] of the segment. #define DMT_HEDGE_LINEDEF DDVT_PTR #define DMT_HEDGE_SEC DDVT_PTR -#define DMT_HEDGE_SUBSECTOR DDVT_PTR +#define DMT_HEDGE_BSPLEAF DDVT_PTR #define DMT_HEDGE_TWIN DDVT_PTR #define DMT_HEDGE_ANGLE DDVT_ANGLE #define DMT_HEDGE_SIDE DDVT_BYTE // 0=front, 1=back @@ -19,10 +19,10 @@ #define DMT_HEDGE_LENGTH DDVT_FLOAT // Accurate length of the segment (v1 -> v2). #define DMT_HEDGE_OFFSET DDVT_FLOAT -#define DMT_SUBSECTOR_HEDGECOUNT DDVT_UINT -#define DMT_SUBSECTOR_HEDGES DDVT_PTR // [hedgeCount] size. -#define DMT_SUBSECTOR_POLYOBJ DDVT_PTR // NULL, if there is no polyobj. -#define DMT_SUBSECTOR_SECTOR DDVT_PTR +#define DMT_BSPLEAF_HEDGECOUNT DDVT_UINT +#define DMT_BSPLEAF_HEDGES DDVT_PTR // [hedgeCount] size. +#define DMT_BSPLEAF_POLYOBJ DDVT_PTR // NULL, if there is no polyobj. +#define DMT_BSPLEAF_SECTOR DDVT_PTR #define DMT_MATERIAL_FLAGS DDVT_SHORT #define DMT_MATERIAL_WIDTH DDVT_INT @@ -51,8 +51,8 @@ #define DMT_SECTOR_MOBJLIST DDVT_PTR // List of mobjs in the sector. #define DMT_SECTOR_LINEDEFCOUNT DDVT_UINT #define DMT_SECTOR_LINEDEFS DDVT_PTR // [lineDefCount+1] size. -#define DMT_SECTOR_SUBSECTORCOUNT DDVT_UINT -#define DMT_SECTOR_SUBSECTORS DDVT_PTR // [subsectorCount+1] size. +#define DMT_SECTOR_BSPLEAFCOUNT DDVT_UINT +#define DMT_SECTOR_BSPLEAFS DDVT_PTR // [bspLeafCount+1] size. #define DMT_SECTOR_SOUNDORG DDVT_PTR #define DMT_SECTOR_PLANECOUNT DDVT_UINT #define DMT_SECTOR_REVERB DDVT_FLOAT @@ -75,6 +75,6 @@ #define DMT_LINEDEF_DY DDVT_FLOAT #define DMT_BSPNODE_BBOX DDVT_FLOAT // Bounding box for each child. -#define DMT_BSPNODE_CHILDREN DDVT_UINT // If NF_SUBSECTOR it's a subsector. +#define DMT_BSPNODE_CHILDREN DDVT_UINT // If NF_LEAF it's a BspLeaf. #endif diff --git a/doomsday/engine/api/dd_share.h b/doomsday/engine/api/dd_share.h index dea80d11da..982fc10223 100644 --- a/doomsday/engine/api/dd_share.h +++ b/doomsday/engine/api/dd_share.h @@ -277,7 +277,7 @@ enum { DD_SIDE_COUNT, DD_VERTEX_COUNT, DD_HEDGE_COUNT, - DD_SUBSECTOR_COUNT, + DD_BSPLEAF_COUNT, DD_BSPNODE_COUNT, DD_POLYOBJ_COUNT, DD_XGFUNC_LINK, ///< XG line classes @@ -656,7 +656,7 @@ enum { DMU_LINEDEF, DMU_SIDEDEF, DMU_BSPNODE, - DMU_SUBSECTOR, + DMU_BSPLEAF, DMU_SECTOR, DMU_PLANE, DMU_SURFACE, @@ -1029,7 +1029,7 @@ typedef struct aaboxf_s { nodeindex_t lineRoot; /* lines to which this is linked */ \ struct mobj_s* sNext, **sPrev; /* links in sector (if needed) */ \ \ - struct subsector_s* subsector; /* subsector in which this resides */ \ + struct bspleaf_s* bspLeaf; /* bspLeaf in which this resides */ \ float mom[3]; \ angle_t angle; \ spritenum_t sprite; /* used to find patch_t and flip value */ \ @@ -1069,7 +1069,7 @@ typedef struct aaboxf_s { #define DD_BASE_POLYOBJ_ELEMENTS() \ DD_BASE_DDMOBJ_ELEMENTS() \ \ - struct subsector_s* subsector; /* subsector in which this resides */ \ + struct bspleaf_s* bspLeaf; /* bspLeaf in which this resides */ \ unsigned int idx; /* Idx of polyobject. */ \ int tag; /* Reference tag. */ \ int validCount; \ diff --git a/doomsday/engine/api/dd_types.h b/doomsday/engine/api/dd_types.h index 9e16ba2f09..b7371d1c77 100644 --- a/doomsday/engine/api/dd_types.h +++ b/doomsday/engine/api/dd_types.h @@ -209,7 +209,7 @@ struct vertex_s; struct linedef_s; struct side_s; struct hedge_s; -struct subsector_s; +struct bspleaf_s; struct sector_s; struct polyblock_s; struct polyobj_s; diff --git a/doomsday/engine/api/doomsday.def b/doomsday/engine/api/doomsday.def index d6cd872ffe..14f5006815 100644 --- a/doomsday/engine/api/doomsday.def +++ b/doomsday/engine/api/doomsday.def @@ -449,12 +449,12 @@ EXPORTS P_TraceLOS @829 NONAME P_TraceOpening @828 NONAME P_SetTraceOpening @64 NONAME - P_SubsectorAtPointXY @102 NONAME + P_BspLeafAtPointXY @102 NONAME P_MobjsBoxIterator @346 NONAME P_LinesBoxIterator @435 NONAME P_AllLinesBoxIterator @347 NONAME P_PolyobjsBoxIterator @348 NONAME - P_SubsectorsBoxIterator @345 NONAME + P_BspLeafsBoxIterator @345 NONAME P_LineMobjsIterator @73 NONAME P_SectorTouchingMobjsIterator @74 NONAME P_PathTraverse @692 NONAME diff --git a/doomsday/engine/api/doomsday.h b/doomsday/engine/api/doomsday.h index 24bd272442..791322b43e 100644 --- a/doomsday/engine/api/doomsday.h +++ b/doomsday/engine/api/doomsday.h @@ -70,7 +70,7 @@ extern "C" { typedef struct linedef_s { int type; } linedef_t; typedef struct sidedef_s { int type; } sidedef_t; typedef struct hedge_s { int type; } HEdge; - typedef struct subsector_s { int type; } subsector_t; + typedef struct bspleaf_s { int type; } BspLeaf; typedef struct sector_s { int type; } sector_t; typedef struct plane_s { int type; } plane_t; typedef struct material_s { int type; } material_t; @@ -427,7 +427,7 @@ boolean ClMobj_LocalActionsEnabled(struct mobj_s* mo); TraceOpening* P_TraceOpening(void); void P_SetTraceOpening(struct linedef_s* linedef); - struct subsector_s* P_SubsectorAtPointXY(float x, float y); + struct bspleaf_s* P_BspLeafAtPointXY(float x, float y); // Object in bounding box iterators. int P_MobjsBoxIterator(const AABoxf* box, @@ -439,8 +439,8 @@ boolean ClMobj_LocalActionsEnabled(struct mobj_s* mo); int P_AllLinesBoxIterator(const AABoxf* box, int (*func) (struct linedef_s*, void*), void* data); - int P_SubsectorsBoxIterator(const AABoxf* box, sector_t* sector, - int (*func) (subsector_t*, void*), + int P_BspLeafsBoxIterator(const AABoxf* box, sector_t* sector, + int (*func) (BspLeaf*, void*), void* data); int P_PolyobjsBoxIterator(const AABoxf* box, int (*func) (struct polyobj_s*, void*), diff --git a/doomsday/engine/data/cphelp.txt b/doomsday/engine/data/cphelp.txt index a92ce183a0..4ee89b6186 100644 --- a/doomsday/engine/data/cphelp.txt +++ b/doomsday/engine/data/cphelp.txt @@ -637,7 +637,7 @@ desc = 1=Display lumobj debug display. desc = 1=Display particle generator indices. [rend-dev-blockmap] -desc = Enable drawing of the blockmap debug display: 1=Mobjs, 2=Linedefs, 3=Subsectors, 4=Polyobjs. +desc = Enable drawing of the blockmap debug display: 1=Mobjs, 2=Linedefs, 3=BspLeafs, 4=Polyobjs. [rend-dev-blockmap-size] desc = Scale multiplier for the blockmap debug display. @@ -1071,8 +1071,8 @@ desc = Halo dimming relative end distance. [rend-dev-freeze] desc = 1=Stop updating rendering lists. -[rend-dev-cull-subsectors] -desc = 1=Disable non-visible subsector culling. +[rend-dev-cull-leafs] +desc = 1=Disable non-visible bsp leaf culling. [rend-dev-mobj-bbox] desc = 1=Render mobj bounding boxes (as used for collision detection). diff --git a/doomsday/engine/portable/include/bsp_edge.h b/doomsday/engine/portable/include/bsp_edge.h index a1da0ec0a9..6dcc3b349a 100644 --- a/doomsday/engine/portable/include/bsp_edge.h +++ b/doomsday/engine/portable/include/bsp_edge.h @@ -78,7 +78,7 @@ typedef struct bsp_hedge_s { int index; // The superblock that contains this half-edge, or NULL if the half-edge - // is no longer in any superblock (e.g. now in a subsector). + // is no longer in any superblock (e.g. now in a leaf). struct superblock_s* block; // Precomputed data for faster calculations. diff --git a/doomsday/engine/portable/include/dam_main.h b/doomsday/engine/portable/include/dam_main.h index d4d537fe72..322d3975fa 100644 --- a/doomsday/engine/portable/include/dam_main.h +++ b/doomsday/engine/portable/include/dam_main.h @@ -36,7 +36,7 @@ enum { ML_SIDEDEFS, // SideDefs, from editing ML_VERTEXES, // Vertices, edited and BSP splits generated ML_SEGS, // LineSegs, from LineDefs split by BSP - ML_SSECTORS, // Subsectors, list of LineSegs + ML_SSECTORS, // Subsectors (BSP leafs), list of LineSegs ML_NODES, // BSP nodes ML_SECTORS, // Sectors, from editing ML_REJECT, // LUT, sector-sector visibility diff --git a/doomsday/engine/portable/include/gamemap.h b/doomsday/engine/portable/include/gamemap.h index 58d2f1c8c7..bf2a6cbaf1 100644 --- a/doomsday/engine/portable/include/gamemap.h +++ b/doomsday/engine/portable/include/gamemap.h @@ -87,8 +87,8 @@ typedef struct gamemap_s { uint numSectors; sector_t* sectors; - uint numSubsectors; - subsector_t* subsectors; + uint numBspLeafs; + BspLeaf* bspLeafs; uint numBspNodes; BspNode* bspNodes; @@ -112,7 +112,7 @@ typedef struct gamemap_s { struct blockmap_s* mobjBlockmap; struct blockmap_s* polyobjBlockmap; struct blockmap_s* lineDefBlockmap; - struct blockmap_s* subsectorBlockmap; + struct blockmap_s* bspLeafBlockmap; nodepile_t mobjNodes, lineNodes; // All kinds of wacky links. nodeindex_t* lineLinks; // Indices to roots. @@ -234,13 +234,13 @@ sidedef_t* GameMap_SideDef(GameMap* map, uint idx); sector_t* GameMap_Sector(GameMap* map, uint idx); /** - * Lookup a Subsector by its unique index. + * Lookup a BspLeaf by its unique index. * * @param map GameMap instance. - * @param idx Unique index of the subsector. - * @return Pointer to Subsector with this index else @c NULL if @a idx is not valid. + * @param idx Unique index of the bsp leaf. + * @return Pointer to BspLeaf with this index else @c NULL if @a idx is not valid. */ -subsector_t* GameMap_Subsector(GameMap* map, uint idx); +BspLeaf* GameMap_BspLeaf(GameMap* map, uint idx); /** * Lookup a HEdge by its unique index. @@ -297,13 +297,13 @@ int GameMap_SideDefIndex(GameMap* map, sidedef_t* side); int GameMap_SectorIndex(GameMap* map, sector_t* sector); /** - * Lookup the unique index for @a subsector. + * Lookup the unique index for @a bspLeaf. * * @param map GameMap instance. - * @param subsector Subsector to lookup. - * @return Unique index for the Subsector else @c -1 if not present. + * @param bspLeaf BspLeaf to lookup. + * @return Unique index for the BspLeaf else @c -1 if not present. */ -int GameMap_SubsectorIndex(GameMap* map, subsector_t* subsector); +int GameMap_BspLeafIndex(GameMap* map, BspLeaf* bspLeaf); /** * Lookup the unique index for @a hedge. @@ -356,12 +356,12 @@ uint GameMap_SideDefCount(GameMap* map); uint GameMap_SectorCount(GameMap* map); /** - * Retrieve the number of Subsector instances owned by this. + * Retrieve the number of BspLeaf instances owned by this. * * @param map GameMap instance. - * @return Number Subsector. + * @return Number BspLeaf. */ -uint GameMap_SubsectorCount(GameMap* map); +uint GameMap_BspLeafCount(GameMap* map); /** * Retrieve the number of HEdge instances owned by this. @@ -633,26 +633,26 @@ int GameMap_AllLineDefsBoxIterator(GameMap* map, const AABoxf* box, int (*callback) (linedef_t*, void*), void* parameters); /** - * Construct an initial (empty) Subsector Blockmap for this map. + * Construct an initial (empty) BspLeaf Blockmap for this map. * * @param min Minimal coordinates for the map. * @param max Maximal coordinates for the map. */ -void GameMap_InitSubsectorBlockmap(GameMap* map, const_pvec2_t min, const_pvec2_t max); +void GameMap_InitBspLeafBlockmap(GameMap* map, const_pvec2_t min, const_pvec2_t max); -void GameMap_LinkSubsectorInBlockmap(GameMap* map, subsector_t* subsector); +void GameMap_LinkBspLeafInBlockmap(GameMap* map, BspLeaf* bspLeaf); -int GameMap_IterateCellSubsectors(GameMap* map, const uint coords[2], +int GameMap_IterateCellBspLeafs(GameMap* map, const uint coords[2], sector_t* sector, const AABoxf* box, int localValidCount, - int (*callback) (subsector_t*, void*), void* parameters); -int GameMap_IterateCellBlockSubsectors(GameMap* map, const struct gridmapblock_s* blockCoords, + int (*callback) (BspLeaf*, void*), void* parameters); +int GameMap_IterateCellBlockBspLeafs(GameMap* map, const struct gridmapblock_s* blockCoords, sector_t* sector, const AABoxf* box, int localValidCount, - int (*callback) (subsector_t*, void*), void* parameters); + int (*callback) (BspLeaf*, void*), void* parameters); -int GameMap_SubsectorsBoxIterator(GameMap* map, const AABoxf* box, sector_t* sector, - int (*callback) (subsector_t*, void*), void* parameters); +int GameMap_BspLeafsBoxIterator(GameMap* map, const AABoxf* box, sector_t* sector, + int (*callback) (BspLeaf*, void*), void* parameters); -int GameMap_SubsectorIterator(GameMap* map, int (*callback) (subsector_t*, void*), void* parameters); +int GameMap_BspLeafIterator(GameMap* map, int (*callback) (BspLeaf*, void*), void* parameters); /** * Construct an initial (empty) Polyobj Blockmap for this map. @@ -706,18 +706,18 @@ int GameMap_PathXYTraverse(GameMap* map, float fromX, float fromY, float toX, fl int flags, traverser_t callback); /** - * Determine the BSP leaf (subsector) on the back side of the BS partition that - * lies in front of the specified point within the map's coordinate space. + * Determine the BSP leaf on the back side of the BS partition that lies in front + * of the specified point within the map's coordinate space. * - * @note Always returns a valid subsector although the point may not actually lay + * @note Always returns a valid BspLeaf although the point may not actually lay * within it (however it is on the same side of the space partition)! * * @param map GameMap instance. * @param x X coordinate of the point to test. * @param y Y coordinate of the point to test. - * @return Subsector instance for that BSP node's leaf. + * @return BspLeaf instance for that BSP node's leaf. */ -subsector_t* GameMap_SubsectorAtPoint(GameMap* map, float point[2]); -subsector_t* GameMap_SubsectorAtPointXY(GameMap* map, float x, float y); +BspLeaf* GameMap_BspLeafAtPoint(GameMap* map, float point[2]); +BspLeaf* GameMap_BspLeafAtPointXY(GameMap* map, float x, float y); #endif /// LIBDENG_GAMEMAP_H diff --git a/doomsday/engine/portable/include/mapdata.hs b/doomsday/engine/portable/include/mapdata.hs index 68989a90a4..cc09f070c4 100644 --- a/doomsday/engine/portable/include/mapdata.hs +++ b/doomsday/engine/portable/include/mapdata.hs @@ -90,7 +90,7 @@ struct seg PTR vertex_s*[2] v // [Start, End] of the segment. PTR linedef_s* lineDef PTR sector_s*[2] sec - PTR subsector_s* subsector + PTR bspleaf_s* bspLeaf PTR hedge_s* twin ANGLE angle_t angle BYTE byte side // 0=front, 1=back @@ -102,10 +102,10 @@ struct seg end internal -#define SUBF_MIDPOINT 0x80 // Midpoint is tri-fan centre. +#define BLF_MIDPOINT 0x80 ///< Midpoint is tri-fan centre. end -struct subsector +struct BspLeaf UINT uint hedgeCount PTR hedge_s** hedges // [hedgeCount] size. PTR polyobj_s* polyObj // NULL, if there is no polyobj. @@ -179,7 +179,7 @@ internal typedef struct surfacedecor_s { float pos[3]; // World coordinates of the decoration. - subsector_t* subsector; + BspLeaf* bspLeaf; const struct ded_decorlight_s* def; } surfacedecor_t; end @@ -318,10 +318,10 @@ struct sector PTR mobj_s* mobjList // List of mobjs in the sector. UINT uint lineDefCount PTR linedef_s** lineDefs // [lineDefCount+1] size. - UINT uint subsectorCount - PTR subsector_s** subsectors // [subsectorCount+1] size. - - uint numReverbSubsectorAttributors - - subsector_s** reverbSubsectors // [numReverbSubsectorAttributors] size. + UINT uint bspLeafCount + PTR bspleaf_s** bspLeafs // [bspLeafCount+1] size. + - uint numReverbBspLeafAttributors + - bspleaf_s** reverbBspLeafs // [numReverbBspLeafAttributors] size. PTR ddmobj_base_t soundOrg UINT uint planeCount - plane_s** planes // [planeCount+1] size. @@ -513,5 +513,5 @@ end struct BspNode - partition_t partition FLOAT float[2][4] bBox // Bounding box for each child. - UINT uint[2] children // If NF_SUBSECTOR it's a subsector. + UINT uint[2] children // If NF_LEAF it's a BspLeaf. end diff --git a/doomsday/engine/portable/include/p_mapdata.h b/doomsday/engine/portable/include/p_mapdata.h index 2ac8e6ecc8..1e2f23a6d4 100644 --- a/doomsday/engine/portable/include/p_mapdata.h +++ b/doomsday/engine/portable/include/p_mapdata.h @@ -39,7 +39,7 @@ #define GET_LINE_IDX(li) GameMap_LineDefIndex(theMap, li) #define GET_SIDE_IDX(si) GameMap_SideDefIndex(theMap, si) #define GET_SECTOR_IDX(sec) GameMap_SectorIndex(theMap, sec) -#define GET_SUBSECTOR_IDX(ssec) GameMap_SubsectorIndex(theMap, ssec) +#define GET_BSPLEAF_IDX(bspLeaf) GameMap_BspLeafIndex(theMap, bspLeaf) #define GET_HEDGE_IDX(he) GameMap_HEdgeIndex(theMap, he) #define GET_BSPNODE_IDX(nd) GameMap_BspNodeIndex(theMap, nd) @@ -47,7 +47,7 @@ #define LINE_PTR(idx) GameMap_LineDef(theMap, idx) #define SIDE_PTR(idx) GameMap_SideDef(theMap, idx) #define SECTOR_PTR(idx) GameMap_Sector(theMap, idx) -#define SUBSECTOR_PTR(idx) GameMap_Subsector(theMap, idx) +#define BSPLEAF_PTR(idx) GameMap_BspLeaf(theMap, idx) #define HEDGE_PTR(idx) GameMap_HEdge(theMap, idx) #define BSPNODE_PTR(idx) GameMap_BspNode(theMap, idx) @@ -55,16 +55,16 @@ #define NUM_LINEDEFS GameMap_LineDefCount(theMap) #define NUM_SIDEDEFS GameMap_SideDefCount(theMap) #define NUM_SECTORS GameMap_SectorCount(theMap) -#define NUM_SUBSECTORS GameMap_SubsectorCount(theMap) +#define NUM_BSPLEAFS GameMap_BspLeafCount(theMap) #define NUM_HEDGES GameMap_HEdgeCount(theMap) #define NUM_BSPNODES GameMap_BspNodeCount(theMap) #define NUM_POLYOBJS GameMap_PolyobjCount(theMap) // Node flags. -#define NF_SUBSECTOR 0x80000000 +#define NF_LEAF 0x80000000 -// Runtime map data objects, such as vertices, sectors, and subsectors all +// Runtime map data objects, such as vertices, sectors, and BspLeafs all // have this header as their first member. This makes it possible to treat // an unknown map data pointer as a runtime_mapdata_header_t* and determine // its type. Note that this information is internal to the engine. @@ -176,7 +176,7 @@ extern Uri* mapUri; extern vertex_t* vertexes; extern HEdge* hedges; extern sector_t* sectors; -extern subsector_t* subsectors; +extern BspLeaf* bspLeafs; extern BspNode* bspNodes; extern linedef_t* lineDefs; extern sidedef_t* sideDefs; diff --git a/doomsday/engine/portable/include/p_maptypes.h b/doomsday/engine/portable/include/p_maptypes.h index 144ec2be50..3a18567065 100644 --- a/doomsday/engine/portable/include/p_maptypes.h +++ b/doomsday/engine/portable/include/p_maptypes.h @@ -84,7 +84,7 @@ typedef struct hedge_s { struct vertex_s* v[2]; // [Start, End] of the segment. struct linedef_s* lineDef; struct sector_s* sec[2]; - struct subsector_s* subsector; + struct bspleaf_s* bspLeaf; struct hedge_s* twin; angle_t angle; byte side; // 0=front, 1=back @@ -95,9 +95,9 @@ typedef struct hedge_s { short frameFlags; } HEdge; -#define SUBF_MIDPOINT 0x80 // Midpoint is tri-fan centre. +#define BLF_MIDPOINT 0x80 // Midpoint is tri-fan centre. -typedef struct subsector_s { +typedef struct bspleaf_s { runtime_mapdata_header_t header; unsigned int hedgeCount; struct hedge_s** hedges; // [hedgeCount] size. @@ -115,7 +115,7 @@ typedef struct subsector_s { struct fvertex_s** vertices; // [numvertices] size struct shadowlink_s* shadows; struct biassurface_s** bsuf; // [sector->planeCount] size. -} subsector_t; +} BspLeaf; typedef enum { MEC_UNKNOWN = -1, @@ -164,7 +164,7 @@ typedef struct material_s { typedef struct surfacedecor_s { float pos[3]; // World coordinates of the decoration. - subsector_t* subsector; + BspLeaf* bspLeaf; const struct ded_decorlight_s* def; } surfacedecor_t; @@ -297,10 +297,10 @@ typedef struct sector_s { struct mobj_s* mobjList; // List of mobjs in the sector. unsigned int lineDefCount; struct linedef_s** lineDefs; // [lineDefCount+1] size. - unsigned int subsectorCount; - struct subsector_s** subsectors; // [subsectorCount+1] size. - unsigned int numReverbSSecAttributors; - struct subsector_s** reverbSubsectors; // [numReverbSSecAttributors] size. + unsigned int bspLeafCount; + struct bspleaf_s** bspLeafs; // [bspLeafCount+1] size. + unsigned int numReverbBspLeafAttributors; + struct bspleaf_s** reverbBspLeafs; // [numReverbBspLeafAttributors] size. ddmobj_base_t soundOrg; unsigned int planeCount; struct plane_s** planes; // [planeCount+1] size. @@ -478,7 +478,7 @@ typedef struct bspnode_s { runtime_mapdata_header_t header; partition_t partition; float bBox[2][4]; // Bounding box for each child. - unsigned int children[2]; // If NF_SUBSECTOR it's a subsector. + unsigned int children[2]; // If NF_LEAF it's a BspLeaf. } BspNode; #endif diff --git a/doomsday/engine/portable/include/p_maputil.h b/doomsday/engine/portable/include/p_maputil.h index cfc5ca25c6..1fcb06b3ad 100644 --- a/doomsday/engine/portable/include/p_maputil.h +++ b/doomsday/engine/portable/include/p_maputil.h @@ -91,20 +91,20 @@ const TraceOpening* P_TraceOpening(void); void P_SetTraceOpening(linedef_t* linedef); /** - * Determine the BSP leaf (subsector) on the back side of the BS partition that - * lies in front of the specified point within the CURRENT map's coordinate space. + * Determine the BSP leaf on the back side of the BS partition that lies in + * front of the specified point within the CURRENT map's coordinate space. * - * @note Always returns a valid subsector although the point may not actually lay + * @note Always returns a valid BspLeaf although the point may not actually lay * within it (however it is on the same side of the space partition)! * * @param x X coordinate of the point to test. * @param y Y coordinate of the point to test. - * @return Subsector instance for that BSP node's leaf. + * @return BspLeaf instance for that BSP node's leaf. */ -subsector_t* P_SubsectorAtPointXY(float x, float y); +BspLeaf* P_BspLeafAtPointXY(float x, float y); /** - * Is the point inside the sector, according to the edge lines of the subsector. + * Is the point inside the sector, according to the edge lines of the BspLeaf. * * @param X coordinate to test. * @param Y coordinate to test. @@ -115,18 +115,18 @@ subsector_t* P_SubsectorAtPointXY(float x, float y); boolean P_IsPointXYInSector(float x, float y, const sector_t* sector); /** - * Is the point inside the subsector, according to the edge lines of the subsector. + * Is the point inside the BspLeaf (according to the edges). * * @algorithm Uses the well-known algorithm described here: * http://www.alienryderflex.com/polygon/ * * @param x X coordinate to test. * @param y Y coordinate to test. - * @param subsector Subsector to test. + * @param bspLeaf BspLeaf to test. * - * @return @c true, if the point is inside the subsector. + * @return @c true, if the point is inside the BspLeaf. */ -boolean P_IsPointXYInSubsector(float x, float y, const subsector_t* subsector); +boolean P_IsPointXYInBspLeaf(float x, float y, const BspLeaf* bspLeaf); void P_MobjLink(mobj_t* mo, byte flags); int P_MobjUnlink(mobj_t* mo); @@ -182,7 +182,7 @@ int P_PolyobjLinesBoxIterator(const AABoxf* box, int (*callback) (linedef_t*, vo */ int P_AllLinesBoxIterator(const AABoxf* box, int (*callback) (linedef_t*, void*), void* parameters); -int P_SubsectorsBoxIterator(const AABoxf* box, sector_t* sector, int (*callback) (subsector_t*, void*), void* parameters); +int P_BspLeafsBoxIterator(const AABoxf* box, sector_t* sector, int (*callback) (BspLeaf*, void*), void* parameters); int P_PathTraverse(float const from[2], float const to[2], int flags, traverser_t callback); int P_PathTraverse2(float const from[2], float const to[2], int flags, traverser_t callback, void* parameters); diff --git a/doomsday/engine/portable/include/p_objlink.h b/doomsday/engine/portable/include/p_objlink.h index cdaa46c9ec..42655fc84d 100644 --- a/doomsday/engine/portable/include/p_objlink.h +++ b/doomsday/engine/portable/include/p_objlink.h @@ -25,7 +25,7 @@ /** * p_objlink.c: Objlink management. * - * Object => Subsector contacts and object => Subsector spreading. + * Object => BspLeaf contacts and object => BspLeaf spreading. */ #ifndef LIBDENG_OBJLINK_BLOCKMAP_H @@ -56,7 +56,7 @@ void R_DestroyObjlinkBlockmap(void); void R_InitObjlinkBlockmapForMap(void); /** - * Initialize the object => Subsector contact lists, ready for linking to + * 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(void); @@ -79,32 +79,32 @@ void R_ObjlinkCreate(void* object, objtype_t type); void R_LinkObjs(void); /** - * Spread object => Subsector links for the given @a subsector. Note that + * Spread object => BspLeaf links for the given @a BspLeaf. Note that * all object types will be spread at this time. */ -void R_InitForSubsector(subsector_t* subsector); +void R_InitForBspLeaf(BspLeaf* bspLeaf); typedef struct { void* obj; objtype_t type; -} linkobjtosubsectorparams_t; +} linkobjtobspleafparams_t; /** - * Create a new object => Subsector contact in the objlink blockmap. + * Create a new object => BspLeaf contact in the objlink blockmap. * Can be used as an iterator. * - * @params paramaters @see linkobjtosubsectorparams_t + * @params paramaters @see linkobjtobspleafparams_t * @return @c false (always). */ -int RIT_LinkObjToSubsector(subsector_t* subsector, void* paramaters); +int RIT_LinkObjToBspLeaf(BspLeaf* bspLeaf, void* paramaters); /** * Traverse the list of objects of the specified @a type which have been linked - * with @a subsector for the current render frame. + * with @a bspLeaf for the current render frame. */ -int R_IterateSubsectorContacts2(subsector_t* subsector, objtype_t type, +int R_IterateBspLeafContacts2(BspLeaf* bspLeaf, objtype_t type, int (*func) (void* object, void* paramaters), void* paramaters); -int R_IterateSubsectorContacts(subsector_t* subsector, objtype_t type, +int R_IterateBspLeafContacts(BspLeaf* bspLeaf, objtype_t type, int (*func) (void* object, void* paramaters)); /*paramaters=NULL*/ #endif /* LIBDENG_OBJLINK_BLOCKMAP_H */ diff --git a/doomsday/engine/portable/include/p_subsector.h b/doomsday/engine/portable/include/p_subsector.h index 7980e9a678..271c56fad6 100644 --- a/doomsday/engine/portable/include/p_subsector.h +++ b/doomsday/engine/portable/include/p_subsector.h @@ -1,4 +1,4 @@ -/**\file p_subsector.h +/**\file bspleaf.h *\section License * License: GPL * Online License Link: http://www.gnu.org/licenses/gpl.html @@ -23,23 +23,23 @@ */ /** - * Map subsector + * Map BSP leaf */ -#ifndef LIBDENG_MAP_SUBSECTOR_H -#define LIBDENG_MAP_SUBSECTOR_H +#ifndef LIBDENG_MAP_BSPLEAF_H +#define LIBDENG_MAP_BSPLEAF_H #include "r_data.h" #include "p_dmu.h" /** - * Get the value of a subsector property, selected by DMU_* name. + * Get the value of property, selected by DMU_* name. */ -int Subsector_GetProperty(const subsector_t* subsector, setargs_t* args); +int BspLeaf_GetProperty(const BspLeaf* bspLeaf, setargs_t* args); /** - * Update the subsector, property is selected by DMU_* name. + * Update a property, selected by DMU_* name. */ -int Subsector_SetProperty(subsector_t* subsector, const setargs_t* args); +int BspLeaf_SetProperty(BspLeaf* bspLeaf, const setargs_t* args); -#endif /* LIBDENG_MAP_SUBSECTOR_H */ +#endif /// LIBDENG_MAP_BSPLEAF_H diff --git a/doomsday/engine/portable/include/r_data.h b/doomsday/engine/portable/include/r_data.h index bd3d30d56f..05c5d61ce5 100644 --- a/doomsday/engine/portable/include/r_data.h +++ b/doomsday/engine/portable/include/r_data.h @@ -450,7 +450,7 @@ void R_GetColorPaletteRGBf(colorpaletteid_t id, int colorIdx, float rgb[3], bool */ boolean R_SetDefaultColorPalette(colorpaletteid_t id); -//boolean R_UpdateSubsector(struct subsector_t* subsector, boolean forceUpdate); +//boolean R_UpdateBspLeaf(struct BspLeaf* bspLeaf, boolean forceUpdate); boolean R_UpdateSector(struct sector_s* sec, boolean forceUpdate); boolean R_UpdateLinedef(struct linedef_s* line, boolean forceUpdate); boolean R_UpdateSidedef(struct sidedef_s* side, boolean forceUpdate); diff --git a/doomsday/engine/portable/include/r_fakeradio.h b/doomsday/engine/portable/include/r_fakeradio.h index ac79fbbe9c..dcb19d4573 100644 --- a/doomsday/engine/portable/include/r_fakeradio.h +++ b/doomsday/engine/portable/include/r_fakeradio.h @@ -29,14 +29,14 @@ * is that the corners of a room are slightly dimmer than the rest of * the surfaces. (It's not the only characteristic, however.) We * will fake these shadowed areas by generating shadow polygons for - * wall segments and determining, which subsector vertices will be + * wall segments and determining, which BSP leaf vertices will be * shadowed. * * In other words, walls use shadow polygons (over entire hedges), while * planes use vertex lighting. Since planes are usually tesselated - * into a great deal of subsectors (and triangles), they are better + * into a great deal of BSP leafs (and triangles), they are better * suited for vertex lighting. In some cases we will be forced to - * split a subsector into smaller pieces than strictly necessary in + * split a BSP leaf into smaller pieces than strictly necessary in * order to achieve better accuracy in the shadow effect. */ diff --git a/doomsday/engine/portable/include/r_lumobjs.h b/doomsday/engine/portable/include/r_lumobjs.h index 585c5af0db..a656b1bcc1 100644 --- a/doomsday/engine/portable/include/r_lumobjs.h +++ b/doomsday/engine/portable/include/r_lumobjs.h @@ -31,8 +31,8 @@ // Lumobject types. typedef enum { - LT_OMNI, // Omni (spherical) light. - LT_PLANE, // Planar light. + LT_OMNI, ///< Omni (spherical) light. + LT_PLANE ///< Planar light. } lumtype_t; // Helper macros for accessing lum data. @@ -42,7 +42,7 @@ typedef enum { typedef struct lumobj_s { lumtype_t type; float pos[3]; // Center of the obj. - subsector_t* subsector; + BspLeaf* bspLeaf; float maxDistance; void* decorSource; // decorsource_t ptr, else @c NULL. @@ -115,10 +115,10 @@ void LO_UnlinkMobjLumobjs(void); uint LO_GetNumLuminous(void); /** - * Construct a new lumobj and link it into subsector @a subsector. + * Construct a new lumobj and link it into @a bspLeaf. * @return Logical index (name) for referencing the new lumobj. */ -uint LO_NewLuminous(lumtype_t type, subsector_t* subsector); +uint LO_NewLuminous(lumtype_t type, BspLeaf* bspLeaf); /// @return Lumobj associated with logical index @a idx else @c NULL. lumobj_t* LO_GetLuminous(uint idx); @@ -146,60 +146,60 @@ float LO_DistanceToViewer(uint idx, int i); float LO_AttenuationFactor(uint idx, float distance); /** - * Clip lumobj, omni lights in the given subsector. + * Clip lumobj, omni lights in the given BspLeaf. * - * @param subsectorIdx Subsector index in which lights will be clipped. + * @param bspLeafIdx BspLeaf index in which lights will be clipped. */ -void LO_ClipInSubsector(uint subsectorIdx); +void LO_ClipInBspLeaf(uint bspLeafIdx); /** - * In the situation where a subsector contains both lumobjs and a polyobj, + * In the situation where a BSP leaf contains both lumobjs and a polyobj, * the lumobjs must be clipped more carefully. Here we check if the line of * sight intersects any of the polyobj hedges that face the camera. * - * @param subsectorIdx Subsector index in which lumobjs will be clipped. + * @param bspLeafIdx BspLeaf index in which lumobjs will be clipped. */ -void LO_ClipInSubsectorBySight(uint subsectorIdx); +void LO_ClipInBspLeafBySight(uint bspLeafIdx); /** * Iterate over all luminous objects within the specified origin range, making * a callback for each visited. Iteration ends when all selected luminous objects * have been visited or a callback returns non-zero. * - * @param subsector The subsector in which the origin resides. - * @param x X coordinate of the origin (must be within @a subsector). - * @param y Y coordinate of the origin (must be within @a subsector). + * @param bspLeaf BspLeaf in which the origin resides. + * @param x X coordinate of the origin (must be within @a bspLeaf). + * @param y Y coordinate of the origin (must be within @a bspLeaf). * @param radius Radius of the range around the origin point. * @param callback Callback to make for each object. * @param paramaters Data to pass to the callback. * * @return @c 0 iff iteration completed wholly. */ -int LO_LumobjsRadiusIterator2(subsector_t* subsector, float x, float y, float radius, +int LO_LumobjsRadiusIterator2(BspLeaf* bspLeaf, float x, float y, float radius, int (*callback) (const lumobj_t* lum, float distance, void* paramaters), void* paramaters); -int LO_LumobjsRadiusIterator(subsector_t* subsector, float x, float y, float radius, +int LO_LumobjsRadiusIterator(BspLeaf* bspLeaf, float x, float y, float radius, int (*callback) (const lumobj_t* lum, float distance, void* paramaters)); /* paramaters = NULL */ /** * @defgroup projectLightFlags Flags for LO_ProjectToSurface. - * @{ */ -#define PLF_SORT_LUMINOSITY_DESC 0x1 /// Sort by descending luminosity, brightest to dullest. -#define PLF_NO_PLANE 0x2 /// Surface is not lit by planar lights. -#define PLF_TEX_FLOOR 0x4 /// Prefer the "floor" slot when picking textures. -#define PLF_TEX_CEILING 0x8 /// Prefer the "ceiling" slot when picking textures. -/**@}*/ +///@{ +#define PLF_SORT_LUMINOSITY_DESC 0x1 ///< Sort by descending luminosity, brightest to dullest. +#define PLF_NO_PLANE 0x2 ///< Surface is not lit by planar lights. +#define PLF_TEX_FLOOR 0x4 ///< Prefer the "floor" slot when picking textures. +#define PLF_TEX_CEILING 0x8 ///< Prefer the "ceiling" slot when picking textures. +///@} /** * Project all lights affecting the given quad (world space), calculate * coordinates (in texture space) then store into a new list of projections. * - * \assume The coordinates of the given quad must be contained wholly within - * the subsector specified. This is due to an optimization within the lumobj + * @assume The coordinates of the given quad must be contained wholly within + * the BSP leaf specified. This is due to an optimization within the lumobj * management which separates them according to their position in the BSP. * * @param flags @see projectLightFlags - * @param subsector Subsector within which the quad wholly resides. + * @param bspLeaf BspLeaf within which the quad wholly resides. * @param blendFactor Multiplied with projection alpha. * @param topLeft Top left coordinates of the surface being projected to. * @param bottomRight Bottom right coordinates of the surface being projected to. @@ -211,7 +211,7 @@ int LO_LumobjsRadiusIterator(subsector_t* subsector, float x, float y, float rad * * @return Projection list identifier if surface is lit else @c 0. */ -uint LO_ProjectToSurface(int flags, subsector_t* subsector, float blendFactor, +uint LO_ProjectToSurface(int flags, BspLeaf* bspLeaf, float blendFactor, vec3_t topLeft, vec3_t bottomRight, vec3_t tangent, vec3_t bitangent, vec3_t normal); /** diff --git a/doomsday/engine/portable/include/r_shadow.h b/doomsday/engine/portable/include/r_shadow.h index 3033b6d5a2..fef6c9d76b 100644 --- a/doomsday/engine/portable/include/r_shadow.h +++ b/doomsday/engine/portable/include/r_shadow.h @@ -56,11 +56,11 @@ float R_ShadowAttenuationFactor(float distance); * Project all mobj shadows affecting the given quad (world space), calculate * coordinates (in texture space) then store into a new list of projections. * - * \assume The coordinates of the given quad must be contained wholly within - * the subsector specified. This is due to an optimization within the mobj + * @assume The coordinates of the given quad must be contained wholly within + * the BSP leaf specified. This is due to an optimization within the mobj * management which separates them according to their position in the BSP. * - * @param subsector Subsector within which the quad wholly resides. + * @param bspLeaf BspLeaf within which the quad wholly resides. * @param blendFactor Multiplied with projection alpha. * @param topLeft Top left coordinates of the surface being projected to. * @param bottomRight Bottom right coordinates of the surface being projected to. @@ -70,7 +70,7 @@ float R_ShadowAttenuationFactor(float distance); * * @return Projection list identifier if surface is lit else @c 0. */ -uint R_ProjectShadowsToSurface(subsector_t* subsector, float blendFactor, +uint R_ProjectShadowsToSurface(BspLeaf* bspLeaf, float blendFactor, vec3_t topLeft, vec3_t bottomRight, vec3_t tangent, vec3_t bitangent, vec3_t normal); /** diff --git a/doomsday/engine/portable/include/r_things.h b/doomsday/engine/portable/include/r_things.h index 8a4f4f62b8..e8d032d11e 100644 --- a/doomsday/engine/portable/include/r_things.h +++ b/doomsday/engine/portable/include/r_things.h @@ -104,7 +104,7 @@ typedef struct rendspriteparams_s { uint vLightListIdx; // Misc - struct subsector_s* subsector; + struct bspleaf_s* bspLeaf; } rendspriteparams_t; /** @name rendFlareFlags */ @@ -164,12 +164,12 @@ typedef struct vispsprite_s { union vispsprite_data_u { struct vispsprite_sprite_s { - subsector_t* subsector; + BspLeaf* bspLeaf; float alpha; boolean isFullBright; } sprite; struct vispsprite_model_s { - subsector_t* subsector; + BspLeaf* bspLeaf; float gzt; // global top for silhouette clipping int flags; // for color translation and shadow draw uint id; @@ -195,7 +195,7 @@ typedef struct vispsprite_s { typedef struct collectaffectinglights_params_s { float center[3]; float* ambientColor; - subsector_t* subsector; + BspLeaf* bspLeaf; boolean starkLight; // World light has a more pronounced effect. } collectaffectinglights_params_t; @@ -236,7 +236,7 @@ void R_ProjectPlayerSprites(void); void R_SortVisSprites(void); vissprite_t* R_NewVisSprite(void); -void R_AddSprites(subsector_t* subsector); +void R_AddSprites(BspLeaf* bspLeaf); /// To be called at the start of the current render frame to clear the vissprite list. void R_ClearVisSprites(void); diff --git a/doomsday/engine/portable/include/r_world.h b/doomsday/engine/portable/include/r_world.h index 8988bde797..d98691eedb 100644 --- a/doomsday/engine/portable/include/r_world.h +++ b/doomsday/engine/portable/include/r_world.h @@ -31,7 +31,7 @@ #include "r_data.h" -// Used for vertex sector owners, side line owners and reverb subsectors. +// Used for vertex sector owners, side line owners and reverb BSP leafs. typedef struct ownernode_s { void* data; struct ownernode_s* next; @@ -62,7 +62,7 @@ extern skyfix_t skyFix[2]; // [floor, ceiling] void R_SetupMap(int mode, int flags); /** - * Polygonizes all subsectors in the map. + * Polygonizes all BSP leafs in the map. */ void R_PolygonizeMap(GameMap* map); diff --git a/doomsday/engine/portable/include/rend_clip.h b/doomsday/engine/portable/include/rend_clip.h index 9f885143e2..c301098566 100644 --- a/doomsday/engine/portable/include/rend_clip.h +++ b/doomsday/engine/portable/include/rend_clip.h @@ -53,7 +53,7 @@ int C_CheckViewRelSeg(float x1, float y1, float x2, float y2); // Returns 1 if the specified angle is visible. int C_IsAngleVisible(binangle_t bang); -// Returns 1 if the subsector might be visible. -int C_CheckSubsector(subsector_t* subsector); +// Returns 1 if the BSP leaf might be visible. +int C_CheckBspLeaf(BspLeaf* bspLeaf); #endif diff --git a/doomsday/engine/portable/include/rend_fakeradio.h b/doomsday/engine/portable/include/rend_fakeradio.h index 1ee6b6ac8b..d1a2871ab5 100644 --- a/doomsday/engine/portable/include/rend_fakeradio.h +++ b/doomsday/engine/portable/include/rend_fakeradio.h @@ -54,9 +54,9 @@ void Rend_RadioSegSection(const rvertex_t* rvertices, const walldiv_t* divs, const rendsegradio_params_t* params); /** - * Render FakeRadio for the given subsector. + * Render FakeRadio for the given BSP leaf. */ -void Rend_RadioSubsectorEdges(subsector_t* subsector); +void Rend_RadioBspLeafEdges(BspLeaf* bspLeaf); /** * Render the shadow poly vertices, for debug. diff --git a/doomsday/engine/portable/src/blockmapvisual.c b/doomsday/engine/portable/src/blockmapvisual.c index 31e40a22c5..d23403a005 100644 --- a/doomsday/engine/portable/src/blockmapvisual.c +++ b/doomsday/engine/portable/src/blockmapvisual.c @@ -32,7 +32,7 @@ #include "de_misc.h" #include "de_ui.h" -byte bmapShowDebug = 0; // 1 = mobjs, 2 = linedefs, 3 = subsectors, 4 = polyobjs. +byte bmapShowDebug = 0; // 1 = mobjs, 2 = linedefs, 3 = BSP leafs, 4 = polyobjs. float bmapDebugSize = 1.5f; #if 0 @@ -56,7 +56,7 @@ static int rendLineDef(linedef_t* line, void* paramaters) return false; // Continue iteration. } -static int rendSubsector(subsector_t* ssec, void* paramaters) +static int rendBspLeaf(BspLeaf* bspLeaf, void* paramaters) { const float scale = MAX_OF(bmapDebugSize, 1); const float width = (theWindow->geometry.size.width / 16) / scale; @@ -64,7 +64,7 @@ static int rendSubsector(subsector_t* ssec, void* paramaters) HEdge** hedgeIter, *hedge; vec2_t start, end; - for(hedgeIter = ssec->hedges; *hedgeIter; hedgeIter++) + for(hedgeIter = bspLeaf->hedges; *hedgeIter; hedgeIter++) { hedge = *hedgeIter; @@ -110,8 +110,8 @@ static int rendSubsector(subsector_t* ssec, void* paramaters) } // Draw the bounding box. - V2_Set(start, ssec->aaBox.minX, ssec->aaBox.minY); - V2_Set(end, ssec->aaBox.maxX, ssec->aaBox.maxY); + V2_Set(start, bspLeaf->aaBox.minX, bspLeaf->aaBox.minY); + V2_Set(end, bspLeaf->aaBox.maxX, bspLeaf->aaBox.maxY); glBegin(GL_LINES); glVertex2f(start[VX], start[VY]); @@ -183,19 +183,19 @@ int rendCellMobjs(void* cellPtr, void* paramaters) return false; // Continue iteration. } -int rendCellSubsectors(void* cellPtr, void* paramaters) +int rendCellBspLeafs(void* cellPtr, void* paramaters) { BlockmapCell* cell = (BlockmapCell*)cellPtr; if(cell && cell->ringNodes) { - bmapsubsectoriterateparams_t bsiParams; + bmapbspleafiterateparams_t bsiParams; bsiParams.localValidCount = validCount; - bsiParams.func = rendSubsector; + bsiParams.func = rendBspLeaf; bsiParams.param = paramaters; bsiParams.sector = NULL; bsiParams.box = NULL; - BlockmapCell_IterateObjects(cell, blockmapCellSubsectorsIterator, (void*)&bsiParams); + BlockmapCell_IterateObjects(cell, blockmapCellBspLeafsIterator, (void*)&bsiParams); } return false; // Continue iteration. } @@ -374,7 +374,7 @@ static void drawPolyobjCellInfoBox(Blockmap* blockmap, const Point2Raw* origin, drawCellInfo(origin, info); } -static void drawSubsectorCellInfoBox(Blockmap* blockmap, const Point2Raw* origin, uint coords[2]) +static void drawBspLeafCellInfoBox(Blockmap* blockmap, const Point2Raw* origin, uint coords[2]) { uint count = 0; char info[160]; @@ -382,7 +382,7 @@ static void drawSubsectorCellInfoBox(Blockmap* blockmap, const Point2Raw* origin validCount++; Blockmap_IterateCellObjects(blockmap, coords, countCellObject, (void*)&count); - dd_snprintf(info, 160, "Cell:[%u,%u] Subsectors:#%u", coords[VX], coords[VY], count); + dd_snprintf(info, 160, "Cell:[%u,%u] BspLeafs:#%u", coords[VX], coords[VY], count); drawCellInfo(origin, info); } @@ -604,12 +604,12 @@ void Rend_BlockmapDebug(void) cellInfoDrawer = drawLineDefCellInfoBox; break; - case 3: // Subsectors. - if(!map->subsectorBlockmap) return; + case 3: // BspLeafs. + if(!map->bspLeafBlockmap) return; - blockmap = map->subsectorBlockmap; - cellDrawer = rendCellSubsectors; - cellInfoDrawer = drawSubsectorCellInfoBox; + blockmap = map->bspLeafBlockmap; + cellDrawer = rendCellBspLeafs; + cellInfoDrawer = drawBspLeafCellInfoBox; break; case 4: // PolyobjLinks. diff --git a/doomsday/engine/portable/src/bsp_main.c b/doomsday/engine/portable/src/bsp_main.c index 854492a87a..fde3b5435e 100644 --- a/doomsday/engine/portable/src/bsp_main.c +++ b/doomsday/engine/portable/src/bsp_main.c @@ -319,9 +319,9 @@ boolean BSP_Build(GameMap* map, vertex_t*** vertexes, uint* numVertexes) else rHeight = lHeight = 0; - VERBOSE( Con_Printf("BSP built: %d Nodes, %d Subsectors, %d HEdges, %d Vertexes\n" + VERBOSE( Con_Printf("BSP built: %d Nodes, %d BspLeafs, %d HEdges, %d Vertexes\n" " Balance %+ld (l%ld - r%ld).\n", - map->numBspNodes, map->numSubsectors, map->numHEdges, map->numVertexes, + map->numBspNodes, map->numBspLeafs, map->numHEdges, map->numVertexes, lHeight - rHeight, lHeight, rHeight) ) } diff --git a/doomsday/engine/portable/src/bsp_map.c b/doomsday/engine/portable/src/bsp_map.c index 2344ad8c72..7b33bcee16 100644 --- a/doomsday/engine/portable/src/bsp_map.c +++ b/doomsday/engine/portable/src/bsp_map.c @@ -129,7 +129,7 @@ static boolean hEdgeCollector(binarytree_t* tree, void* data) else { // Count mode. if(hEdge->index == -1) - Con_Error("HEdge %p never reached a subsector!", hEdge); + Con_Error("HEdge %p never reached a BspLeaf!", hEdge); params->curIdx++; } @@ -256,7 +256,7 @@ static void buildHEdgesFromBSPHEdges(GameMap* dest, binarytree_t* rootNode) M_Free(index); } -static void hardenSubsectorHEdgeList(GameMap* dest, subsector_t* ssec, +static void hardenBspLeafHEdgeList(GameMap* dest, BspLeaf* bspLeaf, bsp_hedge_t* list, size_t hedgeCount) { size_t i; @@ -270,12 +270,12 @@ static void hardenSubsectorHEdgeList(GameMap* dest, subsector_t* ssec, hedges[hedgeCount] = NULL; // Terminate. if(i != hedgeCount) - Con_Error("hardenSubsectorHEdgeList: Miscounted?"); + Con_Error("hardenBspLeafHEdgeList: Miscounted?"); - ssec->hedges = hedges; + bspLeaf->hedges = hedges; } -static void hardenLeaf(GameMap* map, subsector_t* dest, +static void hardenLeaf(GameMap* map, BspLeaf* dest, const bspleafdata_t* src) { HEdge** segp; @@ -290,14 +290,14 @@ static void hardenLeaf(GameMap* map, subsector_t* dest, hEdgeCount++; } while((hEdge = hEdge->next) != NULL); - dest->header.type = DMU_SUBSECTOR; + dest->header.type = DMU_BSPLEAF; dest->hedgeCount = (uint) hEdgeCount; dest->shadows = NULL; dest->vertices = NULL; - hardenSubsectorHEdgeList(map, dest, src->hEdges, hEdgeCount); + hardenBspLeafHEdgeList(map, dest, src->hEdges, hEdgeCount); - // Determine which sector this subsector belongs to. + // Determine which sector this BSP leaf belongs to. segp = dest->hedges; found = false; while(*segp) @@ -309,19 +309,19 @@ static void hardenLeaf(GameMap* map, subsector_t* dest, dest->sector = side->sector; found = true; } - hedge->subsector = dest; + hedge->bspLeaf = dest; segp++; } if(!dest->sector) { - Con_Message("hardenLeaf: Warning orphan subsector %p.\n", dest); + Con_Message("hardenLeaf: Warning orphan BSP leaf %p.\n", dest); } } typedef struct { - GameMap* dest; - uint subsectorCurIndex; + GameMap* dest; + uint leafCurIndex; uint nodeCurIndex; } hardenbspparams_t; @@ -330,7 +330,7 @@ static boolean C_DECL hardenNode(binarytree_t* tree, void* data) binarytree_t* right, *left; bspnodedata_t* nodeData; hardenbspparams_t* params; - BspNode* node; + BspNode* node; if(BinaryTree_IsLeaf(tree)) return true; // Continue iteration. @@ -362,10 +362,10 @@ static boolean C_DECL hardenNode(binarytree_t* tree, void* data) if(BinaryTree_IsLeaf(right)) { bspleafdata_t* leaf = (bspleafdata_t*) BinaryTree_GetData(right); - uint idx = params->subsectorCurIndex++; + uint idx = params->leafCurIndex++; - node->children[RIGHT] = idx | NF_SUBSECTOR; - hardenLeaf(params->dest, ¶ms->dest->subsectors[idx], leaf); + node->children[RIGHT] = idx | NF_LEAF; + hardenLeaf(params->dest, ¶ms->dest->bspLeafs[idx], leaf); } else { @@ -381,10 +381,10 @@ static boolean C_DECL hardenNode(binarytree_t* tree, void* data) if(BinaryTree_IsLeaf(left)) { bspleafdata_t* leaf = (bspleafdata_t*) BinaryTree_GetData(left); - uint idx = params->subsectorCurIndex++; + uint idx = params->leafCurIndex++; - node->children[LEFT] = idx | NF_SUBSECTOR; - hardenLeaf(params->dest, ¶ms->dest->subsectors[idx], leaf); + node->children[LEFT] = idx | NF_LEAF; + hardenLeaf(params->dest, ¶ms->dest->bspLeafs[idx], leaf); } else { @@ -422,22 +422,22 @@ static void hardenBSP(GameMap* dest, binarytree_t* rootNode) else dest->bspNodes = 0; - dest->numSubsectors = 0; - BinaryTree_PostOrder(rootNode, countSSec, &dest->numSubsectors); - dest->subsectors = Z_Calloc(dest->numSubsectors * sizeof(subsector_t), PU_MAPSTATIC, 0); + dest->numBspLeafs = 0; + BinaryTree_PostOrder(rootNode, countSSec, &dest->numBspLeafs); + dest->bspLeafs = Z_Calloc(dest->numBspLeafs * sizeof(BspLeaf), PU_MAPSTATIC, 0); if(!rootNode) return; if(BinaryTree_IsLeaf(rootNode)) { - hardenLeaf(dest, &dest->subsectors[0], (bspleafdata_t*) BinaryTree_GetData(rootNode)); + hardenLeaf(dest, &dest->bspLeafs[0], (bspleafdata_t*) BinaryTree_GetData(rootNode)); return; } { hardenbspparams_t p; p.dest = dest; - p.subsectorCurIndex = 0; + p.leafCurIndex = 0; p.nodeCurIndex = 0; BinaryTree_PostOrder(rootNode, hardenNode, &p); } diff --git a/doomsday/engine/portable/src/bsp_node.c b/doomsday/engine/portable/src/bsp_node.c index b0561a3754..37abee56ab 100644 --- a/doomsday/engine/portable/src/bsp_node.c +++ b/doomsday/engine/portable/src/bsp_node.c @@ -39,9 +39,9 @@ * does the least splitting and has the least difference in numbers of * half-edges on either side. * - * If the ones on the left side make a Subsector, then create another Subsector + * If the ones on the left side make a BspLeaf, then create another BspLeaf * else put the half-edges into the left list. - * If the ones on the right side make a Subsector, then create another Subsector + * If the ones on the right side make a BspLeaf, then create another BspLeaf * else put the half-edges into the right list. * * Rewritten by Andrew Apted (-AJA-), 1999-2000. @@ -73,7 +73,7 @@ // PRIVATE DATA DEFINITIONS ------------------------------------------------ -// Used when sorting subsector hEdges by angle around midpoint. +// Used when sorting BSP leaf half-edges by angle around midpoint. static size_t hEdgeSortBufSize; static bsp_hedge_t **hEdgeSortBuf; @@ -452,10 +452,10 @@ static boolean C_DECL clockwiseLeaf(binarytree_t *tree, void *data) } /** - * Traverse the BSP tree and put all the half-edges in each subsector into + * Traverse the BSP tree and put all the half-edges in each BSP leaf into * clockwise order, and renumber their indices. * - * \important This cannot be done during BuildNodes() since splitting a + * @important This cannot be done during BuildNodes() since splitting a * half-edge with a twin may insert another half-edge into that twin's list, * usually in the wrong place order-wise. */ @@ -488,7 +488,7 @@ static void createBSPLeafWorker(bspleafdata_t *leaf, superblock_t *block) // Un-link first half-edge from the block. block->hEdges = cur->next; - // Link it into head of the subsector's list. + // Link it into head of the leaf's list. cur->next = leaf->hEdges; cur->block = NULL; @@ -505,7 +505,7 @@ static void createBSPLeafWorker(bspleafdata_t *leaf, superblock_t *block) createBSPLeafWorker(leaf, a); if(a->realNum + a->miniNum > 0) - Con_Error("createSubsectorWorker: child %d not empty!", num); + Con_Error("createBspLeafWorker: child %d not empty!", num); BSP_SuperBlockDestroy(a); block->subs[num] = NULL; @@ -567,7 +567,7 @@ static bspleafdata_t *createBSPLeaf(superblock_t *hEdgeList) /** * Takes the half-edge list and determines if it is convex, possibly - * converting it into a subsector. Otherwise, the list is divided into two + * converting it into a BSP leaf. Otherwise, the list is divided into two * halves and recursion will continue on the new sub list. * * @param hEdgeList Ptr to the list of half edges at the current node. @@ -685,7 +685,7 @@ Con_Message("BuildNodes: Partition %p (%1.0f,%1.0f) -> (%1.0f,%1.0f).\n", // "second" SideDef, then create a flipped Seg. // 2 - Call CreateNodes with the current list of Segs. The list of Segs is // the only argument to CreateNodes. -// 3 - Save the Nodes, Segs and Subsectors to disk. Start with the leaves of +// 3 - Save the Nodes, Segs and BspLeafs to disk. Start with the leaves of // the Nodes tree and continue up to the root (last Node). // // CreateNodes does the following: @@ -696,11 +696,11 @@ Con_Message("BuildNodes: Partition %p (%1.0f,%1.0f) -> (%1.0f,%1.0f).\n", // 3 - If the first list (segs1) contains references to more than one // Sector or if the angle between two adjacent Segs is greater than // 180 degrees, then call CreateNodes with this (smaller) list. -// Else, create a Subsector with all these Segs. +// Else, create a BspLeaf with all these Segs. // 4 - Do the same for the second list (segs2). // 5 - Return the new node (its two children are already OK). // -// Each time CreateSubsector is called, the Segs are put in a global list. +// Each time CreateBspLeaf is called, the Segs are put in a global list. // When there is no more Seg in CreateNodes' list, then they are all in the // global list and ready to be saved to disk. // diff --git a/doomsday/engine/portable/src/cl_player.c b/doomsday/engine/portable/src/cl_player.c index ae725f3a17..11c5124c46 100644 --- a/doomsday/engine/portable/src/cl_player.c +++ b/doomsday/engine/portable/src/cl_player.c @@ -144,7 +144,7 @@ void ClPlayer_UpdatePos(int plrNum) // The player's client mobj is not linked to any lists, so position // can be updated without any hassles. memcpy(remoteClientMobj->pos, localMobj->pos, sizeof(localMobj->pos)); - P_MobjLink(remoteClientMobj, 0); // Update subsector pointer. + P_MobjLink(remoteClientMobj, 0); // Update bspLeaf pointer. remoteClientMobj->floorZ = localMobj->floorZ; remoteClientMobj->ceilingZ = localMobj->ceilingZ; remoteClientMobj->mom[MX] = localMobj->mom[MX]; @@ -356,9 +356,9 @@ void ClPlayer_MoveLocal(float dx, float dy, float z, boolean onground) P_MobjLink(mo, DDLINK_SECTOR | DDLINK_BLOCKMAP); } - mo->subsector = P_SubsectorAtPointXY(mo->pos[VX], mo->pos[VY]); - mo->floorZ = mo->subsector->sector->SP_floorheight; - mo->ceilingZ = mo->subsector->sector->SP_ceilheight; + mo->bspLeaf = P_BspLeafAtPointXY(mo->pos[VX], mo->pos[VY]); + mo->floorZ = mo->bspLeaf->sector->SP_floorheight; + mo->ceilingZ = mo->bspLeaf->sector->SP_ceilheight; if(onground) { diff --git a/doomsday/engine/portable/src/dam_file.c b/doomsday/engine/portable/src/dam_file.c index ef7593e1ad..dc0d88ecc1 100644 --- a/doomsday/engine/portable/src/dam_file.c +++ b/doomsday/engine/portable/src/dam_file.c @@ -55,9 +55,9 @@ typedef enum damsegment_e { DAMSEG_LINES, DAMSEG_SIDES, DAMSEG_SECTORS, - DAMSEG_SUBSECTORS, + DAMSEG_BSPLEAFS, DAMSEG_HEDGES, - DAMSEG_NODES, + DAMSEG_BSPNODES, DAMSEG_BLOCKMAP, DAMSEG_REJECT } damsegment_t; @@ -479,15 +479,15 @@ static void writeSector(const GameMap *map, uint idx) for(i = 0; i < s->lineDefCount; ++i) writeLong((s->lineDefs[i] - map->lineDefs) + 1); - // Subsector list. - writeLong((long) s->subsectorCount); - for(i = 0; i < s->subsectorCount; ++i) - writeLong((s->subsectors[i] - map->subsectors) + 1); + // BspLeaf list. + writeLong((long) s->bspLeafCount); + for(i = 0; i < s->bspLeafCount; ++i) + writeLong((s->bspLeafs[i] - map->bspLeafs) + 1); - // Reverb subsector attributors. - writeLong((long) s->numReverbSSecAttributors); - for(i = 0; i < s->numReverbSSecAttributors; ++i) - writeLong((s->reverbSubsectors[i] - map->subsectors) + 1); + // Reverb BSP leaf attributors. + writeLong((long) s->numReverbBspLeafAttributors); + for(i = 0; i < s->numReverbBspLeafAttributors; ++i) + writeLong((s->reverbBspLeafs[i] - map->bspLeafs) + 1); } static void readSector(const GameMap *map, uint idx) @@ -563,21 +563,21 @@ static void readSector(const GameMap *map, uint idx) s->lineDefs[i] = &map->lineDefs[(unsigned) readLong() - 1]; s->lineDefs[i] = NULL; // Terminate. - // Subsector list. - s->subsectorCount = (uint) readLong(); - s->subsectors = - Z_Malloc(sizeof(subsector_t*) * (s->subsectorCount + 1), PU_MAP, 0); - for(i = 0; i < s->subsectorCount; ++i) - s->subsectors[i] = &map->subsectors[(unsigned) readLong() - 1]; - s->subsectors[i] = NULL; // Terminate. - - // Reverb subsector attributors. - s->numReverbSSecAttributors = (uint) readLong(); - s->reverbSubsectors = - Z_Malloc(sizeof(subsector_t*) * (s->numReverbSSecAttributors + 1), PU_MAP, 0); - for(i = 0; i < s->numReverbSSecAttributors; ++i) - s->reverbSubsectors[i] = &map->subsectors[(unsigned) readLong() - 1]; - s->reverbSubsectors[i] = NULL; // Terminate. + // BspLeaf list. + s->bspLeafCount = (uint) readLong(); + s->bspLeafs = + Z_Malloc(sizeof(BspLeaf*) * (s->bspLeafCount + 1), PU_MAP, 0); + for(i = 0; i < s->bspLeafCount; ++i) + s->bspLeafs[i] = &map->bspLeafs[(unsigned) readLong() - 1]; + s->bspLeafs[i] = NULL; // Terminate. + + // Reverb BSP leaf attributors. + s->numReverbBspLeafAttributors = (uint) readLong(); + s->reverbBspLeafs = + Z_Malloc(sizeof(BspLeaf*) * (s->numReverbBspLeafAttributors + 1), PU_MAP, 0); + for(i = 0; i < s->numReverbBspLeafAttributors; ++i) + s->reverbBspLeafs[i] = &map->bspLeafs[(unsigned) readLong() - 1]; + s->reverbBspLeafs[i] = NULL; // Terminate. } static void archiveSectors(GameMap *map, boolean write) @@ -608,10 +608,10 @@ static void archiveSectors(GameMap *map, boolean write) assertSegment(DAMSEG_END); } -static void writeSubsector(const GameMap *map, uint idx) +static void writeBspLeaf(const GameMap *map, uint idx) { uint i; - subsector_t *s = &map->subsectors[idx]; + BspLeaf *s = &map->bspLeafs[idx]; writeLong((long) s->flags); writeFloat(s->aaBox.minX); @@ -623,21 +623,21 @@ static void writeSubsector(const GameMap *map, uint idx) writeLong(s->sector? ((s->sector - map->sectors) + 1) : 0); writeLong(s->polyObj? (s->polyObj->idx + 1) : 0); - // Subsector reverb. + // BspLeaf reverb. for(i = 0; i < NUM_REVERB_DATA; ++i) writeLong((long) s->reverb[i]); - // Subsector hedges list. + // BspLeaf hedges list. writeLong((long) s->hedgeCount); for(i = 0; i < s->hedgeCount; ++i) writeLong((s->hedges[i] - map->hedges) + 1); } -static void readSubsector(const GameMap *map, uint idx) +static void readBspLeaf(const GameMap *map, uint idx) { uint i; long obIdx; - subsector_t *s = &map->subsectors[idx]; + BspLeaf *s = &map->bspLeafs[idx]; s->flags = (int) readLong(); s->aaBox.minX = readFloat(); @@ -651,11 +651,11 @@ static void readSubsector(const GameMap *map, uint idx) obIdx = readLong(); s->polyObj = (obIdx == 0? NULL : map->polyObjs[(unsigned) obIdx - 1]); - // Subsector reverb. + // BspLeaf reverb. for(i = 0; i < NUM_REVERB_DATA; ++i) s->reverb[i] = (uint) readLong(); - // Subsector hedges list. + // BspLeaf hedges list. s->hedgeCount = (uint) readLong(); s->hedges = Z_Malloc(sizeof(HEdge*) * (s->hedgeCount + 1), PU_MAP, 0); for(i = 0; i < s->hedgeCount; ++i) @@ -663,26 +663,26 @@ static void readSubsector(const GameMap *map, uint idx) s->hedges[i] = NULL; // Terminate. } -static void archiveSubsectors(GameMap *map, boolean write) +static void archiveBspLeafs(GameMap *map, boolean write) { uint i; if(write) - beginSegment(DAMSEG_SUBSECTORS); + beginSegment(DAMSEG_BSPLEAFS); else - assertSegment(DAMSEG_SUBSECTORS); + assertSegment(DAMSEG_BSPLEAFS); if(write) { - writeLong(map->numSubsectors); - for(i = 0; i < map->numSubsectors; ++i) - writeSubsector(map, i); + writeLong(map->numBspLeafs); + for(i = 0; i < map->numBspLeafs; ++i) + writeBspLeaf(map, i); } else { - map->numSubsectors = readLong(); - for(i = 0; i < map->numSubsectors; ++i) - readSubsector(map, i); + map->numBspLeafs = readLong(); + for(i = 0; i < map->numBspLeafs; ++i) + readBspLeaf(map, i); } if(write) @@ -702,7 +702,7 @@ static void writeSeg(const GameMap *map, uint idx) writeLong(s->lineDef? ((s->lineDef - map->lineDefs) + 1) : 0); writeLong(s->sec[FRONT]? ((s->sec[FRONT] - map->sectors) + 1) : 0); writeLong(s->sec[BACK]? ((s->sec[BACK] - map->sectors) + 1) : 0); - writeLong(s->subsector? ((s->subsector - map->subsectors) + 1) : 0); + writeLong(s->bspLeaf? ((s->bspLeaf - map->bspLeafs) + 1) : 0); writeLong(s->twin? ((s->twin - map->hedges) + 1) : 0); writeLong((long) s->angle); writeByte(s->side); @@ -725,7 +725,7 @@ static void readSeg(const GameMap *map, uint idx) obIdx = readLong(); s->sec[BACK] = (obIdx == 0? NULL : &map->sectors[(unsigned) obIdx - 1]); obIdx = readLong(); - s->subsector = (obIdx == 0? NULL : &map->subsectors[(unsigned) obIdx - 1]); + s->bspLeaf = (obIdx == 0? NULL : &map->bspLeafs[(unsigned) obIdx - 1]); obIdx = readLong(); s->twin = (obIdx == 0? NULL : &map->hedges[(unsigned) obIdx - 1]); s->angle = (angle_t) readLong(); @@ -806,9 +806,9 @@ static void archiveNodes(GameMap *map, boolean write) uint i; if(write) - beginSegment(DAMSEG_NODES); + beginSegment(DAMSEG_BSPNODES); else - assertSegment(DAMSEG_NODES); + assertSegment(DAMSEG_BSPNODES); if(write) { @@ -1015,7 +1015,7 @@ static void archiveMap(GameMap *map, boolean write) archiveLines(map, write); // Must follow vertexes (lineowner nodes). archiveSides(map, write); archiveSectors(map, write); - archiveSubsectors(map, write); + archiveBspLeafs(map, write); archiveSegs(map, write); archiveNodes(map, write); archiveBlockmap(map, write); diff --git a/doomsday/engine/portable/src/dam_main.c b/doomsday/engine/portable/src/dam_main.c index dc17083c93..a8b17fd30f 100644 --- a/doomsday/engine/portable/src/dam_main.c +++ b/doomsday/engine/portable/src/dam_main.c @@ -557,13 +557,13 @@ boolean DAM_AttemptMapLoad(const Uri* uri) Rend_DecorInit(); - // Init blockmap for searching subsectors. + // Init blockmap for searching BSP leafs. V2_Set(min, map->bBox[BOXLEFT], map->bBox[BOXBOTTOM]); V2_Set(max, map->bBox[BOXRIGHT], map->bBox[BOXTOP]); - GameMap_InitSubsectorBlockmap(map, min, max); - for(i = 0; i < map->numSubsectors; ++i) + GameMap_InitBspLeafBlockmap(map, min, max); + for(i = 0; i < map->numBspLeafs; ++i) { - GameMap_LinkSubsectorInBlockmap(map, map->subsectors + i); + GameMap_LinkBspLeafInBlockmap(map, map->bspLeafs + i); } map->uri = Uri_NewCopy(dam->uri); diff --git a/doomsday/engine/portable/src/dd_main.c b/doomsday/engine/portable/src/dd_main.c index c33af870f8..d35d2dea2f 100644 --- a/doomsday/engine/portable/src/dd_main.c +++ b/doomsday/engine/portable/src/dd_main.c @@ -2130,8 +2130,8 @@ void* DD_GetVariable(int ddvalue) valueU = theMap? GameMap_HEdgeCount(theMap) : 0; return &valueU; - case DD_SUBSECTOR_COUNT: - valueU = theMap? GameMap_SubsectorCount(theMap) : 0; + case DD_BSPLEAF_COUNT: + valueU = theMap? GameMap_BspLeafCount(theMap) : 0; return &valueU; case DD_BSPNODE_COUNT: diff --git a/doomsday/engine/portable/src/edit_bias.c b/doomsday/engine/portable/src/edit_bias.c index 142203fbfc..ab4289d9ce 100644 --- a/doomsday/engine/portable/src/edit_bias.c +++ b/doomsday/engine/portable/src/edit_bias.c @@ -695,7 +695,7 @@ static void SBE_DrawLevelGauge(const Point2Raw* origin, int height) int off, secY, p, minY = 0, maxY = 0; Point2Raw labelOrigin; - subsector_t* ssec; + BspLeaf* bspLeaf; sector_t* sector; source_t* src; char buf[80]; @@ -706,10 +706,10 @@ static void SBE_DrawLevelGauge(const Point2Raw* origin, int height) else src = SBE_GetNearest(); - ssec = P_SubsectorAtPointXY(src->pos[VX], src->pos[VY]); - if(!ssec) return; + bspLeaf = P_BspLeafAtPointXY(src->pos[VX], src->pos[VY]); + if(!bspLeaf) return; - sector = ssec->sector; + sector = bspLeaf->sector; if(lastSector != sector) { diff --git a/doomsday/engine/portable/src/edit_map.c b/doomsday/engine/portable/src/edit_map.c index 51b60e0c7c..3920f142f8 100644 --- a/doomsday/engine/portable/src/edit_map.c +++ b/doomsday/engine/portable/src/edit_map.c @@ -604,7 +604,7 @@ boolean MPE_Begin(const char* mapUri) return true; } -static void hardenSectorSSecList(GameMap* map, uint secIDX) +static void hardenSectorBspLeafList(GameMap* map, uint secIDX) { assert(map && secIDX < map->numSectors); { @@ -612,43 +612,43 @@ static void hardenSectorSSecList(GameMap* map, uint secIDX) uint i, n, count; count = 0; - for(i = 0; i < map->numSubsectors; ++i) + for(i = 0; i < map->numBspLeafs; ++i) { - subsector_t *ssec = &map->subsectors[i]; - if(ssec->sector == sec) + BspLeaf *bspLeaf = &map->bspLeafs[i]; + if(bspLeaf->sector == sec) ++count; } if(0 == count) return; - sec->subsectors = Z_Malloc((count + 1) * sizeof(subsector_t*), PU_MAPSTATIC, NULL); + sec->bspLeafs = Z_Malloc((count + 1) * sizeof(BspLeaf*), PU_MAPSTATIC, NULL); n = 0; - for(i = 0; i < map->numSubsectors; ++i) + for(i = 0; i < map->numBspLeafs; ++i) { - subsector_t* ssec = &map->subsectors[i]; - if(ssec->sector == sec) + BspLeaf* bspLeaf = &map->bspLeafs[i]; + if(bspLeaf->sector == sec) { - ssec->inSectorID = n; - sec->subsectors[n++] = ssec; + bspLeaf->inSectorID = n; + sec->bspLeafs[n++] = bspLeaf; } } - sec->subsectors[n] = NULL; // Terminate. - sec->subsectorCount = count; + sec->bspLeafs[n] = NULL; // Terminate. + sec->bspLeafCount = count; } } /** - * Build subsector tables for all sectors. + * Build BspLeaf tables for all sectors. */ -static void buildSectorSSecLists(GameMap *map) +static void buildSectorBspLeafLists(GameMap *map) { - VERBOSE( Con_Message(" Build subsector tables...\n") ) + VERBOSE( Con_Message(" Build BSP leaf tables...\n") ) { uint i; for(i = 0; i < map->numSectors; ++i) { - hardenSectorSSecList(map, i); + hardenSectorBspLeafList(map, i); }} } @@ -943,7 +943,7 @@ static void updateMapBounds(GameMap* map) } } -static void updateSSecMidPoint(subsector_t *sub) +static void updateSSecMidPoint(BspLeaf *sub) { HEdge **ptr; fvertex_t *vtx; @@ -980,15 +980,15 @@ static void updateSSecMidPoint(subsector_t *sub) sub->worldGridOffset[VY] = fmod(sub->aaBox.maxY, 64); } -static void prepareSubsectors(GameMap* map) +static void prepareBspLeafs(GameMap* map) { uint i; - for(i = 0; i < map->numSubsectors; ++i) + for(i = 0; i < map->numBspLeafs; ++i) { - subsector_t* ssec = &map->subsectors[i]; + BspLeaf* bspLeaf = &map->bspLeafs[i]; - updateSSecMidPoint(ssec); + updateSSecMidPoint(bspLeaf); } } @@ -1425,7 +1425,7 @@ static void hardenPolyobjs(GameMap* dest, editmap_t* src) dy = line->L_v2pos[VY] - line->L_v1pos[VY]; hedge->length = P_AccurateDistance(dx, dy); hedge->twin = NULL; - hedge->subsector = NULL; + hedge->bspLeaf = NULL; hedge->HE_frontsector = line->L_frontsector; hedge->HE_backsector = NULL; hedge->flags |= HEDGEF_POLYOBJ; @@ -1886,17 +1886,17 @@ boolean MPE_End(void) // Polygonize. R_PolygonizeMap(gamemap); - buildSectorSSecLists(gamemap); + buildSectorBspLeafLists(gamemap); // Announce any issues detected with the map. MPE_PrintMapErrors(); - // Map must be polygonized and sector->subsectors must be built before + // Map must be polygonized and sector->bspLeafs must be built before // this is called! hardenPlanes(gamemap, map); // Destroy the rest of editable map, we are finished with it. - // \note Only the vertexes should be left anyway. + /// @note Only the vertexes should be left anyway. destroyMap(); if(!builtOK) @@ -1912,7 +1912,7 @@ boolean MPE_End(void) finishSectors(gamemap); updateMapBounds(gamemap); S_DetermineSubsecsAffectingSectorReverb(gamemap); - prepareSubsectors(gamemap); + prepareBspLeafs(gamemap); P_FreeBadTexList(); MPE_FreeUnclosedSectorList(); diff --git a/doomsday/engine/portable/src/gamemap.c b/doomsday/engine/portable/src/gamemap.c index 4572234242..499c8408cd 100644 --- a/doomsday/engine/portable/src/gamemap.c +++ b/doomsday/engine/portable/src/gamemap.c @@ -186,18 +186,18 @@ sector_t* GameMap_Sector(GameMap* map, uint idx) return &map->sectors[idx]; } -int GameMap_SubsectorIndex(GameMap* map, subsector_t* ssec) +int GameMap_BspLeafIndex(GameMap* map, BspLeaf* bspLeaf) { assert(map); - if(!ssec || !(ssec >= map->subsectors && ssec <= &map->subsectors[map->numSubsectors])) return -1; - return ssec - map->subsectors; + if(!bspLeaf || !(bspLeaf >= map->bspLeafs && bspLeaf <= &map->bspLeafs[map->numBspLeafs])) return -1; + return bspLeaf - map->bspLeafs; } -subsector_t* GameMap_Subsector(GameMap* map, uint idx) +BspLeaf* GameMap_BspLeaf(GameMap* map, uint idx) { assert(map); - if(idx >= map->numSubsectors) return NULL; - return &map->subsectors[idx]; + if(idx >= map->numBspLeafs) return NULL; + return &map->bspLeafs[idx]; } int GameMap_HEdgeIndex(GameMap* map, HEdge* hedge) @@ -252,10 +252,10 @@ uint GameMap_SectorCount(GameMap* map) return map->numSectors; } -uint GameMap_SubsectorCount(GameMap* map) +uint GameMap_BspLeafCount(GameMap* map) { assert(map); - return map->numSubsectors; + return map->numBspLeafs; } uint GameMap_HEdgeCount(GameMap* map) @@ -317,8 +317,8 @@ polyobj_t* GameMap_PolyobjByOrigin(GameMap* map, void* ddMobjBase) static void initPolyobj(polyobj_t* po) { linedef_t** lineIter; - subsector_t* ssec; - vec2_t avg; // < Used to find a polyobj's center, and hence subsector. + BspLeaf* bspLeaf; + vec2_t avg; /// < Used to find a polyobj's center, and hence BSP leaf. if(!po) return; @@ -345,17 +345,17 @@ static void initPolyobj(polyobj_t* po) } V2_Scale(avg, 1.f / po->lineCount); - ssec = P_SubsectorAtPointXY(avg[VX], avg[VY]); - if(ssec) + bspLeaf = P_BspLeafAtPointXY(avg[VX], avg[VY]); + if(bspLeaf) { - if(ssec->polyObj) + if(bspLeaf->polyObj) { - Con_Message("Warning: GameMap::initPolyobj: Multiple polyobjs in a single subsector\n" - " (subsector %ld, sector %ld). Previous polyobj overridden.\n", - (long)GET_SUBSECTOR_IDX(ssec), (long)GET_SECTOR_IDX(ssec->sector)); + Con_Message("Warning: GameMap::initPolyobj: Multiple polyobjs in a single BSP leaf\n" + " (BSP leaf %ld, sector %ld). Previous polyobj overridden.\n", + (long)GET_BSPLEAF_IDX(bspLeaf), (long)GET_SECTOR_IDX(bspLeaf->sector)); } - ssec->polyObj = po; - po->subsector = ssec; + bspLeaf->polyObj = po; + po->bspLeaf = bspLeaf; } Polyobj_UpdateAABox(po); @@ -499,7 +499,7 @@ void GameMap_InitPolyobjBlockmap(GameMap* map, const_pvec2_t min_, const_pvec2_t #undef BLOCKMAP_MARGIN } -void GameMap_InitSubsectorBlockmap(GameMap* map, const_pvec2_t min_, const_pvec2_t max_) +void GameMap_InitBspLeafBlockmap(GameMap* map, const_pvec2_t min_, const_pvec2_t max_) { #define BLOCKMAP_MARGIN 8 // size guardband around map #define CELL_SIZE MAPBLOCKUNITS @@ -514,7 +514,7 @@ void GameMap_InitSubsectorBlockmap(GameMap* map, const_pvec2_t min_, const_pvec2 V2_Set(max, max_[VX] + BLOCKMAP_MARGIN, max_[VY] + BLOCKMAP_MARGIN); - map->subsectorBlockmap = Blockmap_New(min, max, CELL_SIZE, CELL_SIZE); + map->bspLeafBlockmap = Blockmap_New(min, max, CELL_SIZE, CELL_SIZE); #undef CELL_SIZE #undef BLOCKMAP_MARGIN @@ -739,7 +739,7 @@ int GameMap_LineDefIterator(GameMap* map, int (*callback) (linedef_t*, void*), v return false; // Continue iteration. } -void GameMap_LinkSubsectorInBlockmap(GameMap* map, subsector_t* ssec) +void GameMap_LinkBspLeafInBlockmap(GameMap* map, BspLeaf* bspLeaf) { Blockmap* blockmap; GridmapBlock blockCoords; @@ -747,27 +747,27 @@ void GameMap_LinkSubsectorInBlockmap(GameMap* map, subsector_t* ssec) uint x, y; assert(map); - // Do not link NULL subsectors. - if(!ssec) + // Do not link NULL BSP leafs. + if(!bspLeaf) { - DEBUG_Message(("Warning: GameMap::LinkSubsectorInBlockmap: Attempted with NULL subsector argument.\n")); + DEBUG_Message(("Warning: GameMap::LinkBspLeafInBlockmap: Attempted with NULL bspLeaf argument.\n")); return; } - // Subsectors without sectors don't get in. - if(!ssec->sector) return; + // BspLeafs without sectors don't get in. + if(!bspLeaf->sector) return; - blockmap = map->subsectorBlockmap; - aaBox.minX = ssec->aaBox.minX; - aaBox.minY = ssec->aaBox.minY; - aaBox.maxX = ssec->aaBox.maxX; - aaBox.maxY = ssec->aaBox.maxY; + blockmap = map->bspLeafBlockmap; + aaBox.minX = bspLeaf->aaBox.minX; + aaBox.minY = bspLeaf->aaBox.minY; + aaBox.maxX = bspLeaf->aaBox.maxX; + aaBox.maxY = bspLeaf->aaBox.maxY; Blockmap_CellBlockCoords(blockmap, &blockCoords, &aaBox); for(y = blockCoords.minY; y <= blockCoords.maxY; ++y) for(x = blockCoords.minX; x <= blockCoords.maxX; ++x) { - Blockmap_CreateCellAndLinkObjectXY(blockmap, x, y, ssec); + Blockmap_CreateCellAndLinkObjectXY(blockmap, x, y, bspLeaf); } } @@ -775,48 +775,48 @@ typedef struct subseciterparams_s { const AABoxf* box; sector_t* sector; int localValidCount; - int (*func) (subsector_t*, void*); + int (*func) (BspLeaf*, void*); void* param; -} bmapsubsectoriterateparams_t; +} bmapbspleafiterateparams_t; -static int blockmapCellSubsectorsIterator(void* object, void* context) +static int blockmapCellBspLeafsIterator(void* object, void* context) { - subsector_t* ssec = (subsector_t*)object; - bmapsubsectoriterateparams_t* args = (bmapsubsectoriterateparams_t*) context; - if(ssec->validCount != args->localValidCount) + BspLeaf* bspLeaf = (BspLeaf*)object; + bmapbspleafiterateparams_t* args = (bmapbspleafiterateparams_t*) context; + if(bspLeaf->validCount != args->localValidCount) { boolean ok = true; - // This subsector has now been processed for the current iteration. - ssec->validCount = args->localValidCount; + // This BspLeaf has now been processed for the current iteration. + bspLeaf->validCount = args->localValidCount; // Check the sector restriction. - if(args->sector && ssec->sector != args->sector) + if(args->sector && bspLeaf->sector != args->sector) ok = false; // Check the bounds. if(args->box && - (ssec->aaBox.maxX < args->box->minX || - ssec->aaBox.minX > args->box->maxX || - ssec->aaBox.minY > args->box->maxY || - ssec->aaBox.maxY < args->box->minY)) + (bspLeaf->aaBox.maxX < args->box->minX || + bspLeaf->aaBox.minX > args->box->maxX || + bspLeaf->aaBox.minY > args->box->maxY || + bspLeaf->aaBox.maxY < args->box->minY)) ok = false; if(ok) { // Action the callback. - int result = args->func(ssec, args->param); + int result = args->func(bspLeaf, args->param); if(result) return result; // Stop iteration. } } return false; // Continue iteration. } -int GameMap_IterateCellSubsectors(GameMap* map, const uint coords[2], +int GameMap_IterateCellBspLeafs(GameMap* map, const uint coords[2], sector_t* sector, const AABoxf* box, int localValidCount, - int (*callback) (subsector_t*, void*), void* context) + int (*callback) (BspLeaf*, void*), void* context) { - bmapsubsectoriterateparams_t args; + bmapbspleafiterateparams_t args; assert(map); args.localValidCount = localValidCount; @@ -825,15 +825,15 @@ int GameMap_IterateCellSubsectors(GameMap* map, const uint coords[2], args.sector = sector; args.box = box; - return Blockmap_IterateCellObjects(map->subsectorBlockmap, coords, - blockmapCellSubsectorsIterator, (void*)&args); + return Blockmap_IterateCellObjects(map->bspLeafBlockmap, coords, + blockmapCellBspLeafsIterator, (void*)&args); } -int GameMap_IterateCellBlockSubsectors(GameMap* map, const GridmapBlock* blockCoords, +int GameMap_IterateCellBlockBspLeafs(GameMap* map, const GridmapBlock* blockCoords, sector_t* sector, const AABoxf* box, int localValidCount, - int (*callback) (subsector_t*, void*), void* context) + int (*callback) (BspLeaf*, void*), void* context) { - bmapsubsectoriterateparams_t args; + bmapbspleafiterateparams_t args; assert(map); args.localValidCount = localValidCount; @@ -842,12 +842,12 @@ int GameMap_IterateCellBlockSubsectors(GameMap* map, const GridmapBlock* blockCo args.sector = sector; args.box = box; - return Blockmap_IterateCellBlockObjects(map->subsectorBlockmap, blockCoords, - blockmapCellSubsectorsIterator, (void*) &args); + return Blockmap_IterateCellBlockObjects(map->bspLeafBlockmap, blockCoords, + blockmapCellBspLeafsIterator, (void*) &args); } -int GameMap_SubsectorsBoxIterator(GameMap* map, const AABoxf* box, sector_t* sector, - int (*callback) (subsector_t*, void*), void* parameters) +int GameMap_BspLeafsBoxIterator(GameMap* map, const AABoxf* box, sector_t* sector, + int (*callback) (BspLeaf*, void*), void* parameters) { static int localValidCount = 0; GridmapBlock blockCoords; @@ -856,18 +856,18 @@ int GameMap_SubsectorsBoxIterator(GameMap* map, const AABoxf* box, sector_t* sec // This is only used here. localValidCount++; - Blockmap_CellBlockCoords(map->subsectorBlockmap, &blockCoords, box); - return GameMap_IterateCellBlockSubsectors(map, &blockCoords, sector, box, + Blockmap_CellBlockCoords(map->bspLeafBlockmap, &blockCoords, box); + return GameMap_IterateCellBlockBspLeafs(map, &blockCoords, sector, box, localValidCount, callback, parameters); } -int GameMap_SubsectorIterator(GameMap* map, int (*callback) (subsector_t*, void*), void* parameters) +int GameMap_BspLeafIterator(GameMap* map, int (*callback) (BspLeaf*, void*), void* parameters) { uint i; assert(map); - for(i = 0; i < map->numSubsectors; ++i) + for(i = 0; i < map->numBspLeafs; ++i) { - int result = callback(map->subsectors + i, parameters); + int result = callback(map->bspLeafs + i, parameters); if(result) return result; } return false; // Continue iteration. @@ -1388,7 +1388,7 @@ int GameMap_PathXYTraverse(GameMap* map, float fromX, float fromY, float toX, fl return GameMap_PathXYTraverse2(map, fromX, fromY, toX, toY, flags, callback, NULL/*no parameters*/); } -subsector_t* GameMap_SubsectorAtPoint(GameMap* map, float point_[2]) +BspLeaf* GameMap_BspLeafAtPoint(GameMap* map, float point_[2]) { BspNode* node = 0; uint nodenum = 0; @@ -1397,27 +1397,27 @@ subsector_t* GameMap_SubsectorAtPoint(GameMap* map, float point_[2]) point[0] = point_? point_[0] : 0; point[1] = point_? point_[1] : 0; - // single subsector is a special case + // A single BSP leaf is a special case if(!map->numBspNodes) { - return (subsector_t*) map->subsectors; + return (BspLeaf*) map->bspLeafs; } nodenum = map->numBspNodes - 1; - while(!(nodenum & NF_SUBSECTOR)) + while(!(nodenum & NF_LEAF)) { node = map->bspNodes + nodenum; ASSERT_DMU_TYPE(node, DMU_BSPNODE); nodenum = node->children[P_PointOnPartitionSide(point[0], point[1], &node->partition)]; } - return map->subsectors + (nodenum & ~NF_SUBSECTOR); + return map->bspLeafs + (nodenum & ~NF_LEAF); } -subsector_t* GameMap_SubsectorAtPointXY(GameMap* map, float x, float y) +BspLeaf* GameMap_BspLeafAtPointXY(GameMap* map, float x, float y) { float point[2]; point[0] = x; point[1] = y; - return GameMap_SubsectorAtPoint(map, point); + return GameMap_BspLeafAtPoint(map, point); } diff --git a/doomsday/engine/portable/src/net_main.c b/doomsday/engine/portable/src/net_main.c index c59c9d6c28..d6207209f3 100644 --- a/doomsday/engine/portable/src/net_main.c +++ b/doomsday/engine/portable/src/net_main.c @@ -1103,7 +1103,7 @@ D_CMD(MakeCamera) mo->pos[VX] = conp->mo->pos[VX]; mo->pos[VY] = conp->mo->pos[VY]; mo->pos[VZ] = conp->mo->pos[VZ]; - mo->subsector = conp->mo->subsector; + mo->bspLeaf = conp->mo->bspLeaf; ddPlayers[cp].mo = mo; displayPlayer = cp; */ diff --git a/doomsday/engine/portable/src/p_data.c b/doomsday/engine/portable/src/p_data.c index c21789e3b9..dbdcee3c40 100644 --- a/doomsday/engine/portable/src/p_data.c +++ b/doomsday/engine/portable/src/p_data.c @@ -53,7 +53,7 @@ Uri* mapUri; // Name by which the game referred to the current map. vertex_t* vertexes = NULL; HEdge* hedges = NULL; sector_t* sectors = NULL; -subsector_t* subsectors = NULL; +BspLeaf* bspLeafs = NULL; BspNode* bspNodes = NULL; linedef_t* lineDefs = NULL; sidedef_t* sideDefs = NULL; @@ -121,7 +121,7 @@ void P_SetCurrentMap(GameMap* map) vertexes = 0; hedges = 0; sectors = 0; - subsectors = 0; + bspLeafs = 0; bspNodes = 0; lineDefs = 0; sideDefs = 0; @@ -136,7 +136,7 @@ void P_SetCurrentMap(GameMap* map) vertexes = map->vertexes; hedges = map->hedges; sectors = map->sectors; - subsectors = map->subsectors; + bspLeafs = map->bspLeafs; bspNodes = map->bspNodes; lineDefs = map->lineDefs; sideDefs = map->sideDefs; diff --git a/doomsday/engine/portable/src/p_dmu.c b/doomsday/engine/portable/src/p_dmu.c index a480aad775..541d9a452a 100644 --- a/doomsday/engine/portable/src/p_dmu.c +++ b/doomsday/engine/portable/src/p_dmu.c @@ -101,7 +101,7 @@ const char* DMU_Str(uint prop) { DMU_LINEDEF, "DMU_LINEDEF" }, { DMU_SIDEDEF, "DMU_SIDEDEF" }, { DMU_BSPNODE, "DMU_BSPNODE" }, - { DMU_SUBSECTOR, "DMU_SUBSECTOR" }, + { DMU_BSPLEAF, "DMU_BSPLEAF" }, { DMU_SECTOR, "DMU_SECTOR" }, { DMU_PLANE, "DMU_PLANE" }, { DMU_MATERIAL, "DMU_MATERIAL" }, @@ -192,7 +192,7 @@ int DMU_GetType(const void* ptr) case DMU_HEDGE: case DMU_LINEDEF: case DMU_SIDEDEF: - case DMU_SUBSECTOR: + case DMU_BSPLEAF: case DMU_SECTOR: case DMU_PLANE: case DMU_BSPNODE: @@ -433,8 +433,8 @@ uint P_ToIndex(const void* ptr) case DMU_SIDEDEF: return GET_SIDE_IDX((sidedef_t*) ptr); - case DMU_SUBSECTOR: - return GET_SUBSECTOR_IDX((subsector_t*) ptr); + case DMU_BSPLEAF: + return GET_BSPLEAF_IDX((BspLeaf*) ptr); case DMU_SECTOR: return GET_SECTOR_IDX((sector_t*) ptr); @@ -473,8 +473,8 @@ void* P_ToPtr(int type, uint index) case DMU_SIDEDEF: return SIDE_PTR(index); - case DMU_SUBSECTOR: - return SUBSECTOR_PTR(index); + case DMU_BSPLEAF: + return BSPLEAF_PTR(index); case DMU_SECTOR: return SECTOR_PTR(index); @@ -531,14 +531,14 @@ int P_Iteratep(void *ptr, uint prop, void* context, int (*callback) (void* p, vo } return result; } - case DMU_SUBSECTOR: + case DMU_BSPLEAF: { sector_t* sec = (sector_t*) ptr; int result = false; // Continue iteration. - if(sec->subsectors) + if(sec->bspLeafs) { - subsector_t** ssecIter = sec->subsectors; + BspLeaf** ssecIter = sec->bspLeafs; while(*ssecIter && !(result = callback(*ssecIter, context))) ssecIter++; } @@ -548,17 +548,17 @@ int P_Iteratep(void *ptr, uint prop, void* context, int (*callback) (void* p, vo Con_Error("P_Iteratep: Property %s unknown/not vector.\n", DMU_Str(prop)); } break; - case DMU_SUBSECTOR: + case DMU_BSPLEAF: switch(prop) { case DMU_HEDGE: { - subsector_t* ssec = (subsector_t*) ptr; + BspLeaf* bspLeaf = (BspLeaf*) ptr; int result = false; // Continue iteration. - if(ssec->hedges) + if(bspLeaf->hedges) { - HEdge** segIter = ssec->hedges; + HEdge** segIter = bspLeaf->hedges; while(*segIter && !(result = callback(*segIter, context))) segIter++; } @@ -620,9 +620,9 @@ int P_Callback(int type, uint index, void* context, return callback(BSPNODE_PTR(index), context); break; - case DMU_SUBSECTOR: - if(index < NUM_SUBSECTORS) - return callback(SUBSECTOR_PTR(index), context); + case DMU_BSPLEAF: + if(index < NUM_BSPLEAFS) + return callback(BSPLEAF_PTR(index), context); break; case DMU_SECTOR: @@ -675,7 +675,7 @@ int P_Callbackp(int type, void* ptr, void* context, case DMU_LINEDEF: case DMU_SIDEDEF: case DMU_BSPNODE: - case DMU_SUBSECTOR: + case DMU_BSPLEAF: case DMU_SECTOR: case DMU_PLANE: case DMU_MATERIAL: @@ -917,7 +917,7 @@ static int setProperty(void* obj, void* context) linedef_t* updateLinedef = NULL; sidedef_t* updateSidedef = NULL; surface_t* updateSurface = NULL; - // subsector_t* updateSubsector = NULL; + // BspLeaf* updateBspLeaf = NULL; /** * \algorithm: @@ -936,18 +936,18 @@ static int setProperty(void* obj, void* context) */ // Dereference where necessary. Note the order, these cascade. - if(args->type == DMU_SUBSECTOR) + if(args->type == DMU_BSPLEAF) { - // updateSubsector = (subsector_t*) obj; + // updateBspLeaf = (BspLeaf*) obj; if(args->modifiers & DMU_FLOOR_OF_SECTOR) { - obj = ((subsector_t*) obj)->sector; + obj = ((BspLeaf*) obj)->sector; args->type = DMU_SECTOR; } else if(args->modifiers & DMU_CEILING_OF_SECTOR) { - obj = ((subsector_t*) obj)->sector; + obj = ((BspLeaf*) obj)->sector; args->type = DMU_SECTOR; } } @@ -1093,8 +1093,8 @@ static int setProperty(void* obj, void* context) SideDef_SetProperty(obj, args); break; - case DMU_SUBSECTOR: - Subsector_SetProperty(obj, args); + case DMU_BSPLEAF: + BspLeaf_SetProperty(obj, args); break; case DMU_SECTOR: @@ -1165,9 +1165,9 @@ static int setProperty(void* obj, void* context) R_UpdateSector(updateSector2, false); } -/* if(updateSubsector) +/* if(updateBspLeaf) { - R_UpdateSubsector(updateSubsector, false); + R_UpdateBspLeaf(updateBspLeaf, false); } */ return true; // Continue iteration. @@ -1399,16 +1399,16 @@ static int getProperty(void* obj, void* context) setargs_t* args = (setargs_t*) context; // Dereference where necessary. Note the order, these cascade. - if(args->type == DMU_SUBSECTOR) + if(args->type == DMU_BSPLEAF) { if(args->modifiers & DMU_FLOOR_OF_SECTOR) { - obj = ((subsector_t*) obj)->sector; + obj = ((BspLeaf*) obj)->sector; args->type = DMU_SECTOR; } else if(args->modifiers & DMU_CEILING_OF_SECTOR) { - obj = ((subsector_t*) obj)->sector; + obj = ((BspLeaf*) obj)->sector; args->type = DMU_SECTOR; } } @@ -1550,8 +1550,8 @@ static int getProperty(void* obj, void* context) SideDef_GetProperty(obj, args); break; - case DMU_SUBSECTOR: - Subsector_GetProperty(obj, args); + case DMU_BSPLEAF: + BspLeaf_GetProperty(obj, args); break; case DMU_MATERIAL: diff --git a/doomsday/engine/portable/src/p_maputil.c b/doomsday/engine/portable/src/p_maputil.c index bbd80e19b4..3cfe1e38bc 100644 --- a/doomsday/engine/portable/src/p_maputil.c +++ b/doomsday/engine/portable/src/p_maputil.c @@ -496,31 +496,31 @@ void P_SetTraceOpening(linedef_t* linedef) } /// @note Part of the Doomsday public API -subsector_t* P_SubsectorAtPointXY(float x, float y) +BspLeaf* P_BspLeafAtPointXY(float x, float y) { if(theMap) { - return GameMap_SubsectorAtPointXY(theMap, x, y); + return GameMap_BspLeafAtPointXY(theMap, x, y); } return NULL; } -boolean P_IsPointXYInSubsector(float x, float y, const subsector_t* ssec) +boolean P_IsPointXYInBspLeaf(float x, float y, const BspLeaf* bspLeaf) { fvertex_t* vi, *vj; uint i; - if(!ssec) return false; // I guess? + if(!bspLeaf) return false; // I guess? - for(i = 0; i < ssec->hedgeCount; ++i) + for(i = 0; i < bspLeaf->hedgeCount; ++i) { - vi = &ssec->hedges[i]->HE_v1->v; - vj = &ssec->hedges[(i + 1) % ssec->hedgeCount]->HE_v1->v; + vi = &bspLeaf->hedges[i]->HE_v1->v; + vj = &bspLeaf->hedges[(i + 1) % bspLeaf->hedgeCount]->HE_v1->v; if(((vi->pos[VY] - y) * (vj->pos[VX] - vi->pos[VX]) - (vi->pos[VX] - x) * (vj->pos[VY] - vi->pos[VY])) < 0) { - // Outside the subsector's edges. + // Outside the BSP leaf's edges. return false; } } @@ -530,14 +530,14 @@ boolean P_IsPointXYInSubsector(float x, float y, const subsector_t* ssec) boolean P_IsPointXYInSector(float x, float y, const sector_t* sector) { - subsector_t* ssec; + BspLeaf* bspLeaf; if(!sector) return false; // I guess? /// @fixme Do not assume @a sector is from the current map. - ssec = GameMap_SubsectorAtPointXY(theMap, x, y); - if(ssec->sector != sector) return false; + bspLeaf = GameMap_BspLeafAtPointXY(theMap, x, y); + if(bspLeaf->sector != sector) return false; - return P_IsPointXYInSubsector(x, y, ssec); + return P_IsPointXYInBspLeaf(x, y, bspLeaf); } /** @@ -701,17 +701,17 @@ void GameMap_LinkMobjToLineDefs(GameMap* map, mobj_t* mo) } /** - * Links a mobj into both a block and a subsector based on it's (x,y). - * Sets mobj->subsector properly. Calling with flags==0 only updates - * the subsector pointer. Can be called without unlinking first. + * Links a mobj into both a block and a BSP leaf based on it's (x,y). + * Sets mobj->bspLeaf properly. Calling with flags==0 only updates + * the BspLeaf pointer. Can be called without unlinking first. */ void P_MobjLink(mobj_t* mo, byte flags) { sector_t* sec; // Link into the sector. - mo->subsector = P_SubsectorAtPointXY(mo->pos[VX], mo->pos[VY]); - sec = mo->subsector->sector; + mo->bspLeaf = P_BspLeafAtPointXY(mo->pos[VX], mo->pos[VY]); + sec = mo->bspLeaf->sector; if(flags & DDLINK_SECTOR) { @@ -756,9 +756,9 @@ void P_MobjLink(mobj_t* mo, byte flags) player->inVoid = true; if(P_IsPointXYInSector(player->mo->pos[VX], player->mo->pos[VY], - player->mo->subsector->sector) && - (player->mo->pos[VZ] < player->mo->subsector->sector->SP_ceilvisheight + 4 && - player->mo->pos[VZ] >= player->mo->subsector->sector->SP_floorvisheight)) + player->mo->bspLeaf->sector) && + (player->mo->pos[VZ] < player->mo->bspLeaf->sector->SP_ceilvisheight + 4 && + player->mo->pos[VZ] >= player->mo->bspLeaf->sector->SP_floorvisheight)) player->inVoid = false; } } @@ -810,7 +810,7 @@ int GameMap_MobjSectorsIterator(GameMap* map, mobj_t* mo, tn = map->mobjNodes.nodes; // Always process the mobj's own sector first. - *end++ = sec = mo->subsector->sector; + *end++ = sec = mo->bspLeaf->sector; sec->validCount = validCount; // Any good lines around here? @@ -1118,11 +1118,11 @@ int P_PolyobjLinesBoxIterator(const AABoxf* box, int (*callback) (linedef_t*, vo } /// @note Part of the Doomsday public API. -int P_SubsectorsBoxIterator(const AABoxf* box, sector_t* sector, - int (*callback) (subsector_t*, void*), void* parameters) +int P_BspLeafsBoxIterator(const AABoxf* box, sector_t* sector, + int (*callback) (BspLeaf*, void*), void* parameters) { if(!theMap) return false; // Continue iteration. - return GameMap_SubsectorsBoxIterator(theMap, box, sector, callback, parameters); + return GameMap_BspLeafsBoxIterator(theMap, box, sector, callback, parameters); } /// @note Part of the Doomsday public API. diff --git a/doomsday/engine/portable/src/p_mobj.c b/doomsday/engine/portable/src/p_mobj.c index f2c1021bc0..d7229cdd59 100644 --- a/doomsday/engine/portable/src/p_mobj.c +++ b/doomsday/engine/portable/src/p_mobj.c @@ -319,11 +319,11 @@ D_CMD(InspectMobj) mo->pos[0], mo->pos[1], mo->pos[2], mo->mom[0], mo->mom[1], mo->mom[2]); Con_Printf("FloorZ:%f CeilingZ:%f\n", mo->floorZ, mo->ceilingZ); - if(mo->subsector) + if(mo->bspLeaf) { - Con_Printf("Sector:%i (FloorZ:%f CeilingZ:%f)\n", P_ToIndex(mo->subsector->sector), - mo->subsector->sector->SP_floorheight, - mo->subsector->sector->SP_ceilheight); + Con_Printf("Sector:%i (FloorZ:%f CeilingZ:%f)\n", P_ToIndex(mo->bspLeaf->sector), + mo->bspLeaf->sector->SP_floorheight, + mo->bspLeaf->sector->SP_ceilheight); } if(mo->onMobj) { diff --git a/doomsday/engine/portable/src/p_objlink.c b/doomsday/engine/portable/src/p_objlink.c index 96bcb9366b..baf7d8bf04 100644 --- a/doomsday/engine/portable/src/p_objlink.c +++ b/doomsday/engine/portable/src/p_objlink.c @@ -71,7 +71,7 @@ typedef struct { } contactfinderparams_t; typedef struct objcontact_s { - struct objcontact_s* next; /// Next in the subsector. + struct objcontact_s* next; /// Next in the BSP leaf. struct objcontact_s* nextUsed; /// Next used contact. void* obj; } objcontact_t; @@ -91,8 +91,8 @@ static objlinkblockmap_t blockmaps[NUM_OBJ_TYPES]; // List of unused and used contacts. static objcontact_t* contFirst = NULL, *contCursor = NULL; -// List of contacts for each subsector. -static objcontactlist_t* subsectorContacts = NULL; +// List of contacts for each BSP leaf. +static objcontactlist_t* bspLeafContacts = NULL; static __inline objlinkblockmap_t* chooseObjlinkBlockmap(objtype_t type) { @@ -169,9 +169,9 @@ static __inline void linkContact(objcontact_t* con, objcontact_t** list, uint in list[index] = con; } -static void linkContactToSubsector(objcontact_t* node, objtype_t type, uint index) +static void linkContactToBspLeaf(objcontact_t* node, objtype_t type, uint index) { - linkContact(node, &subsectorContacts[index].head[type], 0); + linkContact(node, &bspLeafContacts[index].head[type], 0); } /** @@ -245,8 +245,8 @@ void R_InitObjlinkBlockmapForMap(void) obm->gridmap = Gridmap_New(width, height, sizeof(objlinkblock_t), PU_MAPSTATIC); } - // Initialize obj => subsector contact lists. - subsectorContacts = Z_Calloc(sizeof *subsectorContacts * NUM_SUBSECTORS, PU_MAPSTATIC, 0); + // Initialize obj => BspLeaf contact lists. + bspLeafContacts = Z_Calloc(sizeof *bspLeafContacts * NUM_BSPLEAFS, PU_MAPSTATIC, 0); } void R_DestroyObjlinkBlockmap(void) @@ -259,10 +259,10 @@ void R_DestroyObjlinkBlockmap(void) Gridmap_Delete(obm->gridmap); obm->gridmap = NULL; } - if(subsectorContacts) + if(bspLeafContacts) { - Z_Free(subsectorContacts); - subsectorContacts = NULL; + Z_Free(bspLeafContacts); + bspLeafContacts = NULL; } } @@ -309,51 +309,51 @@ void R_ObjlinkCreate(void* obj, objtype_t type) link->type = type; } -int RIT_LinkObjToSubsector(subsector_t* subsector, void* paramaters) +int RIT_LinkObjToBspLeaf(BspLeaf* bspLeaf, void* paramaters) { - const linkobjtosubsectorparams_t* p = (linkobjtosubsectorparams_t*) paramaters; + const linkobjtobspleafparams_t* p = (linkobjtobspleafparams_t*) paramaters; objcontact_t* con = allocObjContact(); con->obj = p->obj; - // Link the contact list for this subsector. - linkContactToSubsector(con, p->type, GET_SUBSECTOR_IDX(subsector)); + // Link the contact list for this bspLeaf. + linkContactToBspLeaf(con, p->type, GET_BSPLEAF_IDX(bspLeaf)); return false; // Continue iteration. } /** * Attempt to spread the obj from the given contact from the source - * subsector and into the (relative) back subsector. + * BspLeaf and into the (relative) back BspLeaf. * - * @param subsec Subsector to attempt to spread over to. + * @param bspLeaf BspLeaf to attempt to spread over to. * @param data @see contactfinderparams_t * * @return @c true (always - this function is also used as an iterator). */ -static void spreadInSubsector(subsector_t* ssec, void* paramaters) +static void spreadInBspLeaf(BspLeaf* bspLeaf, void* paramaters) { - HEdge** segIter = ssec->hedges; - while(*segIter) { processSeg(*segIter++, paramaters); } + HEdge** hedgeIter = bspLeaf->hedges; + while(*hedgeIter) { processSeg(*hedgeIter++, paramaters); } } static void processSeg(HEdge* hedge, void* paramaters) { contactfinderparams_t* p = (contactfinderparams_t*) paramaters; - linkobjtosubsectorparams_t loParams; - subsector_t* source, *dest; + linkobjtobspleafparams_t loParams; + BspLeaf* source, *dest; float distance; vertex_t* vtx; - // HEdge must be between two different subsectors. - if(hedge->lineDef && (!hedge->twin || hedge->subsector == hedge->twin->subsector)) + // HEdge must be between two different BspLeafs. + if(hedge->lineDef && (!hedge->twin || hedge->bspLeaf == hedge->twin->bspLeaf)) return; // Which way does the spread go? - if(hedge->subsector->validCount == validCount && - hedge->twin->subsector->validCount != validCount) + if(hedge->bspLeaf->validCount == validCount && + hedge->twin->bspLeaf->validCount != validCount) { - source = hedge->subsector; - dest = hedge->twin->subsector; + source = hedge->bspLeaf; + dest = hedge->twin->bspLeaf; } else { @@ -361,13 +361,13 @@ static void processSeg(HEdge* hedge, void* paramaters) return; } - // Is the dest subsector inside the objlink's AABB? + // Is the dest BspLeaf inside the objlink's AABB? if(dest->aaBox.maxX <= p->box[BOXLEFT] || dest->aaBox.minX >= p->box[BOXRIGHT] || dest->aaBox.maxY <= p->box[BOXBOTTOM] || dest->aaBox.minY >= p->box[BOXTOP]) { - // The subsector is not inside the params's bounds. + // The BspLeaf is not inside the params's bounds. return; } @@ -388,7 +388,7 @@ static void processSeg(HEdge* hedge, void* paramaters) // Don't spread if the middle material completely fills the gap between // floor and ceiling (direction is from dest to source). if(LineDef_MiddleMaterialCoversOpening(hedge->lineDef, - dest == hedge->twin->subsector? false : true, false)) + dest == hedge->twin->bspLeaf? false : true, false)) return; } @@ -403,8 +403,8 @@ static void processSeg(HEdge* hedge, void* paramaters) if(hedge->lineDef) { - if((source == hedge->subsector && distance < 0) || - (source == hedge->twin->subsector && distance > 0)) + if((source == hedge->bspLeaf && distance < 0) || + (source == hedge->twin->bspLeaf && distance > 0)) { // Can't spread in this direction. return; @@ -422,27 +422,27 @@ static void processSeg(HEdge* hedge, void* paramaters) // During next step, obj will continue spreading from there. dest->validCount = validCount; - // Add this obj to the destination subsector. + // Add this obj to the destination BspLeaf. loParams.obj = p->obj; loParams.type = p->objType; - RIT_LinkObjToSubsector(dest, &loParams); + RIT_LinkObjToBspLeaf(dest, &loParams); - spreadInSubsector(dest, paramaters); + spreadInBspLeaf(dest, paramaters); } /** - * Create a contact for the objlink in all the subsectors the linked obj is - * contacting (tests done on bounding boxes and the subsector spread test). + * Create a contact for the objlink in all the BspLeafs the linked obj is + * contacting (tests done on bounding boxes and the BSP leaf spread test). * - * @param oLink Ptr to objlink to find subsector contacts for. + * @param oLink Ptr to objlink to find BspLeaf contacts for. */ static void findContacts(objlink_t* link) { contactfinderparams_t cfParams; - linkobjtosubsectorparams_t loParams; + linkobjtobspleafparams_t loParams; float radius; pvec3_t pos; - subsector_t** ssecAdr; + BspLeaf** ssecAdr; switch(link->type) { @@ -453,7 +453,7 @@ static void findContacts(objlink_t* link) pos = lum->pos; radius = LUM_OMNI(lum)->radius; - ssecAdr = &lum->subsector; + ssecAdr = &lum->bspLeaf; break; } case OT_MOBJ: { @@ -461,7 +461,7 @@ static void findContacts(objlink_t* link) pos = mo->pos; radius = R_VisualRadius(mo); - ssecAdr = &mo->subsector; + ssecAdr = &mo->bspLeaf; break; } default: @@ -469,7 +469,7 @@ static void findContacts(objlink_t* link) exit(1); // Unreachable. } - // Do the subsector spread. Begin from the obj's own subsector. + // Do the BSP leaf spread. Begin from the obj's own BspLeaf. (*ssecAdr)->validCount = ++validCount; cfParams.obj = link->obj; @@ -483,34 +483,34 @@ static void findContacts(objlink_t* link) cfParams.box[BOXBOTTOM] = cfParams.objPos[VY] - radius; cfParams.box[BOXTOP] = cfParams.objPos[VY] + radius; - // Always contact the obj's own subsector. + // Always contact the obj's own BspLeaf. loParams.obj = link->obj; loParams.type = link->type; - RIT_LinkObjToSubsector(*ssecAdr, &loParams); + RIT_LinkObjToBspLeaf(*ssecAdr, &loParams); - spreadInSubsector(*ssecAdr, &cfParams); + spreadInBspLeaf(*ssecAdr, &cfParams); } /** - * Spread contacts in the object => Subsector objlink blockmap to all - * other Subsectors within the block. + * Spread contacts in the object => BspLeaf objlink blockmap to all + * other BspLeafs within the block. * - * @param subsector Subsector to spread the contacts of. + * @param bspLeaf BspLeaf to spread the contacts of. */ -void R_ObjlinkBlockmapSpreadInSubsector(objlinkblockmap_t* obm, - const subsector_t* ssec, float maxRadius) +void R_ObjlinkBlockmapSpreadInBspLeaf(objlinkblockmap_t* obm, + const BspLeaf* bspLeaf, float maxRadius) { uint minBlock[2], maxBlock[2], x, y; objlink_t* iter; assert(obm); - if(!ssec) return; // Wha? + if(!bspLeaf) return; // Wha? - toObjlinkBlockmapCell(obm, minBlock, ssec->aaBox.minX - maxRadius, - ssec->aaBox.minY - maxRadius); + toObjlinkBlockmapCell(obm, minBlock, bspLeaf->aaBox.minX - maxRadius, + bspLeaf->aaBox.minY - maxRadius); - toObjlinkBlockmapCell(obm, maxBlock, ssec->aaBox.maxX + maxRadius, - ssec->aaBox.maxY + maxRadius); + toObjlinkBlockmapCell(obm, maxBlock, bspLeaf->aaBox.maxX + maxRadius, + bspLeaf->aaBox.maxY + maxRadius); for(y = minBlock[1]; y <= maxBlock[1]; ++y) for(x = minBlock[0]; x <= maxBlock[0]; ++x) @@ -536,7 +536,7 @@ static __inline const float maxRadius(objtype_t type) return loMaxRadius; } -void R_InitForSubsector(subsector_t* ssec) +void R_InitForBspLeaf(BspLeaf* bspLeaf) { int i; BEGIN_PROF( PROF_OBJLINK_SPREAD ); @@ -544,7 +544,7 @@ BEGIN_PROF( PROF_OBJLINK_SPREAD ); for(i = 0; i < NUM_OBJ_TYPES; ++i) { objlinkblockmap_t* obm = chooseObjlinkBlockmap((objtype_t)i); - R_ObjlinkBlockmapSpreadInSubsector(obm, ssec, maxRadius((objtype_t)i)); + R_ObjlinkBlockmapSpreadInBspLeaf(obm, bspLeaf, maxRadius((objtype_t)i)); } END_PROF( PROF_OBJLINK_SPREAD ); @@ -608,14 +608,14 @@ void R_InitForNewFrame(void) // Start reusing nodes from the first one in the list. contCursor = contFirst; - if(subsectorContacts) - memset(subsectorContacts, 0, NUM_SUBSECTORS * sizeof *subsectorContacts); + if(bspLeafContacts) + memset(bspLeafContacts, 0, NUM_BSPLEAFS * sizeof *bspLeafContacts); } -int R_IterateSubsectorContacts2(subsector_t* ssec, objtype_t type, +int R_IterateBspLeafContacts2(BspLeaf* bspLeaf, objtype_t type, int (*callback) (void* object, void* paramaters), void* paramaters) { - objcontact_t* con = subsectorContacts[GET_SUBSECTOR_IDX(ssec)].head[type]; + objcontact_t* con = bspLeafContacts[GET_BSPLEAF_IDX(bspLeaf)].head[type]; int result = false; // Continue iteration. while(con) { @@ -626,8 +626,8 @@ int R_IterateSubsectorContacts2(subsector_t* ssec, objtype_t type, return result; } -int R_IterateSubsectorContacts(subsector_t* ssec, objtype_t type, +int R_IterateBspLeafContacts(BspLeaf* bspLeaf, objtype_t type, int (*callback) (void* object, void* paramaters)) { - return R_IterateSubsectorContacts2(ssec, type, callback, NULL/*no paramaters*/); + return R_IterateBspLeafContacts2(bspLeaf, type, callback, NULL/*no paramaters*/); } diff --git a/doomsday/engine/portable/src/p_particle.c b/doomsday/engine/portable/src/p_particle.c index 2ceb331bba..411c72dbf9 100644 --- a/doomsday/engine/portable/src/p_particle.c +++ b/doomsday/engine/portable/src/p_particle.c @@ -315,7 +315,7 @@ void P_SpawnMobjParticleGen(const ded_ptcgen_t* def, mobj_t* source) // Size of source sector might determine count. if(def->flags & PGF_SCALED_RATE) { - gen->spawnRateMultiplier = source->subsector->sector->approxArea; + gen->spawnRateMultiplier = source->bspLeaf->sector->approxArea; } else { @@ -461,7 +461,7 @@ static void P_NewParticle(ptcgen_t* gen) int i; fixed_t uncertain, len; angle_t ang, ang2; - subsector_t* subsec; + BspLeaf* subsec; float inter = -1; modeldef_t* mf = 0, *nextmf = 0; @@ -634,8 +634,8 @@ static void P_NewParticle(ptcgen_t* gen) * Choosing the XY spot is a bit more difficult. * But we must be fast and only sufficiently accurate. * - * \fixme Nothing prevents spawning on the wrong side (or inside) - * of one-sided walls (large diagonal subsectors!). + * @fixme Nothing prevents spawning on the wrong side (or inside) + * of one-sided walls (large diagonal BSP leafs!). */ for(i = 0; i < 5; ++i) // Try a couple of times (max). { @@ -644,7 +644,7 @@ static void P_NewParticle(ptcgen_t* gen) float y = (bbox[BOXBOTTOM] + RNG_RandFloat() * (bbox[BOXTOP] - bbox[BOXBOTTOM])); - subsec = P_SubsectorAtPointXY(x, y); + subsec = P_BspLeafAtPointXY(x, y); if(subsec->sector == sector) break; @@ -665,7 +665,7 @@ static void P_NewParticle(ptcgen_t* gen) pt->pos[VX] = FLT2FIX(x); pt->pos[VY] = FLT2FIX(y); - if(P_SubsectorAtPointXY(x, y) == subsec) + if(P_BspLeafAtPointXY(x, y) == subsec) break; // This is a good place. } @@ -694,7 +694,7 @@ static void P_NewParticle(ptcgen_t* gen) if(gen->plane) pt->sector = gen->plane->sector; else - pt->sector = P_SubsectorAtPointXY(FIX2FLT(pt->pos[VX]), + pt->sector = P_BspLeafAtPointXY(FIX2FLT(pt->pos[VX]), FIX2FLT(pt->pos[VY]))->sector; // Play a stage sound? @@ -1175,7 +1175,7 @@ static void P_MoveParticle(ptcgen_t* gen, particle_t* pt) // Should we update the sector pointer? if(tmcross) - pt->sector = P_SubsectorAtPointXY(FIX2FLT(x), FIX2FLT(y))->sector; + pt->sector = P_BspLeafAtPointXY(FIX2FLT(x), FIX2FLT(y))->sector; } /** diff --git a/doomsday/engine/portable/src/p_players.c b/doomsday/engine/portable/src/p_players.c index 78e4e704d1..1758d41fa2 100644 --- a/doomsday/engine/portable/src/p_players.c +++ b/doomsday/engine/portable/src/p_players.c @@ -139,9 +139,9 @@ int P_GetDDPlayerIdx(ddplayer_t* ddpl) /** * Do we THINK the given (camera) player is currently in the void. * The method used to test this is to compare the position of the mobj - * each time it is linked into a subsector. + * each time it is linked into a BSP leaf. * - * \note Cannot be 100% accurate so best not to use it for anything critical... + * @note Cannot be 100% accurate so best not to use it for anything critical... * * @param player The player to test. * @@ -163,9 +163,9 @@ boolean P_IsInVoid(player_t* player) if(ddpl->inVoid) return true; - if(ddpl->mo && ddpl->mo->subsector) + if(ddpl->mo && ddpl->mo->bspLeaf) { - sector_t* sec = ddpl->mo->subsector->sector; + sector_t* sec = ddpl->mo->bspLeaf->sector; if(R_IsSkySurface(&sec->SP_ceilsurface)) { diff --git a/doomsday/engine/portable/src/p_sight.c b/doomsday/engine/portable/src/p_sight.c index 4a8e91ff32..b92a9754f7 100644 --- a/doomsday/engine/portable/src/p_sight.c +++ b/doomsday/engine/portable/src/p_sight.c @@ -163,15 +163,15 @@ static boolean crossLineDef(const linedef_t* li, byte side, losdata_t* los) } /** - * @return @c true iff trace crosses the given subsector. + * @return @c true iff trace crosses the given BSP leaf. */ -static boolean crossSSec(GameMap* map, uint ssecIdx, losdata_t* los) +static boolean crossBspLeaf(GameMap* map, uint bspLeafIdx, losdata_t* los) { - const subsector_t* ssec = &map->subsectors[ssecIdx]; - if(ssec->polyObj) + const BspLeaf* bspLeaf = &map->bspLeafs[bspLeafIdx]; + if(bspLeaf->polyObj) { // Check polyobj lines. - polyobj_t* po = ssec->polyObj; + polyobj_t* po = bspLeaf->polyObj; linedef_t** lineIter = po->lines; while(*lineIter) { @@ -187,10 +187,10 @@ static boolean crossSSec(GameMap* map, uint ssecIdx, losdata_t* los) } // Check edges. - { HEdge** segPtr = ssec->hedges; - while(*segPtr) + { HEdge** hedgeIter = bspLeaf->hedges; + while(*hedgeIter) { - const HEdge* hedge = *segPtr; + const HEdge* hedge = *hedgeIter; if(hedge->lineDef && hedge->lineDef->validCount != validCount) { linedef_t* li = hedge->lineDef; @@ -198,7 +198,7 @@ static boolean crossSSec(GameMap* map, uint ssecIdx, losdata_t* los) if(!crossLineDef(li, hedge->side, los)) return false; } - segPtr++; + hedgeIter++; }} return true; // Continue iteration. @@ -207,9 +207,9 @@ static boolean crossSSec(GameMap* map, uint ssecIdx, losdata_t* los) /** * @return @c true iff trace crosses the node. */ -static boolean crossBSPNode(GameMap* map, unsigned int bspNum, losdata_t* los) +static boolean crossBspNode(GameMap* map, unsigned int bspNum, losdata_t* los) { - while(!(bspNum & NF_SUBSECTOR)) + while(!(bspNum & NF_LEAF)) { const BspNode* node = &map->bspNodes[bspNum]; int side = P_PointOnPartitionSide(FIX2FLT(los->trace.pos[VX]), FIX2FLT(los->trace.pos[VY]), @@ -224,14 +224,14 @@ static boolean crossBSPNode(GameMap* map, unsigned int bspNum, losdata_t* los) else { // No. - if(!crossBSPNode(map, node->children[side], los)) + if(!crossBspNode(map, node->children[side], los)) return 0; // Cross the starting side. bspNum = node->children[side^1]; // Cross the ending side. } } - return crossSSec(map, bspNum & ~NF_SUBSECTOR, los); + return crossBspLeaf(map, bspNum & ~NF_LEAF, los); } boolean GameMap_CheckLineSight(GameMap* map, const float from[3], const float to[3], @@ -275,5 +275,5 @@ boolean GameMap_CheckLineSight(GameMap* map, const float from[3], const float to } validCount++; - return crossBSPNode(map, map->numBspNodes - 1, &los); + return crossBspNode(map, map->numBspNodes - 1, &los); } diff --git a/doomsday/engine/portable/src/p_subsector.c b/doomsday/engine/portable/src/p_subsector.c index 04a412f249..a2a67c5586 100644 --- a/doomsday/engine/portable/src/p_subsector.c +++ b/doomsday/engine/portable/src/p_subsector.c @@ -1,4 +1,4 @@ -/**\file p_subsector.c +/**\file bspleaf.c *\section License * License: GPL * Online License Link: http://www.gnu.org/licenses/gpl.html @@ -27,34 +27,34 @@ #include "de_refresh.h" #include "de_play.h" -int Subsector_SetProperty(subsector_t* sub, const setargs_t* args) +int BspLeaf_SetProperty(BspLeaf* leaf, const setargs_t* args) { - Con_Error("Subsector_SetProperty: Property %s is not writable.\n", DMU_Str(args->prop)); + Con_Error("BspLeaf_SetProperty: Property %s is not writable.\n", DMU_Str(args->prop)); exit(1);// Unreachable. } -int Subsector_GetProperty(const subsector_t* sub, setargs_t* args) +int BspLeaf_GetProperty(const BspLeaf* leaf, setargs_t* args) { switch(args->prop) { case DMU_SECTOR: - DMU_GetValue(DMT_SUBSECTOR_SECTOR, &sub->sector, args, 0); + DMU_GetValue(DMT_BSPLEAF_SECTOR, &leaf->sector, args, 0); break; case DMU_LIGHT_LEVEL: - DMU_GetValue(DMT_SECTOR_LIGHTLEVEL, &sub->sector->lightLevel, args, 0); + DMU_GetValue(DMT_SECTOR_LIGHTLEVEL, &leaf->sector->lightLevel, args, 0); break; case DMT_MOBJS: - DMU_GetValue(DMT_SECTOR_MOBJLIST, &sub->sector->mobjList, args, 0); + DMU_GetValue(DMT_SECTOR_MOBJLIST, &leaf->sector->mobjList, args, 0); break; case DMU_HEDGE_COUNT: { // FIXME: - //DMU_GetValue(DMT_SUBSECTOR_HEDGECOUNT, &sub->hedgeCount, args, 0); - int val = (int) sub->hedgeCount; + //DMU_GetValue(DMT_BSPLEAF_HEDGECOUNT, &leaf->hedgeCount, args, 0); + int val = (int) leaf->hedgeCount; DMU_GetValue(DDVT_INT, &val, args, 0); break; } default: - Con_Error("Subsector_GetProperty: No property %s.\n", DMU_Str(args->prop)); + Con_Error("BspLeaf_GetProperty: No property %s.\n", DMU_Str(args->prop)); } return false; // Continue iteration. diff --git a/doomsday/engine/portable/src/p_surface.c b/doomsday/engine/portable/src/p_surface.c index 034f15a265..7cfccd0677 100644 --- a/doomsday/engine/portable/src/p_surface.c +++ b/doomsday/engine/portable/src/p_surface.c @@ -41,7 +41,7 @@ boolean Surface_AttachedToMap(surface_t* suf) if(DMU_GetType(suf->owner) == DMU_PLANE) { sector_t* sec = ((plane_t*)suf->owner)->sector; - if(0 == sec->subsectorCount) + if(0 == sec->bspLeafCount) return false; } return true; diff --git a/doomsday/engine/portable/src/r_fakeradio.c b/doomsday/engine/portable/src/r_fakeradio.c index 551194fc8f..b94f7e24af 100644 --- a/doomsday/engine/portable/src/r_fakeradio.c +++ b/doomsday/engine/portable/src/r_fakeradio.c @@ -180,30 +180,28 @@ void R_UpdateVertexShadowOffsets(vertex_t *vtx) } /** - * Link a hedge to an arbitary subsector for the purposes of shadowing. + * Link a half-edge to an arbitary BSP leaf for the purposes of shadowing. */ -static void linkShadowLineDefToSSec(linedef_t *line, byte side, - subsector_t *subsector) +static void linkShadowLineDefToSSec(linedef_t *line, byte side, BspLeaf* bspLeaf) { - shadowlink_t *link; + shadowlink_t* link; #ifdef _DEBUG -// Check the links for dupes! -{ -shadowlink_t *i; - -for(i = subsector->shadows; i; i = i->next) - if(i->lineDef == line && i->side == side) - Con_Error("R_LinkShadow: Already here!!\n"); -} + // Check the links for dupes! + { shadowlink_t* i; + for(i = bspLeaf->shadows; i; i = i->next) + { + if(i->lineDef == line && i->side == side) + Con_Error("R_LinkShadow: Already here!!\n"); + }} #endif // We'll need to allocate a new link. link = ZBlockSet_Allocate(shadowLinksBlockSet); // The links are stored into a linked list. - link->next = subsector->shadows; - subsector->shadows = link; + link->next = bspLeaf->shadows; + bspLeaf->shadows = link; link->lineDef = line; link->side = side; } @@ -214,13 +212,13 @@ typedef struct shadowlinkerparms_s { } shadowlinkerparms_t; /** - * If the shadow polygon (parm) contacts the subsector, link the poly - * to the subsector's shadow list. + * If the shadow polygon (parm) contacts the BspLeaf, link the poly + * to the BspLeaf's shadow list. */ -int RIT_ShadowSubsectorLinker(subsector_t* subsector, void *parm) +int RIT_ShadowBspLeafLinker(BspLeaf* bspLeaf, void* parm) { shadowlinkerparms_t* data = (shadowlinkerparms_t*) parm; - linkShadowLineDefToSSec(data->lineDef, data->side, subsector); + linkShadowLineDefToSSec(data->lineDef, data->side, bspLeaf); return false; // Continue iteration. } @@ -258,14 +256,14 @@ void R_InitFakeRadioForMap(void) /** * The algorithm: * - * 1. Use the subsector blockmap to look for all the blocks that are + * 1. Use the BSP leaf blockmap to look for all the blocks that are * within the linedef's shadow bounding box. * - * 2. Check the subsectors whose sector is the same as the linedef. + * 2. Check the BspLeafs whose sector is the same as the linedef. * - * 3. If any of the shadow points are in the subsector, or any of the - * shadow edges cross one of the subsector's edges (not parallel), - * link the linedef to the subsector. + * 3. If any of the shadow points are in the BSP leaf, or any of the + * shadow edges cross one of the BSP leaf's edges (not parallel), + * link the linedef to the BspLeaf. */ shadowLinksBlockSet = ZBlockSet_New(sizeof(shadowlink_t), 1024, PU_MAP); @@ -299,7 +297,7 @@ void R_InitFakeRadioForMap(void) data.lineDef = line; data.side = j; - P_SubsectorsBoxIterator(&bounds, line->L_sector(j), RIT_ShadowSubsectorLinker, &data); + P_BspLeafsBoxIterator(&bounds, line->L_sector(j), RIT_ShadowBspLeafLinker, &data); } } diff --git a/doomsday/engine/portable/src/r_lgrid.c b/doomsday/engine/portable/src/r_lgrid.c index 97334ef662..6d94e4ff32 100644 --- a/doomsday/engine/portable/src/r_lgrid.c +++ b/doomsday/engine/portable/src/r_lgrid.c @@ -309,7 +309,7 @@ void LG_InitForMap(void) sample.pos[VY] = lgOrigin[VY] + off[VY] + samplePoints[0].pos[VY]; ssamples[idx] = - P_SubsectorAtPointXY(sample.pos[VX], sample.pos[VY])->sector; + P_BspLeafAtPointXY(sample.pos[VX], sample.pos[VY])->sector; if(!P_IsPointXYInSector(sample.pos[VX], sample.pos[VY], ssamples[idx])) ssamples[idx] = NULL; @@ -358,7 +358,7 @@ void LG_InitForMap(void) sample.pos[VY] = lgOrigin[VY] + off[VY] + samplePoints[n].pos[VY]; ssamples[idx] = - P_SubsectorAtPointXY(sample.pos[VX], sample.pos[VY])->sector; + P_BspLeafAtPointXY(sample.pos[VX], sample.pos[VY])->sector; if(!P_IsPointXYInSector(sample.pos[VX], sample.pos[VY], ssamples[idx])) ssamples[idx] = NULL; } @@ -897,7 +897,7 @@ void LG_Evaluate(const vectorcomp_t point[3], float color[3]) * lighting. * * Biasing the dimming is a good idea but the heights must be taken - * from the subsector which contains the surface and not the block. + * from the BSP Leaf which contains the surface and not the block. */ if(block->sector) { diff --git a/doomsday/engine/portable/src/r_lumobjs.c b/doomsday/engine/portable/src/r_lumobjs.c index dffecf22fb..92da91a23f 100644 --- a/doomsday/engine/portable/src/r_lumobjs.c +++ b/doomsday/engine/portable/src/r_lumobjs.c @@ -77,7 +77,7 @@ typedef struct { pvec3_t normal; /// Normalized normal of the surface being projected to. } lightprojectparams_t; -static boolean iterateSubsectorLumObjs(subsector_t* ssec, boolean (*func) (void*, void*), void* data); +static boolean iterateBspLeafLumObjs(BspLeaf* bspLeaf, boolean (*func) (void*, void*), void* data); extern int useBias; @@ -99,11 +99,11 @@ static float* luminousDist = NULL; static byte* luminousClipped = NULL; static uint* luminousOrder = NULL; -// List of unused and used list nodes, for linking lumobjs with subsectors. +// List of unused and used list nodes, for linking lumobjs with BSP leafs. static lumlistnode_t* listNodeFirst = NULL, *listNodeCursor = NULL; -// List of lumobjs for each subsector; -static lumlistnode_t** subLumObjList = NULL; +// List of lumobjs for each BSP leaf; +static lumlistnode_t** bspLeafLumObjList = NULL; // Projection list nodes. static listnode_t* firstNode, *cursorNode; @@ -147,12 +147,12 @@ static lumlistnode_t* allocListNode(void) return ln; } -static void linkLumObjToSSec(lumobj_t* lum, subsector_t* ssec) +static void linkLumObjToSSec(lumobj_t* lum, BspLeaf* bspLeaf) { lumlistnode_t* ln = allocListNode(); lumlistnode_t** root; - root = &subLumObjList[GET_SUBSECTOR_IDX(ssec)]; + root = &bspLeafLumObjList[GET_BSPLEAF_IDX(bspLeaf)]; ln->next = *root; ln->data = lum; *root = ln; @@ -524,8 +524,8 @@ static int projectOmniLightToSurface(lumobj_t* lum, void* paramaters) void LO_InitForMap(void) { - // First initialize the subsector links (root pointers). - subLumObjList = Z_Calloc(sizeof(*subLumObjList) * NUM_SUBSECTORS, PU_MAPSTATIC, 0); + // First initialize the BSP leaf links (root pointers). + bspLeafLumObjList = Z_Calloc(sizeof(*bspLeafLumObjList) * NUM_BSPLEAFS, PU_MAPSTATIC, 0); maxLuminous = 0; luminousBlockSet = 0; // Will have already been free'd. @@ -573,8 +573,8 @@ void LO_BeginWorldFrame(void) // Start reusing nodes from the first one in the list. listNodeCursor = listNodeFirst; - if(subLumObjList) - memset(subLumObjList, 0, sizeof(lumlistnode_t*) * NUM_SUBSECTORS); + if(bspLeafLumObjList) + memset(bspLeafLumObjList, 0, sizeof(lumlistnode_t*) * NUM_BSPLEAFS); numLuminous = 0; } @@ -625,13 +625,13 @@ static lumobj_t* allocLumobj(void) #undef LUMOBJ_BATCH_SIZE } -static lumobj_t* createLuminous(lumtype_t type, subsector_t* ssec) +static lumobj_t* createLuminous(lumtype_t type, BspLeaf* bspLeaf) { lumobj_t* lum = allocLumobj(); lum->type = type; - lum->subsector = ssec; - linkLumObjToSSec(lum, ssec); + lum->bspLeaf = bspLeaf; + linkLumObjToSSec(lum, bspLeaf); if(type != LT_PLANE) R_ObjlinkCreate(lum, OT_LUMOBJ); // For spreading purposes. @@ -639,9 +639,9 @@ static lumobj_t* createLuminous(lumtype_t type, subsector_t* ssec) return lum; } -uint LO_NewLuminous(lumtype_t type, subsector_t* ssec) +uint LO_NewLuminous(lumtype_t type, BspLeaf* bspLeaf) { - createLuminous(type, ssec); + createLuminous(type, bspLeaf); return numLuminous; // == index + 1 } @@ -777,7 +777,7 @@ static void addLuminous(mobj_t* mo) center = -pTex->offY - mo->floorClip - R_GetBobOffset(mo) - yOffset; // Will the sprite be allowed to go inside the floor? - mul = mo->pos[VZ] + -pTex->offY - (float) ms->size.height - mo->subsector->sector->SP_floorheight; + mul = mo->pos[VZ] + -pTex->offY - (float) ms->size.height - mo->bspLeaf->sector->SP_floorheight; if(!(mo->ddFlags & DDMF_NOFITBOTTOM) && mul < 0) { // Must adjust. @@ -817,7 +817,7 @@ static void addLuminous(mobj_t* mo) // This'll allow a halo to be rendered. If the light is hidden from // view by world geometry, the light pointer will be set to NULL. - mo->lumIdx = LO_NewLuminous(LT_OMNI, mo->subsector); + mo->lumIdx = LO_NewLuminous(LT_OMNI, mo->bspLeaf); l = LO_GetLuminous(mo->lumIdx); l->maxDistance = 0; @@ -826,9 +826,9 @@ static void addLuminous(mobj_t* mo) /** * Determine the exact center point of the light. * - * \todo We cannot use smoothing here because this could move the - * light into another subsector (thereby breaking the rules of the - * optimized subsector contact/spread algorithm). + * @todo We cannot use smoothing here because this could move the + * light into another BSP leaf (thereby breaking the rules of the + * optimized BSP leaf contact/spread algorithm). V3_Set(l->pos, 0, 0, 0); if(mo->state && mo->tics >= 0) { @@ -968,13 +968,13 @@ static boolean createGlowLightForSurface(surface_t* suf, void* paramaters) const averagecolor_analysis_t* avgColorAmplified; const materialvariantspecification_t* spec; const materialsnapshot_t* ms; - linkobjtosubsectorparams_t params; + linkobjtobspleafparams_t params; lumobj_t* lum; uint i; // Only produce a light for sectors with open space. - /// @todo Do not add surfaces from sectors with zero subsectors to the glowing list. - if(!sec->subsectorCount || sec->SP_floorvisheight >= sec->SP_ceilvisheight) + /// @todo Do not add surfaces from sectors with zero BSP leafs to the glowing list. + if(!sec->bspLeafCount || sec->SP_floorvisheight >= sec->SP_ceilvisheight) return true; // Continue iteration. // Are we glowing at this moment in time? @@ -988,8 +988,8 @@ static boolean createGlowLightForSurface(surface_t* suf, void* paramaters) if(!avgColorAmplified) Con_Error("createGlowLightForSurface: Texture id:%u has no TA_COLOR_AMPLIFIED analysis.", Textures_Id(MSU_texture(ms, MTU_PRIMARY))); - // \note Plane lights do not spread so simply link to all subsectors of this sector. - lum = createLuminous(LT_PLANE, sec->subsectors[0]); + // @note Plane lights do not spread so simply link to all BspLeafs of this sector. + lum = createLuminous(LT_PLANE, sec->bspLeafs[0]); V3_Set(lum->pos, pln->soundOrg.pos[VX], pln->soundOrg.pos[VY], pln->visHeight); V3_Copy(LUM_PLANE(lum)->normal, pln->PS_normal); @@ -1001,11 +1001,11 @@ static boolean createGlowLightForSurface(surface_t* suf, void* paramaters) params.obj = lum; params.type = OT_LUMOBJ; - RIT_LinkObjToSubsector(sec->subsectors[0], (void*)¶ms); - for(i = 1; i < sec->subsectorCount; ++i) + RIT_LinkObjToBspLeaf(sec->bspLeafs[0], (void*)¶ms); + for(i = 1; i < sec->bspLeafCount; ++i) { - linkLumObjToSSec(lum, sec->subsectors[i]); - RIT_LinkObjToSubsector(sec->subsectors[i], (void*)¶ms); + linkLumObjToSSec(lum, sec->bspLeafs[i]); + RIT_LinkObjToBspLeaf(sec->bspLeafs[i], (void*)¶ms); } break; } @@ -1040,8 +1040,7 @@ BEGIN_PROF( PROF_LUMOBJ_INIT_ADD ); } } - // If the hedges of this subsector are affected by glowing planes we need - // to create dynlights and link them. + // Create dynlights for all glowing surfaces. if(useWallGlow) { surfacelist_t* slist = GameMap_GlowingSurfaces(theMap); @@ -1074,11 +1073,11 @@ int LOIT_RadiusLumobjs(void* ptr, void* paramaters) return result; } -int LO_LumobjsRadiusIterator2(subsector_t* ssec, float x, float y, float radius, +int LO_LumobjsRadiusIterator2(BspLeaf* bspLeaf, float x, float y, float radius, int (*callback) (const lumobj_t*, float distance, void* paramaters), void* paramaters) { lumobjiterparams_t p; - if(!ssec || !callback) return 0; + if(!bspLeaf || !callback) return 0; p.origin[VX] = x; p.origin[VY] = y; @@ -1086,13 +1085,13 @@ int LO_LumobjsRadiusIterator2(subsector_t* ssec, float x, float y, float radius, p.callback = callback; p.paramaters = paramaters; - return R_IterateSubsectorContacts2(ssec, OT_LUMOBJ, LOIT_RadiusLumobjs, (void*) &p); + return R_IterateBspLeafContacts2(bspLeaf, OT_LUMOBJ, LOIT_RadiusLumobjs, (void*) &p); } -int LO_LumobjsRadiusIterator(subsector_t* ssec, float x, float y, float radius, +int LO_LumobjsRadiusIterator(BspLeaf* bspLeaf, float x, float y, float radius, int (*callback) (const lumobj_t*, float distance, void* paramaters)) { - return LO_LumobjsRadiusIterator2(ssec, x, y, radius, callback, NULL); + return LO_LumobjsRadiusIterator2(bspLeaf, x, y, radius, callback, NULL); } boolean LOIT_ClipLumObj(void* data, void* context) @@ -1141,16 +1140,16 @@ boolean LOIT_ClipLumObj(void* data, void* context) return true; // Continue iteration. } -void LO_ClipInSubsector(uint ssecIdx) +void LO_ClipInBspLeaf(uint bspLeafIdx) { - iterateSubsectorLumObjs(&subsectors[ssecIdx], LOIT_ClipLumObj, NULL); + iterateBspLeafLumObjs(&bspLeafs[bspLeafIdx], LOIT_ClipLumObj, NULL); } boolean LOIT_ClipLumObjBySight(void* data, void* context) { lumobj_t* lum = (lumobj_t*) data; uint lumIdx = lumToIndex(lum); - subsector_t* ssec = (subsector_t*) context; + BspLeaf* bspLeaf = (BspLeaf*) context; if(lum->type != LT_OMNI) return true; // Only interested in omnilights. @@ -1164,9 +1163,9 @@ boolean LOIT_ClipLumObjBySight(void* data, void* context) // We need to figure out if any of the polyobj's segments lies // between the viewpoint and the lumobj. - for(i = 0; i < ssec->polyObj->lineCount; ++i) + for(i = 0; i < bspLeaf->polyObj->lineCount; ++i) { - linedef_t* line = ssec->polyObj->lines[i]; + linedef_t* line = bspLeaf->polyObj->lines[i]; HEdge* hedge = line->L_frontside->hedges[0]; // Ignore hedges facing the wrong way. @@ -1187,15 +1186,15 @@ boolean LOIT_ClipLumObjBySight(void* data, void* context) return true; // Continue iteration. } -void LO_ClipInSubsectorBySight(uint ssecIdx) +void LO_ClipInBspLeafBySight(uint bspLeafIdx) { - iterateSubsectorLumObjs(&subsectors[ssecIdx], LOIT_ClipLumObjBySight, &subsectors[ssecIdx]); + iterateBspLeafLumObjs(&bspLeafs[bspLeafIdx], LOIT_ClipLumObjBySight, &bspLeafs[bspLeafIdx]); } -static boolean iterateSubsectorLumObjs(subsector_t* ssec, boolean (*func) (void*, void*), +static boolean iterateBspLeafLumObjs(BspLeaf* bspLeaf, boolean (*func) (void*, void*), void* data) { - lumlistnode_t* ln = subLumObjList[GET_SUBSECTOR_IDX(ssec)]; + lumlistnode_t* ln = bspLeafLumObjList[GET_BSPLEAF_IDX(bspLeaf)]; while(ln) { if(!func(ln->data, data)) @@ -1244,7 +1243,7 @@ int RIT_ProjectLightToSurfaceIterator(void* obj, void* paramaters) } } -uint LO_ProjectToSurface(int flags, subsector_t* ssec, float blendFactor, +uint LO_ProjectToSurface(int flags, BspLeaf* bspLeaf, float blendFactor, vec3_t topLeft, vec3_t bottomRight, vec3_t tangent, vec3_t bitangent, vec3_t normal) { projectlighttosurfaceiteratorparams_t p; @@ -1258,7 +1257,7 @@ uint LO_ProjectToSurface(int flags, subsector_t* ssec, float blendFactor, p.spParams.bitangent = bitangent; p.spParams.normal = normal; - R_IterateSubsectorContacts2(ssec, OT_LUMOBJ, RIT_ProjectLightToSurfaceIterator, (void*)&p); + R_IterateBspLeafContacts2(bspLeaf, OT_LUMOBJ, RIT_ProjectLightToSurfaceIterator, (void*)&p); // Did we produce a projection list? return p.listIdx; } diff --git a/doomsday/engine/portable/src/r_shadow.c b/doomsday/engine/portable/src/r_shadow.c index cd5c81a11b..6fa075137a 100644 --- a/doomsday/engine/portable/src/r_shadow.c +++ b/doomsday/engine/portable/src/r_shadow.c @@ -309,7 +309,7 @@ void R_InitShadowProjectionListsForNewFrame(void) } } -uint R_ProjectShadowsToSurface(subsector_t* ssec, float blendFactor, +uint R_ProjectShadowsToSurface(BspLeaf* bspLeaf, float blendFactor, vec3_t topLeft, vec3_t bottomRight, vec3_t tangent, vec3_t bitangent, vec3_t normal) { projectshadowonsurfaceiteratorparams_t p; @@ -325,7 +325,7 @@ uint R_ProjectShadowsToSurface(subsector_t* ssec, float blendFactor, p.spParams.bitangent = bitangent; p.spParams.normal = normal; - R_IterateSubsectorContacts2(ssec, OT_MOBJ, RIT_ProjectShadowToSurfaceIterator, (void*)&p); + R_IterateBspLeafContacts2(bspLeaf, OT_MOBJ, RIT_ProjectShadowToSurfaceIterator, (void*)&p); // Did we produce a projection list? return p.listIdx; } @@ -364,9 +364,9 @@ plane_t* R_FindShadowPlane(mobj_t* mo) { plane_t* plane = NULL; assert(mo); - if(mo->subsector) + if(mo->bspLeaf) { - plane = mo->subsector->sector->SP_plane(PLN_FLOOR); + plane = mo->bspLeaf->sector->SP_plane(PLN_FLOOR); P_MobjSectorsIterator(mo, RIT_FindShadowPlaneIterator, (void*)&plane); } return plane; diff --git a/doomsday/engine/portable/src/r_things.c b/doomsday/engine/portable/src/r_things.c index a290a0e45c..a5eb556fcd 100644 --- a/doomsday/engine/portable/src/r_things.c +++ b/doomsday/engine/portable/src/r_things.c @@ -708,7 +708,7 @@ float R_ShadowStrength(mobj_t* mo) assert(mo); // Is this mobj in a valid state for shadow casting? - if(!mo->state || !mo->subsector) return 0; + if(!mo->state || !mo->bspLeaf) return 0; // Should this mobj even have a shadow? if((mo->state->flags & STF_FULLBRIGHT) || @@ -724,7 +724,7 @@ float R_ShadowStrength(mobj_t* mo) } else { - ambientLightLevel = mo->subsector->sector->lightLevel; + ambientLightLevel = mo->bspLeaf->sector->lightLevel; Rend_ApplyLightAdaptation(&ambientLightLevel); } @@ -878,12 +878,12 @@ void R_ProjectPlayerSprites(void) spr->type = VPSPR_MODEL; - spr->data.model.subsector = ddpl->mo->subsector; + spr->data.model.bspLeaf = ddpl->mo->bspLeaf; spr->data.model.flags = 0; // 32 is the raised weapon height. spr->data.model.gzt = viewData->current.pos[VZ]; - spr->data.model.secFloor = ddpl->mo->subsector->sector->SP_floorvisheight; - spr->data.model.secCeil = ddpl->mo->subsector->sector->SP_ceilvisheight; + spr->data.model.secFloor = ddpl->mo->bspLeaf->sector->SP_floorvisheight; + spr->data.model.secCeil = ddpl->mo->bspLeaf->sector->SP_ceilvisheight; spr->data.model.pClass = 0; spr->data.model.floorClip = 0; @@ -920,7 +920,7 @@ void R_ProjectPlayerSprites(void) spr->center[VY] = viewData->current.pos[VY]; spr->center[VZ] = viewData->current.pos[VZ]; - spr->data.sprite.subsector = ddpl->mo->subsector; + spr->data.sprite.bspLeaf = ddpl->mo->bspLeaf; spr->data.sprite.alpha = psp->alpha; spr->data.sprite.isFullBright = (psp->flags & DDPSPF_FULLBRIGHT)!=0; } @@ -979,7 +979,7 @@ static void setupSpriteParamsForVisSprite(rendspriteparams_t *params, material_t* mat, boolean matFlipS, boolean matFlipT, blendmode_t blendMode, float ambientColorR, float ambientColorG, float ambientColorB, float alpha, uint vLightListIdx, - int tMap, int tClass, subsector_t* ssec, + int tMap, int tClass, BspLeaf* bspLeaf, boolean floorAdjust, boolean fitTop, boolean fitBottom, boolean viewAligned) { @@ -999,7 +999,7 @@ static void setupSpriteParamsForVisSprite(rendspriteparams_t *params, params->srvo[VY] = visOffY; params->srvo[VZ] = visOffZ; params->distance = distance; - params->subsector = ssec; + params->bspLeaf = bspLeaf; params->viewAligned = viewAligned; params->noZWrite = noSpriteZWrite; @@ -1022,7 +1022,7 @@ void setupModelParamsForVisSprite(rendmodelparams_t *params, struct modeldef_s* mf, struct modeldef_s* nextMF, float inter, float ambientColorR, float ambientColorG, float ambientColorB, float alpha, uint vLightListIdx, - int id, int selector, subsector_t* ssec, int mobjDDFlags, int tmap, + int id, int selector, BspLeaf* bspLeaf, int mobjDDFlags, int tmap, boolean viewAlign, boolean fullBright, boolean alwaysInterpolate) { @@ -1067,7 +1067,7 @@ void setupModelParamsForVisSprite(rendmodelparams_t *params, params->vLightListIdx = vLightListIdx; } -void getLightingParams(float x, float y, float z, subsector_t* ssec, +void getLightingParams(float x, float y, float z, BspLeaf* bspLeaf, float distance, boolean fullBright, float ambientColor[3], uint* vLightListIdx) { @@ -1090,8 +1090,8 @@ void getLightingParams(float x, float y, float z, subsector_t* ssec, } else { - float lightLevel = ssec->sector->lightLevel; - const float* secColor = R_GetSectorLightColor(ssec->sector); + float lightLevel = bspLeaf->sector->lightLevel; + const float* secColor = R_GetSectorLightColor(bspLeaf->sector); /* if(spr->type == VSPR_DECORATION) { @@ -1119,7 +1119,7 @@ void getLightingParams(float x, float y, float z, subsector_t* ssec, lparams.center[VX] = x; lparams.center[VY] = y; lparams.center[VZ] = z; - lparams.subsector = ssec; + lparams.bspLeaf = bspLeaf; lparams.ambientColor = ambientColor; *vLightListIdx = R_CollectAffectingLights(&lparams); @@ -1131,7 +1131,7 @@ void getLightingParams(float x, float y, float z, subsector_t* ssec, */ void R_ProjectSprite(mobj_t* mo) { - sector_t* sect = mo->subsector->sector; + sector_t* sect = mo->bspLeaf->sector; float thangle = 0, alpha, floorClip, secFloor, secCeil; float pos[2], yaw = 0, pitch = 0; vec3_t visOff; @@ -1323,8 +1323,8 @@ void R_ProjectSprite(mobj_t* mo) viewAlign = (align || alwaysAlign == 3)? true : false; fullBright = ((mo->state->flags & STF_FULLBRIGHT) || levelFullBright)? true : false; - secFloor = mo->subsector->sector->SP_floorvisheight; - secCeil = mo->subsector->sector->SP_ceilvisheight; + secFloor = mo->bspLeaf->sector->SP_floorvisheight; + secCeil = mo->bspLeaf->sector->SP_ceilvisheight; // Foot clipping. floorClip = mo->floorClip; @@ -1437,7 +1437,7 @@ void R_ProjectSprite(mobj_t* mo) getLightingParams(vis->center[VX], vis->center[VY], gzt - ms->size.height / 2.0f, - mo->subsector, vis->distance, fullBright, + mo->bspLeaf, vis->distance, fullBright, ambientColor, &vLightListIdx); setupSpriteParamsForVisSprite(&vis->data.sprite, @@ -1451,7 +1451,7 @@ void R_ProjectSprite(mobj_t* mo) vLightListIdx, tmap, tclass, - mo->subsector, + mo->bspLeaf, floorAdjust, fitTop, fitBottom, @@ -1460,7 +1460,7 @@ void R_ProjectSprite(mobj_t* mo) else { getLightingParams(vis->center[VX], vis->center[VY], vis->center[VZ], - mo->subsector, vis->distance, fullBright, + mo->bspLeaf, vis->distance, fullBright, ambientColor, &vLightListIdx); setupModelParamsForVisSprite(&vis->data.model, @@ -1469,7 +1469,7 @@ void R_ProjectSprite(mobj_t* mo) mf, nextmf, interp, ambientColor[CR], ambientColor[CG], ambientColor[CB], alpha, vLightListIdx, mo->thinker.id, mo->selector, - mo->subsector, mo->ddFlags, + mo->bspLeaf, mo->ddFlags, mo->tmap, viewAlign, fullBright && !(mf && (mf->sub[0].flags & MFF_DIM)), @@ -1570,14 +1570,14 @@ void R_ProjectSprite(mobj_t* mo) } typedef struct { - subsector_t* subsector; + BspLeaf* bspLeaf; } addspriteparams_t; int RIT_AddSprite(void* ptr, void* paramaters) { mobj_t* mo = (mobj_t*) ptr; addspriteparams_t* params = (addspriteparams_t*)paramaters; - sector_t* sec = params->subsector->sector; + sector_t* sec = params->bspLeaf->sector; if(mo->addFrameCount != frameCount) { @@ -1608,18 +1608,18 @@ int RIT_AddSprite(void* ptr, void* paramaters) return false; // Continue iteration. } -void R_AddSprites(subsector_t* ssec) +void R_AddSprites(BspLeaf* bspLeaf) { addspriteparams_t params; // Do not use validCount because other parts of the renderer may change it. - if(ssec->addSpriteCount == frameCount) + if(bspLeaf->addSpriteCount == frameCount) return; // Already added. - params.subsector = ssec; - R_IterateSubsectorContacts2(ssec, OT_MOBJ, RIT_AddSprite, ¶ms); + params.bspLeaf = bspLeaf; + R_IterateBspLeafContacts2(bspLeaf, OT_MOBJ, RIT_AddSprite, ¶ms); - ssec->addSpriteCount = frameCount; + bspLeaf->addSpriteCount = frameCount; } void R_SortVisSprites(void) @@ -1859,7 +1859,7 @@ uint R_CollectAffectingLights(const collectaffectinglights_params_t* params) linkVLightNodeToList(node, vLightListIdx); // Add extra light by interpreting lumobjs into vlights. - if(loInited && params->subsector) + if(loInited && params->bspLeaf) { vlightiterparams_t vars; @@ -1869,7 +1869,7 @@ uint R_CollectAffectingLights(const collectaffectinglights_params_t* params) vars.haveList = true; vars.listIdx = vLightListIdx; - LO_LumobjsRadiusIterator2(params->subsector, params->center[VX], params->center[VY], + LO_LumobjsRadiusIterator2(params->bspLeaf, params->center[VX], params->center[VY], (float) loMaxRadius, RIT_VisSpriteLightIterator, (void*)&vars); } diff --git a/doomsday/engine/portable/src/r_world.c b/doomsday/engine/portable/src/r_world.c index c5c96acba1..d021b27090 100644 --- a/doomsday/engine/portable/src/r_world.c +++ b/doomsday/engine/portable/src/r_world.c @@ -605,36 +605,36 @@ plane_t* R_NewPlaneForSector(sector_t* sec) Surface_SetBlendMode(suf, BM_NORMAL); /** - * Resize the biassurface lists for the subsector planes. + * Resize the biassurface lists for the BSP leaf planes. * If we are in map setup mode, don't create the biassurfaces now, * as planes are created before the bias system is available. */ - if(sec->subsectors && *sec->subsectors) + if(sec->bspLeafs && *sec->bspLeafs) { - subsector_t** ssecIter = sec->subsectors; + BspLeaf** ssecIter = sec->bspLeafs; do { - subsector_t* ssec = *ssecIter; + BspLeaf* bspLeaf = *ssecIter; biassurface_t** newList; uint n = 0; newList = Z_Calloc(sec->planeCount * sizeof(biassurface_t*), PU_MAP, NULL); // Copy the existing list? - if(ssec->bsuf) + if(bspLeaf->bsuf) { for(; n < sec->planeCount - 1; ++n) { - newList[n] = ssec->bsuf[n]; + newList[n] = bspLeaf->bsuf[n]; } - Z_Free(ssec->bsuf); + Z_Free(bspLeaf->bsuf); } if(!ddMapSetup) { biassurface_t* bsuf = SB_CreateSurface(); - bsuf->size = ssec->numVertices; + bsuf->size = bspLeaf->numVertices; bsuf->illum = Z_Calloc(sizeof(vertexillum_t) * bsuf->size, PU_MAP, 0); { uint i; @@ -645,7 +645,7 @@ plane_t* R_NewPlaneForSector(sector_t* sec) newList[n] = bsuf; } - ssec->bsuf = newList; + bspLeaf->bsuf = newList; ssecIter++; } while(*ssecIter); @@ -664,7 +664,7 @@ plane_t* R_NewPlaneForSector(sector_t* sec) void R_DestroyPlaneOfSector(uint id, sector_t* sec) { plane_t* plane, **newList = NULL; - subsector_t** ssecIter; + BspLeaf** ssecIter; surfacelist_t* slist; planelist_t* plist; uint i; @@ -711,13 +711,13 @@ void R_DestroyPlaneOfSector(uint id, sector_t* sec) if(slist) R_SurfaceListRemove(slist, &plane->surface); // Destroy the biassurfaces for this plane. - ssecIter = sec->subsectors; + ssecIter = sec->bspLeafs; while(*ssecIter) { - subsector_t* ssec = *ssecIter; - SB_DestroySurface(ssec->bsuf[id]); + BspLeaf* bspLeaf = *ssecIter; + SB_DestroySurface(bspLeaf->bsuf[id]); if(id < sec->planeCount) - memmove(ssec->bsuf + id, ssec->bsuf + id + 1, sizeof(biassurface_t*)); + memmove(bspLeaf->bsuf + id, bspLeaf->bsuf + id + 1, sizeof(biassurface_t*)); ssecIter++; } @@ -1094,12 +1094,12 @@ linedef_t *R_FindLineAlignNeighbor(const sector_t *sec, } /** - * Create a list of map space vertices for the subsector which are suitable for + * Create a list of map space vertices for the BspLeaf which are suitable for * use as the points of a trifan primitive. * * Note that we do not want any overlapping or zero-area (degenerate) triangles. * - * We are assured by the node build process that subsector->hedges has been ordered + * We are assured by the node build process that BspLeaf->hedges has been ordered * by angle, clockwise starting from the smallest angle. So, most of the time, the * points can be created directly from the hedge vertices. * @@ -1111,10 +1111,10 @@ linedef_t *R_FindLineAlignNeighbor(const sector_t *sec, * * If a vertex exists which results in no zero-area triangles it is suitable for * use as the center of our trifan. If a suitable vertex is not found then the - * center of subsector should be selected instead (it will always be valid as - * subsectors are convex). + * center of BSP leaf should be selected instead (it will always be valid as + * BSP leafs are convex). */ -static void tessellateSubsector(subsector_t* ssec, boolean force) +static void tessellateBspLeaf(BspLeaf* bspLeaf, boolean force) { #define MIN_TRIANGLE_EPSILON (0.1) ///< Area @@ -1122,32 +1122,32 @@ static void tessellateSubsector(subsector_t* ssec, boolean force) boolean ok = false; // Already built? - if(ssec->vertices && !force) return; + if(bspLeaf->vertices && !force) return; // Destroy any pre-existing data. - if(ssec->vertices) + if(bspLeaf->vertices) { - Z_Free(ssec->vertices); - ssec->vertices = NULL; + Z_Free(bspLeaf->vertices); + bspLeaf->vertices = NULL; } - ssec->flags &= ~SUBF_MIDPOINT; + bspLeaf->flags &= ~BLF_MIDPOINT; // Search for a good base. - if(ssec->hedgeCount > 3) + if(bspLeaf->hedgeCount > 3) { - // Subsectors with higher vertex counts demand checking. + // BspLeafs with higher vertex counts demand checking. fvertex_t* base, *a, *b; baseIDX = 0; do { - HEdge* hedge = ssec->hedges[baseIDX]; + HEdge* hedge = bspLeaf->hedges[baseIDX]; base = &hedge->HE_v1->v; i = 0; do { - HEdge* hedge2 = ssec->hedges[i]; + HEdge* hedge2 = bspLeaf->hedges[i]; // Test this triangle? if(!(baseIDX > 0 && (i == baseIDX || i == baseIDX - 1))) @@ -1164,14 +1164,14 @@ static void tessellateSubsector(subsector_t* ssec, boolean force) // On to the next triangle. i++; - } while(base && i < ssec->hedgeCount); + } while(base && i < bspLeaf->hedgeCount); if(!base) { // No good. Select the next vertex and start over. baseIDX++; } - } while(!base && baseIDX < ssec->hedgeCount); + } while(!base && baseIDX < bspLeaf->hedgeCount); // Did we find something suitable? if(base) ok = true; @@ -1182,45 +1182,45 @@ static void tessellateSubsector(subsector_t* ssec, boolean force) ok = true; } - ssec->numVertices = ssec->hedgeCount; + bspLeaf->numVertices = bspLeaf->hedgeCount; if(!ok) { // We'll use the midpoint. - ssec->flags |= SUBF_MIDPOINT; - ssec->numVertices += 2; + bspLeaf->flags |= BLF_MIDPOINT; + bspLeaf->numVertices += 2; } // Construct the vertex list. - ssec->vertices = Z_Malloc(sizeof(fvertex_t*) * (ssec->numVertices + 1), PU_MAP, 0); + bspLeaf->vertices = Z_Malloc(sizeof(fvertex_t*) * (bspLeaf->numVertices + 1), PU_MAP, 0); n = 0; // If this is a trifan the first vertex is always the midpoint. - if(ssec->flags & SUBF_MIDPOINT) + if(bspLeaf->flags & BLF_MIDPOINT) { - ssec->vertices[n++] = &ssec->midPoint; + bspLeaf->vertices[n++] = &bspLeaf->midPoint; } // Add the vertices for each hedge. - for(i = 0; i < ssec->hedgeCount; ++i) + for(i = 0; i < bspLeaf->hedgeCount; ++i) { HEdge* hedge; uint idx; idx = baseIDX + i; - if(idx >= ssec->hedgeCount) - idx = idx - ssec->hedgeCount; // Wrap around. + if(idx >= bspLeaf->hedgeCount) + idx = idx - bspLeaf->hedgeCount; // Wrap around. - hedge = ssec->hedges[idx]; - ssec->vertices[n++] = &hedge->HE_v1->v; + hedge = bspLeaf->hedges[idx]; + bspLeaf->vertices[n++] = &hedge->HE_v1->v; } // If this is a trifan the last vertex is always equal to the first. - if(ssec->flags & SUBF_MIDPOINT) + if(bspLeaf->flags & BLF_MIDPOINT) { - ssec->vertices[n++] = &ssec->hedges[0]->HE_v1->v; + bspLeaf->vertices[n++] = &bspLeaf->hedges[0]->HE_v1->v; } - ssec->vertices[n] = NULL; // terminate. + bspLeaf->vertices[n] = NULL; // terminate. #undef MIN_TRIANGLE_EPSILON } @@ -1230,10 +1230,10 @@ void R_PolygonizeMap(GameMap* map) uint startTime = Sys_GetRealTime(); uint i; - for(i = 0; i < map->numSubsectors; ++i) + for(i = 0; i < map->numBspLeafs; ++i) { - subsector_t* ssec = &map->subsectors[i]; - tessellateSubsector(ssec, true/*force rebuild*/); + BspLeaf* bspLeaf = &map->bspLeafs[i]; + tessellateBspLeaf(bspLeaf, true/*force rebuild*/); } // How much time did we spend? @@ -1246,7 +1246,7 @@ void R_PolygonizeMap(GameMap* map) } /** - * The test is done on subsectors. + * The test is done on BSP leafs. */ #if 0 /* Currently unused. */ static sector_t *getContainingSectorOf(GameMap* map, sector_t* sec) @@ -1470,10 +1470,10 @@ void R_SetupMap(int mode, int flags) ddpl->inVoid = true; if(ddpl->mo) { - subsector_t* ssec = P_SubsectorAtPointXY(ddpl->mo->pos[VX], ddpl->mo->pos[VY]); + BspLeaf* bspLeaf = P_BspLeafAtPointXY(ddpl->mo->pos[VX], ddpl->mo->pos[VY]); /// @fixme $nplanes - if(ssec && ddpl->mo->pos[VZ] >= ssec->sector->SP_floorvisheight && ddpl->mo->pos[VZ] < ssec->sector->SP_ceilvisheight - 4) + if(bspLeaf && ddpl->mo->pos[VZ] >= bspLeaf->sector->SP_floorvisheight && ddpl->mo->pos[VZ] < bspLeaf->sector->SP_ceilvisheight - 4) ddpl->inVoid = false; } } @@ -1684,7 +1684,7 @@ boolean R_UpdatePlane(plane_t* pln, boolean forceUpdate) // Geometry change? if(forceUpdate || pln->height != pln->oldHeight[1]) { - subsector_t** ssecIter; + BspLeaf** ssecIter; // Check if there are any camera players in this sector. If their // height is now above the ceiling/below the floor they are now in @@ -1695,11 +1695,11 @@ boolean R_UpdatePlane(plane_t* pln, boolean forceUpdate) player_t* plr = &ddPlayers[i]; ddplayer_t* ddpl = &plr->shared; - if(!ddpl->inGame || !ddpl->mo || !ddpl->mo->subsector) + if(!ddpl->inGame || !ddpl->mo || !ddpl->mo->bspLeaf) continue; //// \fixme $nplanes - if((ddpl->flags & DDPF_CAMERA) && ddpl->mo->subsector->sector == sec && + if((ddpl->flags & DDPF_CAMERA) && ddpl->mo->bspLeaf->sector == sec && (ddpl->mo->pos[VZ] > sec->SP_ceilheight - 4 || ddpl->mo->pos[VZ] < sec->SP_floorheight)) { ddpl->inVoid = true; @@ -1710,13 +1710,13 @@ boolean R_UpdatePlane(plane_t* pln, boolean forceUpdate) pln->soundOrg.pos[VZ] = pln->height; // Inform the shadow bias of changed geometry. - if(sec->subsectors && *sec->subsectors) + if(sec->bspLeafs && *sec->bspLeafs) { - ssecIter = sec->subsectors; + ssecIter = sec->bspLeafs; do { - subsector_t* ssec = *ssecIter; - HEdge** hedgeIter = ssec->hedges; + BspLeaf* bspLeaf = *ssecIter; + HEdge** hedgeIter = bspLeaf->hedges; while(*hedgeIter) { HEdge* hedge = *hedgeIter; @@ -1729,7 +1729,7 @@ boolean R_UpdatePlane(plane_t* pln, boolean forceUpdate) hedgeIter++; } - SB_SurfaceMoved(ssec->bsuf[pln->planeID]); + SB_SurfaceMoved(bspLeaf->bsuf[pln->planeID]); ssecIter++; } while(*ssecIter); } @@ -1747,7 +1747,7 @@ boolean R_UpdatePlane(plane_t* pln, boolean forceUpdate) /** * Stub. */ -boolean R_UpdateSubsector(subsector_t* ssec, boolean forceUpdate) +boolean R_UpdateBspLeaf(BspLeaf* bspLeaf, boolean forceUpdate) { return false; // Not changed. } diff --git a/doomsday/engine/portable/src/rend_bias.c b/doomsday/engine/portable/src/rend_bias.c index 75e51d41d1..b8b888aaad 100644 --- a/doomsday/engine/portable/src/rend_bias.c +++ b/doomsday/engine/portable/src/rend_bias.c @@ -368,13 +368,13 @@ void SB_InitForMap(const char* uniqueID) for(i = 0; i < NUM_SECTORS; ++i) { sector_t* sec = §ors[i]; - if(sec->subsectors && *sec->subsectors) + if(sec->bspLeafs && *sec->bspLeafs) { - subsector_t** ssecIter = sec->subsectors; + BspLeaf** ssecIter = sec->bspLeafs; do { - subsector_t* ssec = *ssecIter; - numVertIllums += ssec->numVertices * sec->planeCount; + BspLeaf* bspLeaf = *ssecIter; + numVertIllums += bspLeaf->numVertices * sec->planeCount; ssecIter++; } while(*ssecIter); } @@ -415,23 +415,23 @@ void SB_InitForMap(const char* uniqueID) for(i = 0; i < NUM_SECTORS; ++i) { sector_t* sec = §ors[i]; - if(sec->subsectors && *sec->subsectors) + if(sec->bspLeafs && *sec->bspLeafs) { - subsector_t** ssecIter = sec->subsectors; + BspLeaf** ssecIter = sec->bspLeafs; do { - subsector_t* ssec = *ssecIter; + BspLeaf* bspLeaf = *ssecIter; uint j; for(j = 0; j < sec->planeCount; ++j) { biassurface_t* bsuf = SB_CreateSurface(); - bsuf->size = ssec->numVertices; + bsuf->size = bspLeaf->numVertices; bsuf->illum = illums; - illums += ssec->numVertices; + illums += bspLeaf->numVertices; - ssec->bsuf[j] = bsuf; + bspLeaf->bsuf[j] = bsuf; } ssecIter++; } while(*ssecIter); @@ -641,7 +641,7 @@ static void updateAffected2(biassurface_t* bsuf, const struct rvertex_s* rvertic if(src->intensity <= 0) continue; - // Calculate minimum 2D distance to the subsector. + // Calculate minimum 2D distance to the BSP leaf. /// @fixme This is probably too accurate an estimate. for(k = 0; k < bsuf->size; ++k) { @@ -781,7 +781,7 @@ BEGIN_PROF( PROF_BIAS_UPDATE ); sector_t* sector; float oldIntensity = s->intensity; - sector = P_SubsectorAtPointXY(s->pos[VX], s->pos[VY])->sector; + sector = P_BspLeafAtPointXY(s->pos[VX], s->pos[VY])->sector; // The lower intensities are useless for light emission. if(sector->lightLevel >= maxLevel) @@ -923,9 +923,9 @@ static boolean SB_CheckColorOverride(biasaffection_t *affected) * @param numVertices Number of vertices (in the array) to be lit. * @param normal Surface normal. * @param sectorLightLevel Sector light level. - * @param mapObject Ptr to either a hedge or subsector. - * @param elmIdx Used with subsectors to select a specific plane. - * @param isHEdge @c true, if @a mapObject is a HEdge ELSE a Subsector. + * @param mapObject Ptr to either a HEdge or BspLeaf. + * @param elmIdx Used with BspLeafs to select a specific plane. + * @param isHEdge @c true, if @a mapObject is a HEdge ELSE a BspLeaf. */ void SB_RendPoly(struct ColorRawf_s* rcolors, biassurface_t* bsuf, const struct rvertex_s* rvertices, @@ -970,11 +970,11 @@ void SB_RendPoly(struct ColorRawf_s* rcolors, biassurface_t* bsuf, } else { - subsector_t* ssec = (subsector_t*) mapObject; + BspLeaf* bspLeaf = (BspLeaf*) mapObject; vec3_t point; - V3_Set(point, ssec->midPoint.pos[VX], ssec->midPoint.pos[VY], - ssec->sector->planes[elmIdx]->height); + V3_Set(point, bspLeaf->midPoint.pos[VX], bspLeaf->midPoint.pos[VY], + bspLeaf->sector->planes[elmIdx]->height); updateAffected2(bsuf, rvertices, numVertices, point, normal); } diff --git a/doomsday/engine/portable/src/rend_clip.c b/doomsday/engine/portable/src/rend_clip.c index 5fbb545496..06ba4c99fa 100644 --- a/doomsday/engine/portable/src/rend_clip.c +++ b/doomsday/engine/portable/src/rend_clip.c @@ -26,7 +26,7 @@ * Angle Clipper (clipnodes and oranges). * * The idea is to keep track of occluded angles around the camera. - * Since subsectors are rendered front-to-back, the occlusion lists + * Since BSP leafs are rendered front-to-back, the occlusion lists * start a frame empty and eventually fill up to cover the whole 360 * degrees around the camera. * @@ -990,7 +990,7 @@ boolean C_IsPointOccluded(float *viewrelpoint) /** * Returns true if the point is visible after checking both the clipnodes * and the occlusion planes. Note that this test can only be done with - * points that reside in subsectors that have not yet been rendered. + * points that reside in BSP leafs that have not yet been rendered. */ boolean C_IsPointVisible(float x, float y, float height) { @@ -1267,21 +1267,19 @@ clipnode_t *C_AngleClippedBy(binangle_t bang) } /** - * @return Non-zero if the subsector might be visible. + * @return Non-zero if the BspLeaf might be visible. */ -int C_CheckSubsector(subsector_t* ssec) +int C_CheckBspLeaf(BspLeaf* bspLeaf) { - uint i; - HEdge **ptr; + HEdge** ptr; + uint i; - if(!ssec || ssec->hedgeCount < 3) - return 0; + if(!bspLeaf || bspLeaf->hedgeCount < 3) return 0; - if(devNoCulling) - return 1; + if(devNoCulling) return 1; // Do we need to resize the angle list buffer? - if(ssec->hedgeCount > anglistSize) + if(bspLeaf->hedgeCount > anglistSize) { anglistSize *= 2; if(!anglistSize) @@ -1291,7 +1289,7 @@ int C_CheckSubsector(subsector_t* ssec) Z_Realloc(anglist, sizeof(binangle_t) * anglistSize, PU_APPSTATIC); } - ptr = ssec->hedges; + ptr = bspLeaf->hedges; i = 0; while(*ptr) // Angles to all corners. { @@ -1304,7 +1302,7 @@ int C_CheckSubsector(subsector_t* ssec) } // Check each of the ranges defined by the edges. - for(i = 0; i < ssec->hedgeCount - 1; ++i) + for(i = 0; i < bspLeaf->hedgeCount - 1; ++i) { uint end = i + 1; binangle_t angLen; @@ -1314,10 +1312,10 @@ int C_CheckSubsector(subsector_t* ssec) // always already covered by the previous edges. (Right?) // If even one of the edges is not contained by a clipnode, - // the subsector is at least partially visible. + // the leaf is at least partially visible. angLen = anglist[end] - anglist[i]; - // The viewer is on an edge, the subsector should be visible. + // The viewer is on an edge, the leaf should be visible. if(angLen == BANG_180) return 1; @@ -1334,7 +1332,7 @@ int C_CheckSubsector(subsector_t* ssec) } } - // All clipped away, the subsector cannot be seen. + // All clipped away, the leaf cannot be seen. return 0; } diff --git a/doomsday/engine/portable/src/rend_decor.c b/doomsday/engine/portable/src/rend_decor.c index de8ff4b570..5c2bbd760c 100644 --- a/doomsday/engine/portable/src/rend_decor.c +++ b/doomsday/engine/portable/src/rend_decor.c @@ -58,7 +58,7 @@ typedef struct decorsource_s { float pos[3]; float maxDistance; const surface_t* surface; - subsector_t* subsector; + BspLeaf* bspLeaf; unsigned int lumIdx; // index+1 of linked lumobj, or 0. float fadeMul; const ded_decorlight_t* def; @@ -109,7 +109,7 @@ static void clearDecorations(void) sourceCursor = sourceFirst; } -extern void getLightingParams(float x, float y, float z, subsector_t* ssec, +extern void getLightingParams(float x, float y, float z, BspLeaf* bspLeaf, float distance, boolean fullBright, float ambientColor[3], uint* lightListIdx); @@ -124,7 +124,7 @@ static void projectDecoration(decorsource_t* src) min = src->def->lightLevels[0]; max = src->def->lightLevels[1]; - if(!((brightness = R_CheckSectorLight(src->subsector->sector->lightLevel, min, max)) > 0)) + if(!((brightness = R_CheckSectorLight(src->bspLeaf->sector->lightLevel, min, max)) > 0)) return; if(src->fadeMul <= 0) @@ -236,7 +236,7 @@ static void addLuminousDecoration(decorsource_t* src) min = def->lightLevels[0]; max = def->lightLevels[1]; - if(!((brightness = R_CheckSectorLight(src->subsector->sector->lightLevel, min, max)) > 0)) + if(!((brightness = R_CheckSectorLight(src->bspLeaf->sector->lightLevel, min, max)) > 0)) return; // Apply the brightness factor (was calculated using sector lightlevel). @@ -247,11 +247,11 @@ static void addLuminousDecoration(decorsource_t* src) return; /** - * \todo From here on is pretty much the same as LO_AddLuminous, - * reconcile the two. + * @todo From here on is pretty much the same as LO_AddLuminous, + * reconcile the two. */ - lumIdx = LO_NewLuminous(LT_OMNI, src->subsector); + lumIdx = LO_NewLuminous(LT_OMNI, src->bspLeaf); l = LO_GetLuminous(lumIdx); l->pos[VX] = src->pos[VX]; @@ -329,7 +329,7 @@ static decorsource_t* addDecoration(void) src->lumIdx = 0; src->maxDistance = 0; src->pos[VX] = src->pos[VY] = src->pos[VZ] = 0; - src->subsector = 0; + src->bspLeaf = 0; src->surface = 0; src->def = NULL; src->flareTex = 0; @@ -358,11 +358,11 @@ static void createDecorSource(const surface_t* suf, const surfacedecor_t* dec, c src->pos[VY] = dec->pos[VY]; src->pos[VZ] = dec->pos[VZ]; src->maxDistance = maxDistance; - src->subsector = dec->subsector; + src->bspLeaf = dec->bspLeaf; src->surface = suf; src->fadeMul = 1; src->def = dec->def; - if(NULL != src->def) + if(src->def) { const ded_decorlight_t* def = src->def; if(!def->flare || Str_CompareIgnoreCase(Uri_Path(def->flare), "-")) @@ -484,7 +484,7 @@ static uint generateDecorLights(const ded_decorlight_t* def, surface_t* suf, if(d) { V3_Copy(d->pos, pos); - d->subsector = P_SubsectorAtPointXY(d->pos[VX], d->pos[VY]); + d->bspLeaf = P_BspLeafAtPointXY(d->pos[VX], d->pos[VY]); d->def = def; num++; } diff --git a/doomsday/engine/portable/src/rend_fakeradio.c b/doomsday/engine/portable/src/rend_fakeradio.c index fdc85b677b..174bf8a819 100644 --- a/doomsday/engine/portable/src/rend_fakeradio.c +++ b/doomsday/engine/portable/src/rend_fakeradio.c @@ -1305,7 +1305,7 @@ static void addShadowEdge(vec2_t inner[2], vec2_t outer[2], float innerLeftZ, RL_AddPoly(PT_FAN, RPF_DEFAULT | (!renderWireframe? RPF_SHADOW : 0), 4, rvertices, rcolors); } -static void processEdgeShadow(const subsector_t* ssec, const linedef_t* lineDef, +static void processEdgeShadow(const BspLeaf* bspLeaf, const linedef_t* lineDef, uint side, uint planeId, float shadowDark) { const sidedef_t* sideDef = lineDef->L_side(side? BACK : FRONT); @@ -1318,7 +1318,7 @@ static void processEdgeShadow(const subsector_t* ssec, const linedef_t* lineDef, const surface_t* suf; vec3_t shadowRGB; int i; - assert(ssec && lineDef && (side == FRONT || side == BACK) && lineDef->L_side(side) && planeId <= lineDef->L_sector(side)->planeCount); + assert(bspLeaf && lineDef && (side == FRONT || side == BACK) && lineDef->L_side(side) && planeId <= lineDef->L_sector(side)->planeCount); if(!(shadowDark > .0001)) return; @@ -1374,7 +1374,7 @@ static void processEdgeShadow(const subsector_t* ssec, const linedef_t* lineDef, if(neighbor != lineDef && !neighbor->L_backside && neighbor->buildData.windowEffect && - neighbor->L_frontsector != ssec->sector) + neighbor->L_frontsector != bspLeaf->sector) { // A one-way window, edgeOpen side. sideOpen[i] = 1; } @@ -1431,22 +1431,22 @@ static void processEdgeShadow(const subsector_t* ssec, const linedef_t* lineDef, addShadowEdge(inner, outer, plnHeight, plnHeight, plnHeight, plnHeight, sideOpen, edgeOpen, suf->normal[VZ] > 0, shadowRGB, shadowDark); } -static void drawLinkedEdgeShadows(const subsector_t* ssec, shadowlink_t* link, +static void drawLinkedEdgeShadows(const BspLeaf* bspLeaf, shadowlink_t* link, const byte* doPlanes, float shadowDark) { uint pln; - assert(ssec && link && doPlanes); + assert(bspLeaf && link && doPlanes); if(!(shadowDark > .0001f)) return; if(doPlanes[PLN_FLOOR]) - processEdgeShadow(ssec, link->lineDef, link->side, PLN_FLOOR, shadowDark); + processEdgeShadow(bspLeaf, link->lineDef, link->side, PLN_FLOOR, shadowDark); if(doPlanes[PLN_CEILING]) - processEdgeShadow(ssec, link->lineDef, link->side, PLN_CEILING, shadowDark); + processEdgeShadow(bspLeaf, link->lineDef, link->side, PLN_CEILING, shadowDark); - for(pln = PLN_MID; pln < ssec->sector->planeCount; ++pln) + for(pln = PLN_MID; pln < bspLeaf->sector->planeCount; ++pln) { - processEdgeShadow(ssec, link->lineDef, link->side, pln, shadowDark); + processEdgeShadow(bspLeaf, link->lineDef, link->side, pln, shadowDark); } // Mark it rendered for this frame. @@ -1454,18 +1454,18 @@ static void drawLinkedEdgeShadows(const subsector_t* ssec, shadowlink_t* link, } /** - * Render the shadowpolygons linked to the subsector, if they haven't + * Render the shadowpolygons linked to the BspLeaf, if they haven't * already been rendered. * - * Don't use the global radio state in here, the subsector can be part of + * Don't use the global radio state in here, the BSP leaf can be part of * any sector, not the one chosen for wall rendering. */ -static void radioSubsectorEdges(const subsector_t* subsector) +static void radioBspLeafEdges(const BspLeaf* bspLeaf) { static size_t doPlaneSize = 0; static byte* doPlanes = NULL; - float sectorlight = subsector->sector->lightLevel; + float sectorlight = bspLeaf->sector->lightLevel; float shadowWallSize, shadowDark; boolean workToDo = false; float vec[3]; @@ -1483,12 +1483,12 @@ static void radioSubsectorEdges(const subsector_t* subsector) // Any need to continue? if(!(shadowDark > .0001f)) return; - vec[VX] = vx - subsector->midPoint.pos[VX]; - vec[VY] = vz - subsector->midPoint.pos[VY]; + vec[VX] = vx - bspLeaf->midPoint.pos[VX]; + vec[VY] = vz - bspLeaf->midPoint.pos[VY]; vec[VZ] = 0; // Do we need to enlarge the size of the doPlanes array? - if(subsector->sector->planeCount > doPlaneSize) + if(bspLeaf->sector->planeCount > doPlaneSize) { if(!doPlaneSize) doPlaneSize = 2; @@ -1500,11 +1500,11 @@ static void radioSubsectorEdges(const subsector_t* subsector) memset(doPlanes, 0, doPlaneSize); - // See if any of this subsector's planes will get shadows. + // See if any of this BspLeaf's planes will get shadows. { uint pln; - for(pln = 0; pln < subsector->sector->planeCount; ++pln) + for(pln = 0; pln < bspLeaf->sector->planeCount; ++pln) { - const plane_t* plane = subsector->sector->planes[pln]; + const plane_t* plane = bspLeaf->sector->planes[pln]; vec[VZ] = vy - plane->visHeight; @@ -1519,24 +1519,23 @@ static void radioSubsectorEdges(const subsector_t* subsector) if(!workToDo) return; - // We need to check all the shadow lines linked to this subsector for + // We need to check all the shadow lines linked to this BspLeaf for // the purpose of fakeradio shadowing. { shadowlink_t* link; - for(link = subsector->shadows; link != NULL; link = link->next) + for(link = bspLeaf->shadows; link != NULL; link = link->next) { // Already rendered during the current frame? We only want to // render each shadow once per frame. if(link->lineDef->shadowVisFrame[link->side] == (ushort) frameCount) continue; - drawLinkedEdgeShadows(subsector, link, doPlanes, shadowDark); + drawLinkedEdgeShadows(bspLeaf, link, doPlanes, shadowDark); }} } -void Rend_RadioSubsectorEdges(subsector_t* subsector) +void Rend_RadioBspLeafEdges(BspLeaf* bspLeaf) { - if(!rendFakeRadio || levelFullBright) - return; + if(!rendFakeRadio || levelFullBright) return; - radioSubsectorEdges(subsector); + radioBspLeafEdges(bspLeaf); } #if _DEBUG diff --git a/doomsday/engine/portable/src/rend_main.c b/doomsday/engine/portable/src/rend_main.c index da6589192f..f90be1d662 100644 --- a/doomsday/engine/portable/src/rend_main.c +++ b/doomsday/engine/portable/src/rend_main.c @@ -121,7 +121,7 @@ byte devVertexBars = 0; // @c 1= Draw world vertex position bars. byte devSurfaceVectors = 0; byte devNoTexFix = 0; -static boolean firstsubsector; // No range checking for the first one. +static boolean firstBspLeaf; // No range checking for the first one. void Rend_Register(void) { @@ -156,7 +156,7 @@ void Rend_Register(void) C_VAR_INT("rend-dev-sky", &devRendSkyMode, CVF_NO_ARCHIVE, 0, 1); C_VAR_BYTE("rend-dev-sky-always", &devRendSkyAlways, CVF_NO_ARCHIVE, 0, 1); C_VAR_BYTE("rend-dev-freeze", &freezeRLs, CVF_NO_ARCHIVE, 0, 1); - C_VAR_INT("rend-dev-cull-subsectors", &devNoCulling,CVF_NO_ARCHIVE,0,1); + C_VAR_INT("rend-dev-cull-leafs", &devNoCulling, CVF_NO_ARCHIVE,0,1); C_VAR_INT("rend-dev-mobj-bbox", &devMobjBBox, CVF_NO_ARCHIVE, 0, 1); C_VAR_BYTE("rend-dev-mobj-show-vlights", &devMobjVLights, CVF_NO_ARCHIVE, 0, 1); C_VAR_INT("rend-dev-polyobj-bbox", &devPolyobjBBox, CVF_NO_ARCHIVE, 0, 1); @@ -351,13 +351,13 @@ void Rend_VertexColorsApplyTorchLight(ColorRawf* colors, const rvertex_t* vertic } void Rend_PreparePlane(rvertex_t* rvertices, size_t numVertices, - float height, const subsector_t* subsector, boolean antiClockwise) + float height, const BspLeaf* bspLeaf, boolean antiClockwise) { size_t i, vid; // First vertex is always #0. - rvertices[0].pos[VX] = subsector->vertices[0]->pos[VX]; - rvertices[0].pos[VY] = subsector->vertices[0]->pos[VY]; + rvertices[0].pos[VX] = bspLeaf->vertices[0]->pos[VX]; + rvertices[0].pos[VY] = bspLeaf->vertices[0]->pos[VY]; rvertices[0].pos[VZ] = height; // Copy the vertices in reverse order for ceilings (flip faces). @@ -368,15 +368,15 @@ void Rend_PreparePlane(rvertex_t* rvertices, size_t numVertices, for(i = 1; i < numVertices; ++i) { - rvertices[i].pos[VX] = subsector->vertices[vid]->pos[VX]; - rvertices[i].pos[VY] = subsector->vertices[vid]->pos[VY]; + rvertices[i].pos[VX] = bspLeaf->vertices[vid]->pos[VX]; + rvertices[i].pos[VY] = bspLeaf->vertices[vid]->pos[VY]; rvertices[i].pos[VZ] = height; (antiClockwise? vid-- : vid++); } } -static void markSegSectionsPVisible(HEdge* hedge) +static void markSideDefSectionsPVisible(HEdge* hedge) { const plane_t* fceil, *bceil, *ffloor, *bfloor; sidedef_t* side; @@ -419,13 +419,13 @@ static void markSegSectionsPVisible(HEdge* hedge) side->SW_bottomsurface.inFlags &= ~SUIF_PVIS; } -static void Rend_MarkSegSectionsPVisible(HEdge* hedge) +static void Rend_MarkSideDefSectionsPVisible(HEdge* hedge) { assert(hedge); - // danij: Do we really need to do this for both sides? Surely not. - markSegSectionsPVisible(hedge); + /// @todo Do we really need to do this for both sides? Surely not. + markSideDefSectionsPVisible(hedge); if(hedge->twin) - markSegSectionsPVisible(hedge->twin); + markSideDefSectionsPVisible(hedge->twin); } /** @@ -1573,7 +1573,7 @@ static boolean doRenderSeg(HEdge* hedge, return false; // Do not clip with this. } -static void renderPlane(subsector_t* ssec, planetype_t type, float height, +static void renderPlane(BspLeaf* bspLeaf, planetype_t type, float height, vec3_t tangent, vec3_t bitangent, vec3_t normal, material_t* inMat, int sufFlags, short sufInFlags, const float sufColor[4], blendmode_t blendMode, @@ -1586,10 +1586,10 @@ static void renderPlane(subsector_t* ssec, planetype_t type, float height, { float inter = 0; rendworldpoly_params_t params; - uint numVertices = ssec->numVertices; + uint numVertices = bspLeaf->numVertices; rvertex_t* rvertices; boolean blended = false; - sector_t* sec = ssec->sector; + sector_t* sec = bspLeaf->sector; material_t* mat = NULL; const materialsnapshot_t* msA = NULL, *msB = NULL; @@ -1597,7 +1597,7 @@ static void renderPlane(subsector_t* ssec, planetype_t type, float height, params.flags = RPF_DEFAULT; params.isWall = false; - params.mapObject = ssec; + params.mapObject = bspLeaf; params.elmIdx = elmIdx; params.bsuf = bsuf; params.normal = normal; @@ -1647,7 +1647,7 @@ static void renderPlane(subsector_t* ssec, planetype_t type, float height, } rvertices = R_AllocRendVertices(numVertices); - Rend_PreparePlane(rvertices, numVertices, height, ssec, !(normal[VZ] > 0) ^ flipSurfaceNormal); + Rend_PreparePlane(rvertices, numVertices, height, bspLeaf, !(normal[VZ] > 0) ^ flipSurfaceNormal); if(!(params.flags & RPF_SKYMASK)) { @@ -1663,7 +1663,7 @@ static void renderPlane(subsector_t* ssec, planetype_t type, float height, } else { - surface_t* suf = &ssec->sector->planes[elmIdx]->surface; + surface_t* suf = &bspLeaf->sector->planes[elmIdx]->surface; const materialvariantspecification_t* spec = Materials_VariantSpecificationForContext( MC_MAPSURFACE, 0, 0, 0, 0, GL_REPEAT, GL_REPEAT, -1, -1, -1, true, true, false, false); const materialsnapshot_t* ms = Materials_Prepare(suf->material, spec, true); @@ -1673,7 +1673,7 @@ static void renderPlane(subsector_t* ssec, planetype_t type, float height, // Dynamic lights? if(addDLights && params.glowing < 1 && !(!useDynlights && !useWallGlow)) { - params.lightListIdx = LO_ProjectToSurface((PLF_NO_PLANE | (type == PLN_FLOOR? PLF_TEX_FLOOR : PLF_TEX_CEILING)), ssec, 1, + params.lightListIdx = LO_ProjectToSurface((PLF_NO_PLANE | (type == PLN_FLOOR? PLF_TEX_FLOOR : PLF_TEX_CEILING)), bspLeaf, 1, params.texTL, params.texBR, tangent, bitangent, normal); } @@ -1681,7 +1681,7 @@ static void renderPlane(subsector_t* ssec, planetype_t type, float height, if(addMobjShadows && params.glowing < 1 && Rend_MobjShadowsEnabled()) { // Glowing planes inversely diminish shadow strength. - params.shadowListIdx = R_ProjectShadowsToSurface(ssec, 1 - params.glowing, + params.shadowListIdx = R_ProjectShadowsToSurface(bspLeaf, 1 - params.glowing, params.texTL, params.texBR, tangent, bitangent, normal); } } @@ -1691,7 +1691,7 @@ static void renderPlane(subsector_t* ssec, planetype_t type, float height, R_FreeRendVertices(rvertices); } -static void Rend_RenderPlane(subsector_t* ssec, planetype_t type, float height, +static void Rend_RenderPlane(BspLeaf* bspLeaf, planetype_t type, float height, const_pvec3_t _tangent, const_pvec3_t _bitangent, const_pvec3_t _normal, material_t* inMat, int sufFlags, short sufInFlags, const float sufColor[4], blendmode_t blendMode, @@ -1705,7 +1705,7 @@ static void Rend_RenderPlane(subsector_t* ssec, planetype_t type, float height, // Must have a visible surface. if(!inMat || !Material_IsDrawable(inMat)) return; - V3_Set(vec, vx - ssec->midPoint.pos[VX], vz - ssec->midPoint.pos[VY], vy - height); + V3_Set(vec, vx - bspLeaf->midPoint.pos[VX], vz - bspLeaf->midPoint.pos[VY], vy - height); /** * Flip surface tangent space vectors according to the z positon of the viewer relative @@ -1728,18 +1728,18 @@ static void Rend_RenderPlane(subsector_t* ssec, planetype_t type, float height, float texTL[3], texBR[3]; // Set the texture origin, Y is flipped for the ceiling. - V3_Set(texTL, ssec->aaBox.minX, - ssec->aaBox.arvec2[type == PLN_FLOOR? 1 : 0][VY], height); - V3_Set(texBR, ssec->aaBox.maxX, - ssec->aaBox.arvec2[type == PLN_FLOOR? 0 : 1][VY], height); + V3_Set(texTL, bspLeaf->aaBox.minX, + bspLeaf->aaBox.arvec2[type == PLN_FLOOR? 1 : 0][VY], height); + V3_Set(texBR, bspLeaf->aaBox.maxX, + bspLeaf->aaBox.arvec2[type == PLN_FLOOR? 0 : 1][VY], height); - renderPlane(ssec, type, height, tangent, bitangent, normal, inMat, sufFlags, sufInFlags, + renderPlane(bspLeaf, type, height, tangent, bitangent, normal, inMat, sufFlags, sufInFlags, sufColor, blendMode, texTL, texBR, texOffset, texScale, skyMasked, addDLights, addMobjShadows, bsuf, elmIdx, texMode, flipNormal); } } -static boolean rendSegSection(subsector_t* ssec, HEdge* hedge, +static boolean rendSegSection(BspLeaf* bspLeaf, HEdge* hedge, sidedefsection_t section, surface_t* surface, const fvertex_t* from, const fvertex_t* to, float bottom, float top, @@ -1906,7 +1906,7 @@ static boolean rendSegSection(subsector_t* ssec, HEdge* hedge, // Dynamic Lights? if(addDLights && msA->glowing < 1 && !(!useDynlights && !useWallGlow)) { - lightListIdx = LO_ProjectToSurface(((section == SS_MIDDLE && isTwoSided)? PLF_SORT_LUMINOSITY_DESC : 0), ssec, 1, + lightListIdx = LO_ProjectToSurface(((section == SS_MIDDLE && isTwoSided)? PLF_SORT_LUMINOSITY_DESC : 0), bspLeaf, 1, texTL, texBR, HEDGE_SIDEDEF(hedge)->SW_middletangent, HEDGE_SIDEDEF(hedge)->SW_middlebitangent, HEDGE_SIDEDEF(hedge)->SW_middlenormal); } @@ -1914,7 +1914,7 @@ static boolean rendSegSection(subsector_t* ssec, HEdge* hedge, if(addMobjShadows && msA->glowing < 1 && Rend_MobjShadowsEnabled()) { // Glowing planes inversely diminish shadow strength. - shadowListIdx = R_ProjectShadowsToSurface(ssec, 1 - msA->glowing, texTL, texBR, + shadowListIdx = R_ProjectShadowsToSurface(bspLeaf, 1 - msA->glowing, texTL, texBR, HEDGE_SIDEDEF(hedge)->SW_middletangent, HEDGE_SIDEDEF(hedge)->SW_middlebitangent, HEDGE_SIDEDEF(hedge)->SW_middlenormal); } @@ -1965,7 +1965,7 @@ static boolean rendSegSection(subsector_t* ssec, HEdge* hedge, /** * Renders the given single-sided hedge into the world. */ -static boolean Rend_RenderSeg(subsector_t* ssec, HEdge* hedge) +static boolean Rend_RenderSeg(BspLeaf* bspLeaf, HEdge* hedge) { boolean solidSeg = true; sidedef_t* side; @@ -1978,7 +1978,7 @@ static boolean Rend_RenderSeg(subsector_t* ssec, HEdge* hedge) side = HEDGE_SIDEDEF(hedge); if(!side) return false; // A one-way window? - frontsec = ssec->sector; + frontsec = bspLeaf->sector; backSide = hedge->side; ldef = hedge->lineDef; @@ -1994,8 +1994,8 @@ static boolean Rend_RenderSeg(subsector_t* ssec, HEdge* hedge) DMU_LINEDEF, &pid); } - ffloor = ssec->sector->SP_floorvisheight; - fceil = ssec->sector->SP_ceilvisheight; + ffloor = bspLeaf->sector->SP_floorvisheight; + fceil = bspLeaf->sector->SP_ceilvisheight; // Create the wall sections. @@ -2013,7 +2013,7 @@ static boolean Rend_RenderSeg(subsector_t* ssec, HEdge* hedge) Rend_RadioUpdateLinedef(hedge->lineDef, hedge->side); - solidSeg = rendSegSection(ssec, hedge, SS_MIDDLE, &side->SW_middlesurface, + solidSeg = rendSegSection(bspLeaf, hedge, SS_MIDDLE, &side->SW_middlesurface, &hedge->HE_v1->v, &hedge->HE_v2->v, ffloor, fceil, texOffset, /*temp >*/ frontsec, /*< temp*/ @@ -2143,7 +2143,7 @@ boolean R_FindBottomTop(linedef_t* lineDef, int side, sidedefsection_t section, /** * Render wall sections for a HEdge belonging to a two-sided LineDef. */ -static boolean Rend_RenderSegTwosided(subsector_t* ssec, HEdge* hedge) +static boolean Rend_RenderSegTwosided(BspLeaf* bspLeaf, HEdge* hedge) { int pid = viewPlayer - ddPlayers; float bottom, top, texOffset[2]; @@ -2175,8 +2175,8 @@ static boolean Rend_RenderSegTwosided(subsector_t* ssec, HEdge* hedge) !frontSide->SW_middlematerial) return false; // Ugh... an obvious wall hedge hack. Best take no chances... - ffloor = ssec->sector->SP_plane(PLN_FLOOR); - fceil = ssec->sector->SP_plane(PLN_CEILING); + ffloor = bspLeaf->sector->SP_plane(PLN_FLOOR); + fceil = bspLeaf->sector->SP_plane(PLN_CEILING); bfloor = backSec->SP_plane(PLN_FLOOR); bceil = backSec->SP_plane(PLN_CEILING); @@ -2206,7 +2206,7 @@ static boolean Rend_RenderSegTwosided(subsector_t* ssec, HEdge* hedge) LINE_SELFREF(line)? true : false, &bottom, &top, texOffset)) { - solidSeg = rendSegSection(ssec, hedge, SS_MIDDLE, suf, + solidSeg = rendSegSection(bspLeaf, hedge, SS_MIDDLE, suf, &hedge->HE_v1->v, &hedge->HE_v2->v, bottom, top, texOffset, frontSec, (((viewPlayer->shared.flags & (DDPF_NOCLIP|DDPF_CAMERA)) || @@ -2252,7 +2252,7 @@ static boolean Rend_RenderSegTwosided(subsector_t* ssec, HEdge* hedge) LINE_SELFREF(line)? true : false, &bottom, &top, texOffset)) { - rendSegSection(ssec, hedge, SS_TOP, suf, + rendSegSection(bspLeaf, hedge, SS_TOP, suf, &hedge->HE_v1->v, &hedge->HE_v2->v, bottom, top, texOffset, frontSec, false, true, true, frontSide->flags); } @@ -2272,7 +2272,7 @@ static boolean Rend_RenderSegTwosided(subsector_t* ssec, HEdge* hedge) LINE_SELFREF(line)? true : false, &bottom, &top, texOffset)) { - rendSegSection(ssec, hedge, SS_BOTTOM, suf, + rendSegSection(bspLeaf, hedge, SS_BOTTOM, suf, &hedge->HE_v1->v, &hedge->HE_v2->v, bottom, top, texOffset, frontSec, false, true, true, frontSide->flags); } @@ -2319,7 +2319,7 @@ static boolean Rend_RenderSegTwosided(subsector_t* ssec, HEdge* hedge) return false; } -static void Rend_MarkSegsFacingFront(subsector_t *sub) +static void Rend_MarkSegsFacingFront(BspLeaf *sub) { HEdge* hedge, **segIt; uint i; @@ -2337,7 +2337,7 @@ static void Rend_MarkSegsFacingFront(subsector_t *sub) else hedge->frameFlags &= ~HEDGEINF_FACINGFRONT; - Rend_MarkSegSectionsPVisible(hedge); + Rend_MarkSideDefSectionsPVisible(hedge); } } @@ -2355,18 +2355,18 @@ static void Rend_MarkSegsFacingFront(subsector_t *sub) else hedge->frameFlags &= ~HEDGEINF_FACINGFRONT; - Rend_MarkSegSectionsPVisible(hedge); + Rend_MarkSideDefSectionsPVisible(hedge); } } } -static void occludeFrontFacingSegsInSubsector(const subsector_t* ssec) +static void occludeFrontFacingSegsInBspLeaf(const BspLeaf* bspLeaf) { HEdge** segIt; HEdge* hedge; uint i; - for(segIt = ssec->hedges; *segIt; segIt++) + for(segIt = bspLeaf->hedges; *segIt; segIt++) { hedge = *segIt; if(!hedge->lineDef || !(hedge->frameFlags & HEDGEINF_FACINGFRONT)) continue; @@ -2378,11 +2378,11 @@ static void occludeFrontFacingSegsInSubsector(const subsector_t* ssec) } } - if(!ssec->polyObj) return; + if(!bspLeaf->polyObj) return; - for(i = 0; i < ssec->polyObj->lineCount; ++i) + for(i = 0; i < bspLeaf->polyObj->lineCount; ++i) { - linedef_t* line = ssec->polyObj->lines[i]; + linedef_t* line = bspLeaf->polyObj->lines[i]; hedge = line->L_frontside->hedges[0]; @@ -2404,12 +2404,12 @@ static void occludeFrontFacingSegsInSubsector(const subsector_t* ssec) #define SKYCAP_UPPER 0x2 ///@} -static __inline float skyCapZ(subsector_t* ssec, int skyCap) +static __inline float skyCapZ(BspLeaf* bspLeaf, int skyCap) { const planetype_t plane = (skyCap & SKYCAP_UPPER)? PLN_CEILING : PLN_FLOOR; - if(!ssec) Con_Error("skyCapZ: Invalid ssec argument (=NULL)."); - if(!ssec->sector || !P_IsInVoid(viewPlayer)) return skyFix[plane].height; - return ssec->sector->SP_planevisheight(plane); + if(!bspLeaf) Con_Error("skyCapZ: Invalid bspLeaf argument (=NULL)."); + if(!bspLeaf->sector || !P_IsInVoid(viewPlayer)) return skyFix[plane].height; + return bspLeaf->sector->SP_planevisheight(plane); } static __inline float skyFixFloorZ(const plane_t* frontFloor, const plane_t* backFloor) @@ -2514,17 +2514,17 @@ static void skyFixZCoords(HEdge* hedge, int skyCap, float* bottom, float* top) } } -static void writeSkyFixGeometry(subsector_t* ssec, int skyCap, int rendPolyFlags) +static void writeSkyFixGeometry(BspLeaf* bspLeaf, int skyCap, int rendPolyFlags) { float zBottom, zTop; int segSkyCapFlags; rvertex_t verts[4]; HEdge** segPtr; - if(!ssec || !ssec->hedgeCount || !ssec->sector) return; + if(!bspLeaf || !bspLeaf->hedgeCount || !bspLeaf->sector) return; if(!(skyCap & SKYCAP_LOWER|SKYCAP_UPPER)) return; - for(segPtr = ssec->hedges; *segPtr; segPtr++) + for(segPtr = bspLeaf->hedges; *segPtr; segPtr++) { HEdge* hedge = *segPtr; @@ -2570,33 +2570,33 @@ static void writeSkyFixGeometry(subsector_t* ssec, int skyCap, int rendPolyFlags } /** - * Render the lower and/or upper sky cap geometry for @a ssec. - * @param ssec Subsector to render geometry for. + * Render the lower and/or upper sky cap geometry for @a bspLeaf. + * @param bspLeaf BspLeaf to render geometry for. * @param skyCap @see skyCapFlags */ -static void rendSubsectorSky(subsector_t* ssec, int skyCap) +static void rendBspLeafSky(BspLeaf* bspLeaf, int skyCap) { const int rendPolyFlags = RPF_DEFAULT | RPF_SKYMASK; - if(!ssec || !ssec->hedgeCount || !ssec->sector) return; + if(!bspLeaf || !bspLeaf->hedgeCount || !bspLeaf->sector) return; // Sky caps are only necessary in sectors with skymasked planes. - if((skyCap & SKYCAP_LOWER) && !R_IsSkySurface(&ssec->sector->SP_floorsurface)) + if((skyCap & SKYCAP_LOWER) && !R_IsSkySurface(&bspLeaf->sector->SP_floorsurface)) skyCap &= ~SKYCAP_LOWER; - if((skyCap & SKYCAP_UPPER) && !R_IsSkySurface(&ssec->sector->SP_ceilsurface)) + if((skyCap & SKYCAP_UPPER) && !R_IsSkySurface(&bspLeaf->sector->SP_ceilsurface)) skyCap &= ~SKYCAP_UPPER; // Sky fixes: - writeSkyFixGeometry(ssec, skyCap, rendPolyFlags); + writeSkyFixGeometry(bspLeaf, skyCap, rendPolyFlags); // Lower cap: if(skyCap & SKYCAP_LOWER) { - const float height = skyCapZ(ssec, SKYCAP_LOWER); - const int numVerts = ssec->numVertices; + const float height = skyCapZ(bspLeaf, SKYCAP_LOWER); + const int numVerts = bspLeaf->numVertices; rvertex_t* verts = R_AllocRendVertices(numVerts); - Rend_PreparePlane(verts, numVerts, height, ssec, false/*clockwise*/); + Rend_PreparePlane(verts, numVerts, height, bspLeaf, false/*clockwise*/); RL_AddPoly(PT_FAN, rendPolyFlags, numVerts, verts, NULL); R_FreeRendVertices(verts); } @@ -2604,11 +2604,11 @@ static void rendSubsectorSky(subsector_t* ssec, int skyCap) // Upper cap: if(skyCap & SKYCAP_UPPER) { - const float height = skyCapZ(ssec, SKYCAP_UPPER); - const int numVerts = ssec->numVertices; + const float height = skyCapZ(bspLeaf, SKYCAP_UPPER); + const int numVerts = bspLeaf->numVertices; rvertex_t* verts = R_AllocRendVertices(numVerts); - Rend_PreparePlane(verts, numVerts, height, ssec, true/*anticlockwise*/); + Rend_PreparePlane(verts, numVerts, height, bspLeaf, true/*anticlockwise*/); RL_AddPoly(PT_FAN, rendPolyFlags, numVerts, verts, NULL); R_FreeRendVertices(verts); } @@ -2640,29 +2640,29 @@ static boolean skymaskSegIsVisible(HEdge* hedge, boolean clipBackFacing) !sideDef->SW_middlematerial); } -static void Rend_RenderSubsectorSky(subsector_t* ssec) +static void Rend_RenderBspLeafSky(BspLeaf* bspLeaf) { // Any work to do? - if(devRendSkyMode || !ssec || !ssec->sector || !R_SectorContainsSkySurfaces(ssec->sector)) return; + if(devRendSkyMode || !bspLeaf || !bspLeaf->sector || !R_SectorContainsSkySurfaces(bspLeaf->sector)) return; // All geometry uses the same (default) RTU write state. RL_LoadDefaultRtus(); // Write geometry. - rendSubsectorSky(ssec, SKYCAP_LOWER|SKYCAP_UPPER); + rendBspLeafSky(bspLeaf, SKYCAP_LOWER|SKYCAP_UPPER); } /** - * Creates new occlusion planes from the subsector's sides. - * Before testing, occlude subsector's backfaces. After testing occlude - * the remaining faces, i.e. the forward facing hedges. This is done before - * rendering hedges, so solid segments cut out all unnecessary oranges. + * Creates new occlusion planes from the BspLeaf's edges. + * Before testing, occlude the BspLeaf's backfaces. After testing occlude + * the remaining faces, i.e. the forward facing edges. This is done before + * rendering edges, so solid segments cut out all unnecessary oranges. */ -static void occludeSubsector(const subsector_t* ssec, boolean forwardFacing) +static void occludeBspLeaf(const BspLeaf* bspLeaf, boolean forwardFacing) { float fronth[2], backh[2]; float* startv, *endv; - sector_t* front = ssec->sector, *back; + sector_t* front = bspLeaf->sector, *back; HEdge* hedge, **segIt; if(devNoCulling || P_IsInVoid(viewPlayer)) @@ -2671,7 +2671,7 @@ static void occludeSubsector(const subsector_t* ssec, boolean forwardFacing) fronth[0] = front->SP_floorheight; fronth[1] = front->SP_ceilheight; - for(segIt = ssec->hedges; *segIt; segIt++) + for(segIt = bspLeaf->hedges; *segIt; segIt++) { hedge = *segIt; @@ -2725,76 +2725,76 @@ static void occludeSubsector(const subsector_t* ssec, boolean forwardFacing) } } -static void Rend_RenderSubsector(uint subsectorIdx) +static void Rend_RenderBspLeaf(uint bspLeafIdx) { uint i; - subsector_t* ssec = SUBSECTOR_PTR(subsectorIdx); + BspLeaf* bspLeaf = BSPLEAF_PTR(bspLeafIdx); HEdge* hedge, **segIt; sector_t* sect; float sceil, sfloor; - if(!ssec->sector) return; // An orphan subsector? + if(!bspLeaf->sector) return; // An orphan BSP leaf? - sect = ssec->sector; + sect = bspLeaf->sector; sceil = sect->SP_ceilvisheight; sfloor = sect->SP_floorvisheight; - if(sceil - sfloor <= 0 || ssec->hedgeCount < 3) + if(sceil - sfloor <= 0 || bspLeaf->hedgeCount < 3) { // Skip this, it has no volume. // Neighbors handle adding the solid clipper segments. return; } - if(!firstsubsector) + if(!firstBspLeaf) { - if(!C_CheckSubsector(ssec)) + if(!C_CheckBspLeaf(bspLeaf)) return; // This isn't visible. } else { - firstsubsector = false; + firstBspLeaf = false; } // Mark the sector visible for this frame. sect->frameFlags |= SIF_VISIBLE; - Rend_MarkSegsFacingFront(ssec); + Rend_MarkSegsFacingFront(bspLeaf); - R_InitForSubsector(ssec); - Rend_RadioSubsectorEdges(ssec); + R_InitForBspLeaf(bspLeaf); + Rend_RadioBspLeafEdges(bspLeaf); - occludeSubsector(ssec, false); - LO_ClipInSubsector(subsectorIdx); - occludeSubsector(ssec, true); + occludeBspLeaf(bspLeaf, false); + LO_ClipInBspLeaf(bspLeafIdx); + occludeBspLeaf(bspLeaf, true); - occludeFrontFacingSegsInSubsector(ssec); + occludeFrontFacingSegsInBspLeaf(bspLeaf); - if(ssec->polyObj) + if(bspLeaf->polyObj) { // Polyobjs don't obstruct, do clip lights with another algorithm. - LO_ClipInSubsectorBySight(subsectorIdx); + LO_ClipInBspLeafBySight(bspLeafIdx); } // Mark the particle generators in the sector visible. Rend_ParticleMarkInSectorVisible(sect); /** - * Sprites for this subsector have to be drawn. + * Sprites for this BSP leaf have to be drawn. * @note - * Must be done BEFORE the segments of this subsector are added to the + * Must be done BEFORE the segments of this BspLeaf are added to the * clipper. Otherwise the sprites would get clipped by them, and that * wouldn't be right. * Must be done AFTER the lumobjs have been clipped as this affects the * projection of flares. */ - R_AddSprites(ssec); + R_AddSprites(bspLeaf); // Draw the sky cap geometry (and various skymask fixes). - Rend_RenderSubsectorSky(ssec); + Rend_RenderBspLeafSky(bspLeaf); // Draw the walls. - for(segIt = ssec->hedges; *segIt; segIt++) + for(segIt = bspLeaf->hedges; *segIt; segIt++) { hedge = *segIt; @@ -2804,9 +2804,9 @@ static void Rend_RenderSubsector(uint subsectorIdx) { boolean solid; if(!hedge->HE_backsector || !hedge->HE_frontsector) - solid = Rend_RenderSeg(ssec, hedge); + solid = Rend_RenderSeg(bspLeaf, hedge); else - solid = Rend_RenderSegTwosided(ssec, hedge); + solid = Rend_RenderSegTwosided(bspLeaf, hedge); if(solid) { @@ -2817,18 +2817,18 @@ static void Rend_RenderSubsector(uint subsectorIdx) } // Is there a polyobj on board? - if(ssec->polyObj) + if(bspLeaf->polyObj) { - for(i = 0; i < ssec->polyObj->lineCount; ++i) + for(i = 0; i < bspLeaf->polyObj->lineCount; ++i) { - linedef_t* line = ssec->polyObj->lines[i]; + linedef_t* line = bspLeaf->polyObj->lines[i]; hedge = line->L_frontside->hedges[0]; // Let's first check which way this hedge is facing. if(hedge->frameFlags & HEDGEINF_FACINGFRONT) { - boolean solid = Rend_RenderSeg(ssec, hedge); + boolean solid = Rend_RenderSeg(bspLeaf, hedge); if(solid) { C_AddViewRelSeg(hedge->HE_v1pos[VX], hedge->HE_v1pos[VY], @@ -2878,19 +2878,19 @@ static void Rend_RenderSubsector(uint subsectorIdx) V2_Copy(texOffset, suf->visOffset); // Add the Y offset to orient the Y flipped texture. if(plane->type == PLN_CEILING) - texOffset[VY] -= ssec->aaBox.maxY - ssec->aaBox.minY; + texOffset[VY] -= bspLeaf->aaBox.maxY - bspLeaf->aaBox.minY; // Add the additional offset to align with the worldwide grid. - texOffset[VX] += ssec->worldGridOffset[VX]; - texOffset[VY] += ssec->worldGridOffset[VY]; + texOffset[VX] += bspLeaf->worldGridOffset[VX]; + texOffset[VY] += bspLeaf->worldGridOffset[VY]; // Inverted. texOffset[VY] = -texOffset[VY]; texScale[VX] = ((suf->flags & DDSUF_MATERIAL_FLIPH)? -1 : 1); texScale[VY] = ((suf->flags & DDSUF_MATERIAL_FLIPV)? -1 : 1); - Rend_RenderPlane(ssec, plane->type, plane->visHeight, suf->tangent, suf->bitangent, suf->normal, + Rend_RenderPlane(bspLeaf, plane->type, plane->visHeight, suf->tangent, suf->bitangent, suf->normal, mat, suf->flags, suf->inFlags, suf->rgba, suf->blendMode, texOffset, texScale, - isSkyMasked, addDLights, (i == PLN_FLOOR), ssec->bsuf[plane->planeID], plane->planeID, + isSkyMasked, addDLights, (i == PLN_FLOOR), bspLeaf->bsuf[plane->planeID], plane->planeID, texMode, flipSurfaceNormal, clipBackFacing); } } @@ -2902,10 +2902,10 @@ static void Rend_RenderNode(uint bspnum) // fully covered by geometry. if(C_IsFull()) return; - if(bspnum & NF_SUBSECTOR) + if(bspnum & NF_LEAF) { - // We've arrived at a subsector. Render it. - Rend_RenderSubsector(bspnum & ~NF_SUBSECTOR); + // We've arrived at a leaf. Render it. + Rend_RenderBspLeaf(bspnum & ~NF_LEAF); } else { @@ -3037,19 +3037,19 @@ void Rend_RenderSurfaceVectors(void) } } - for(i = 0; i < NUM_SUBSECTORS; ++i) + for(i = 0; i < NUM_BSPLEAFS; ++i) { - subsector_t* ssec = &subsectors[i]; + BspLeaf* bspLeaf = &bspLeafs[i]; uint j; - if(!ssec->sector) continue; + if(!bspLeaf->sector) continue; - for(j = 0; j < ssec->sector->planeCount; ++j) + for(j = 0; j < bspLeaf->sector->planeCount; ++j) { - plane_t* pln = ssec->sector->SP_plane(j); + plane_t* pln = bspLeaf->sector->SP_plane(j); vec3_t origin; - V3_Set(origin, ssec->midPoint.pos[VX], ssec->midPoint.pos[VY], pln->visHeight); + V3_Set(origin, bspLeaf->midPoint.pos[VX], bspLeaf->midPoint.pos[VY], pln->visHeight); if(pln->type != PLN_MID && R_IsSkySurface(&pln->surface)) origin[VZ] = skyFix[pln->type].height; @@ -3060,7 +3060,7 @@ void Rend_RenderSurfaceVectors(void) for(i = 0; i < NUM_POLYOBJS; ++i) { const polyobj_t* po = polyObjs[i]; - const sector_t* sec = po->subsector->sector; + const sector_t* sec = po->bspLeaf->sector; float zPos = sec->SP_floorheight + (sec->SP_ceilheight - sec->SP_floorheight)/2; vec3_t origin; uint j; @@ -3184,8 +3184,8 @@ static int drawVertex1(linedef_t* li, void* context) if(alpha > 0) { - float bottom = po->subsector->sector->SP_floorvisheight; - float top = po->subsector->sector->SP_ceilvisheight; + float bottom = po->bspLeaf->sector->SP_floorvisheight; + float top = po->bspLeaf->sector->SP_ceilvisheight; if(devVertexBars) drawVertexBar(vtx, bottom, top, MIN_OF(alpha, .15f)); @@ -3204,7 +3204,7 @@ static int drawVertex1(linedef_t* li, void* context) pos[VX] = vtx->V_pos[VX]; pos[VY] = vtx->V_pos[VY]; - pos[VZ] = po->subsector->sector->SP_floorvisheight; + pos[VZ] = po->bspLeaf->sector->SP_floorvisheight; dist3D = M_Distance(pos, eye); @@ -3406,15 +3406,15 @@ void Rend_RenderMap(void) viewsidex = -viewData->viewSin; viewsidey = viewData->viewCos; - // We don't want subsector clipchecking for the first subsector. - firstsubsector = true; + // We don't want BSP clip checking for the first BSP leaf. + firstBspLeaf = true; if(NUM_BSPNODES != 0) { Rend_RenderNode(NUM_BSPNODES - 1); } else { - Rend_RenderSubsector(0); + Rend_RenderBspLeaf(0); } if(Rend_MobjShadowsEnabled()) @@ -3723,7 +3723,7 @@ static int drawMobjBBox(thinker_t* th, void* context) if(mo == ddPlayers[consolePlayer].shared.mo) return false; // Continue iteration. // Is it vissible? - if(!(mo->subsector && mo->subsector->sector->frameFlags & SIF_VISIBLE)) + if(!(mo->bspLeaf && mo->bspLeaf->sector->frameFlags & SIF_VISIBLE)) return false; // Continue iteration. eye[VX] = vx; @@ -3800,7 +3800,7 @@ static void Rend_RenderBoundingBoxes(void) for(i = 0; i < NUM_POLYOBJS; ++i) { const polyobj_t* po = polyObjs[i]; - const sector_t* sec = po->subsector->sector; + const sector_t* sec = po->bspLeaf->sector; float width = (po->aaBox.maxX - po->aaBox.minX)/2; float length = (po->aaBox.maxY - po->aaBox.minY)/2; float height = (sec->SP_ceilheight - sec->SP_floorheight)/2; diff --git a/doomsday/engine/portable/src/rend_particle.c b/doomsday/engine/portable/src/rend_particle.c index d64223a204..edb3c93ee7 100644 --- a/doomsday/engine/portable/src/rend_particle.c +++ b/doomsday/engine/portable/src/rend_particle.c @@ -368,7 +368,7 @@ static void setupModelParamsForParticle(rendmodelparams_t* params, const particle_t* pt, const ptcstage_t* st, const ded_ptcstage_t* dst, float* center, float dist, float size, float mark, float alpha) { - subsector_t* ssec; + BspLeaf* bspLeaf; int frame; // Render the particle as a model. @@ -376,7 +376,7 @@ static void setupModelParamsForParticle(rendmodelparams_t* params, params->center[VY] = center[VZ]; params->center[VZ] = params->gzt = center[VY]; params->distance = dist; - ssec = P_SubsectorAtPointXY(center[VX], center[VZ]); + bspLeaf = P_BspLeafAtPointXY(center[VX], center[VZ]); params->extraScale = size; // Extra scaling factor. params->mf = &modefs[dst->model]; @@ -453,7 +453,7 @@ static void setupModelParamsForParticle(rendmodelparams_t* params, lparams.center[VX] = params->center[VX]; lparams.center[VY] = params->center[VY]; lparams.center[VZ] = params->center[VZ]; - lparams.subsector = ssec; + lparams.bspLeaf = bspLeaf; lparams.ambientColor = params->ambientColor; params->vLightListIdx = R_CollectAffectingLights(&lparams); diff --git a/doomsday/engine/portable/src/rend_sprite.c b/doomsday/engine/portable/src/rend_sprite.c index 71ac11f27a..59f161dbd1 100644 --- a/doomsday/engine/portable/src/rend_sprite.c +++ b/doomsday/engine/portable/src/rend_sprite.c @@ -386,10 +386,10 @@ static void setupPSpriteParams(rendpspriteparams_t* params, vispsprite_t* spr) { float lightLevel; const float* secColor = - R_GetSectorLightColor(spr->data.sprite.subsector->sector); + R_GetSectorLightColor(spr->data.sprite.bspLeaf->sector); // No need for distance attentuation. - lightLevel = spr->data.sprite.subsector->sector->lightLevel; + lightLevel = spr->data.sprite.bspLeaf->sector->lightLevel; // Add extra light plus bonus. lightLevel += R_ExtraLightDelta(); @@ -409,7 +409,7 @@ static void setupPSpriteParams(rendpspriteparams_t* params, vispsprite_t* spr) lparams.center[VX] = spr->center[VX]; lparams.center[VY] = spr->center[VY]; lparams.center[VZ] = spr->center[VZ]; - lparams.subsector = spr->data.sprite.subsector; + lparams.bspLeaf = spr->data.sprite.bspLeaf; lparams.ambientColor = params->ambientColor; params->vLightListIdx = R_CollectAffectingLights(&lparams); @@ -774,10 +774,10 @@ static void setupModelParamsForVisPSprite(rendmodelparams_t* params, { float lightLevel; const float* secColor = - R_GetSectorLightColor(spr->data.model.subsector->sector); + R_GetSectorLightColor(spr->data.model.bspLeaf->sector); // Diminished light (with compression). - lightLevel = spr->data.model.subsector->sector->lightLevel; + lightLevel = spr->data.model.bspLeaf->sector->lightLevel; // No need for distance attentuation. @@ -800,7 +800,7 @@ static void setupModelParamsForVisPSprite(rendmodelparams_t* params, lparams.center[VX] = spr->center[VX]; lparams.center[VY] = spr->center[VY]; lparams.center[VZ] = spr->center[VZ]; - lparams.subsector = spr->data.model.subsector; + lparams.bspLeaf = spr->data.model.bspLeaf; lparams.ambientColor = params->ambientColor; params->vLightListIdx = R_CollectAffectingLights(&lparams); diff --git a/doomsday/engine/portable/src/s_environ.c b/doomsday/engine/portable/src/s_environ.c index 52c372e6d4..818d6c3f3f 100644 --- a/doomsday/engine/portable/src/s_environ.c +++ b/doomsday/engine/portable/src/s_environ.c @@ -133,37 +133,37 @@ static ownernode_t* newOwnerNode(void) return node; } -static void setSubsectorSectorOwner(ownerlist_t* ownerList, subsector_t* ssec) +static void setBspLeafSectorOwner(ownerlist_t* ownerList, BspLeaf* bspLeaf) { ownernode_t* node; - if(!ssec) return; + if(!bspLeaf) return; // Add a new owner. // NOTE: No need to check for duplicates. ownerList->count++; node = newOwnerNode(); - node->data = ssec; + node->data = bspLeaf; node->next = ownerList->head; ownerList->head = node; } -static void findSubsectorsAffectingSector(GameMap* map, uint secIDX) +static void findBspLeafsAffectingSector(GameMap* map, uint secIDX) { assert(map && secIDX < map->numSectors); { sector_t* sec = &map->sectors[secIDX]; - ownerlist_t subsectorOwnerList; + ownerlist_t bspLeafOwnerList; ownernode_t* node, *p; - subsector_t* sub; + BspLeaf* bspLeaf; float bbox[4]; uint i; if(0 == sec->lineDefCount) return; - memset(&subsectorOwnerList, 0, sizeof(subsectorOwnerList)); + memset(&bspLeafOwnerList, 0, sizeof(bspLeafOwnerList)); memcpy(bbox, sec->bBox, sizeof(bbox)); bbox[BOXLEFT] -= 128; @@ -171,42 +171,40 @@ static void findSubsectorsAffectingSector(GameMap* map, uint secIDX) bbox[BOXTOP] += 128; bbox[BOXBOTTOM] -= 128; -/*#if _DEBUG -Con_Message("sector %i: (%f,%f) - (%f,%f)\n", c, - bbox[BOXLEFT], bbox[BOXTOP], bbox[BOXRIGHT], bbox[BOXBOTTOM]); -#endif*/ + /*DEBUG_Message(("sector %i: (%f,%f) - (%f,%f)\n", c, + bbox[BOXLEFT], bbox[BOXTOP], bbox[BOXRIGHT], bbox[BOXBOTTOM]));*/ - for(i = 0; i < map->numSubsectors; ++i) + for(i = 0; i < map->numBspLeafs; ++i) { - sub = &map->subsectors[i]; - - // Is this subsector close enough? - if(sub->sector == sec || // subsector is IN this sector - (sub->midPoint.pos[VX] > bbox[BOXLEFT] && - sub->midPoint.pos[VX] < bbox[BOXRIGHT] && - sub->midPoint.pos[VY] < bbox[BOXTOP] && - sub->midPoint.pos[VY] > bbox[BOXBOTTOM])) + bspLeaf = &map->bspLeafs[i]; + + // Is this BSP leaf close enough? + if(bspLeaf->sector == sec || // leaf is IN this sector + (bspLeaf->midPoint.pos[VX] > bbox[BOXLEFT] && + bspLeaf->midPoint.pos[VX] < bbox[BOXRIGHT] && + bspLeaf->midPoint.pos[VY] < bbox[BOXTOP] && + bspLeaf->midPoint.pos[VY] > bbox[BOXBOTTOM])) { // It will contribute to the reverb settings of this sector. - setSubsectorSectorOwner(&subsectorOwnerList, sub); + setBspLeafSectorOwner(&bspLeafOwnerList, bspLeaf); } } // Now harden the list. - sec->numReverbSSecAttributors = subsectorOwnerList.count; - if(sec->numReverbSSecAttributors) + sec->numReverbBspLeafAttributors = bspLeafOwnerList.count; + if(sec->numReverbBspLeafAttributors) { - subsector_t **ptr; + BspLeaf **ptr; - sec->reverbSubsectors = - Z_Malloc((sec->numReverbSSecAttributors + 1) * sizeof(subsector_t*), + sec->reverbBspLeafs = + Z_Malloc((sec->numReverbBspLeafAttributors + 1) * sizeof(BspLeaf*), PU_MAPSTATIC, 0); - for(i = 0, ptr = sec->reverbSubsectors, node = subsectorOwnerList.head; - i < sec->numReverbSSecAttributors; ++i, ptr++) + for(i = 0, ptr = sec->reverbBspLeafs, node = bspLeafOwnerList.head; + i < sec->numReverbBspLeafAttributors; ++i, ptr++) { p = node->next; - *ptr = (subsector_t*) node->data; + *ptr = (BspLeaf*) node->data; if(i < map->numSectors - 1) { @@ -226,8 +224,8 @@ Con_Message("sector %i: (%f,%f) - (%f,%f)\n", c, } /** - * Called during map init to determine which subsectors affect the reverb - * properties of each sector. Given that subsectors do not change shape (in + * Called during map init to determine which BSP leafs affect the reverb + * properties of each sector. Given that BSP leafs do not change shape (in * two dimensions at least), they do not move and are not created/destroyed * once the map has been loaded; this step can be pre-processed. */ @@ -235,14 +233,14 @@ void S_DetermineSubsecsAffectingSectorReverb(GameMap* map) { uint i, startTime; ownernode_t* node, *p; - assert(map); startTime = Sys_GetRealTime(); + /// @optimize Make use of the BSP leaf blockmap. for(i = 0; i < map->numSectors; ++i) { - findSubsectorsAffectingSector(map, i); + findBspLeafsAffectingSector(map, i); } // Free any nodes left in the unused list. @@ -261,7 +259,7 @@ void S_DetermineSubsecsAffectingSectorReverb(GameMap* map) (Sys_GetRealTime() - startTime) / 1000.0f)); } -static boolean calcSubsectorReverb(subsector_t* ssec) +static boolean calcBspLeafReverb(BspLeaf* bspLeaf) { float materials[NUM_MATERIAL_ENV_CLASSES]; material_env_class_t mclass; @@ -269,24 +267,24 @@ static boolean calcSubsectorReverb(subsector_t* ssec) float total = 0; uint i, v; - if(!ssec->sector) + if(!bspLeaf->sector) { - ssec->reverb[SRD_SPACE] = ssec->reverb[SRD_VOLUME] = - ssec->reverb[SRD_DECAY] = ssec->reverb[SRD_DAMPING] = 0; + bspLeaf->reverb[SRD_SPACE] = bspLeaf->reverb[SRD_VOLUME] = + bspLeaf->reverb[SRD_DECAY] = bspLeaf->reverb[SRD_DAMPING] = 0; return false; } memset(&materials, 0, sizeof(materials)); - // Space is the rough volume of the subsector (bounding box). - ssec->reverb[SRD_SPACE] = - (int) (ssec->sector->SP_ceilheight - ssec->sector->SP_floorheight) * - (ssec->aaBox.maxX - ssec->aaBox.minX) * - (ssec->aaBox.maxY - ssec->aaBox.minY); + // Space is the rough volume of the BSP leaf (bounding box). + bspLeaf->reverb[SRD_SPACE] = + (int) (bspLeaf->sector->SP_ceilheight - bspLeaf->sector->SP_floorheight) * + (bspLeaf->aaBox.maxX - bspLeaf->aaBox.minX) * + (bspLeaf->aaBox.maxY - bspLeaf->aaBox.minY); // The other reverb properties can be found out by taking a look at the - // materials of all surfaces in the subsector. - hedgeIter = ssec->hedges; + // materials of all surfaces in the BSP leaf. + hedgeIter = bspLeaf->hedges; while(*hedgeIter) { HEdge* hedge = *hedgeIter; @@ -306,8 +304,8 @@ static boolean calcSubsectorReverb(subsector_t* ssec) if(!total) { // Huh? - ssec->reverb[SRD_VOLUME] = ssec->reverb[SRD_DECAY] = - ssec->reverb[SRD_DAMPING] = 0; + bspLeaf->reverb[SRD_VOLUME] = bspLeaf->reverb[SRD_DECAY] = + bspLeaf->reverb[SRD_DAMPING] = 0; return false; } @@ -320,28 +318,26 @@ static boolean calcSubsectorReverb(subsector_t* ssec) v += materials[i] * matInfo[i].volumeMul; if(v > 255) v = 255; - ssec->reverb[SRD_VOLUME] = v; + bspLeaf->reverb[SRD_VOLUME] = v; // Decay time. for(i = 0, v = 0; i < NUM_MATERIAL_ENV_CLASSES; ++i) v += materials[i] * matInfo[i].decayMul; if(v > 255) v = 255; - ssec->reverb[SRD_DECAY] = v; + bspLeaf->reverb[SRD_DECAY] = v; // High frequency damping. for(i = 0, v = 0; i < NUM_MATERIAL_ENV_CLASSES; ++i) v += materials[i] * matInfo[i].dampingMul; if(v > 255) v = 255; - ssec->reverb[SRD_DAMPING] = v; + bspLeaf->reverb[SRD_DAMPING] = v; -/*#if _DEBUG -Con_Message("ssec %04i: vol:%3i sp:%3i dec:%3i dam:%3i\n", - GET_SUBSECTOR_IDX(ssec), ssec->reverb[SRD_VOLUME], - ssec->reverb[SRD_SPACE], ssec->reverb[SRD_DECAY], - ssec->reverb[SRD_DAMPING]); -#endif*/ + /* DEBUG_Message(("bspLeaf %04i: vol:%3i sp:%3i dec:%3i dam:%3i\n", + GET_BSPLEAF_IDX(bspLeaf), bspLeaf->reverb[SRD_VOLUME], + bspLeaf->reverb[SRD_SPACE], bspLeaf->reverb[SRD_DECAY], + bspLeaf->reverb[SRD_DAMPING])); */ return true; } @@ -351,13 +347,13 @@ Con_Message("ssec %04i: vol:%3i sp:%3i dec:%3i dam:%3i\n", * whenever any of the properties governing reverb properties have changed * (i.e. hedge/plane texture or plane height changes). * - * PRE: Subsector attributors must have been determined first. + * PRE: BspLeaf attributors must have been determined first. * * @param sec Ptr to the sector to calculate reverb properties of. */ void S_CalcSectorReverb(sector_t* sec) { - subsector_t* sub; + BspLeaf* sub; float spaceScatter; uint sectorSpace; @@ -367,19 +363,17 @@ void S_CalcSectorReverb(sector_t* sec) (sec->bBox[BOXRIGHT] - sec->bBox[BOXLEFT]) * (sec->bBox[BOXTOP] - sec->bBox[BOXBOTTOM]); -/*#if _DEBUG -Con_Message("sector %i: secsp:%i\n", c, sectorSpace); -#endif*/ + // DEBUG_Message(("sector %i: secsp:%i\n", c, sectorSpace)); sec->reverb[SRD_SPACE] = sec->reverb[SRD_VOLUME] = sec->reverb[SRD_DECAY] = sec->reverb[SRD_DAMPING] = 0; { uint i; - for(i = 0; i < sec->numReverbSSecAttributors; ++i) + for(i = 0; i < sec->numReverbBspLeafAttributors; ++i) { - sub = sec->reverbSubsectors[i]; + sub = sec->reverbBspLeafs[i]; - if(calcSubsectorReverb(sub)) + if(calcBspLeafReverb(sub)) { sec->reverb[SRD_SPACE] += sub->reverb[SRD_SPACE]; diff --git a/doomsday/engine/portable/src/s_sfx.c b/doomsday/engine/portable/src/s_sfx.c index eacdbd0612..40fea4b042 100644 --- a/doomsday/engine/portable/src/s_sfx.c +++ b/doomsday/engine/portable/src/s_sfx.c @@ -542,9 +542,9 @@ void Sfx_ListenerUpdate(void) AudioDriver_SFX()->Listenerv(SFXLP_VELOCITY, vec); // Reverb effects. Has the current sector changed? - if(listenerSector != listener->subsector->sector) + if(listenerSector != listener->bspLeaf->sector) { - listenerSector = listener->subsector->sector; + listenerSector = listener->bspLeaf->sector; for(i = 0; i < NUM_REVERB_DATA; ++i) { diff --git a/doomsday/engine/portable/src/sv_pool.c b/doomsday/engine/portable/src/sv_pool.c index a8f3a625aa..5c3e6decba 100644 --- a/doomsday/engine/portable/src/sv_pool.c +++ b/doomsday/engine/portable/src/sv_pool.c @@ -343,7 +343,7 @@ void Sv_RegisterMobj(dt_mobj_t* reg, const mobj_t* mo) reg->thinker.id = mo->thinker.id; reg->type = mo->type; reg->dPlayer = mo->dPlayer; - reg->subsector = mo->subsector; + reg->bspLeaf = mo->bspLeaf; reg->pos[VX] = mo->pos[VX]; reg->pos[VY] = mo->pos[VY]; reg->pos[VZ] = Sv_GetMaxedMobjZ(mo); @@ -1189,7 +1189,7 @@ void Sv_ApplyDeltaData(void* destDelta, const void* srcDelta) d->dPlayer = s->dPlayer; if(sf & (MDF_POS_X | MDF_POS_Y)) - d->subsector = s->subsector; + d->bspLeaf = s->bspLeaf; if(sf & MDF_POS_X) d->pos[VX] = s->pos[VX]; if(sf & MDF_POS_Y) diff --git a/doomsday/plugins/common/include/p_mapsetup.h b/doomsday/plugins/common/include/p_mapsetup.h index 3e503a0b3a..a8b2eb09a1 100644 --- a/doomsday/plugins/common/include/p_mapsetup.h +++ b/doomsday/plugins/common/include/p_mapsetup.h @@ -30,10 +30,10 @@ #define LIBCOMMON_PLAYSETUP_H #define numvertexes (*(uint*) DD_GetVariable(DD_VERTEX_COUNT)) -#define numsegs (*(uint*) DD_GetVariable(DD_HEDGE_COUNT)) +#define numhedges (*(uint*) DD_GetVariable(DD_HEDGE_COUNT)) #define numsectors (*(uint*) DD_GetVariable(DD_SECTOR_COUNT)) -#define numsubsectors (*(uint*) DD_GetVariable(DD_SUBSECTOR_COUNT)) -#define numnodes (*(uint*) DD_GetVariable(DD_BSPNODE_COUNT)) +#define numbspleafs (*(uint*) DD_GetVariable(DD_BSPLEAF_COUNT)) +#define numbspnodes (*(uint*) DD_GetVariable(DD_BSPNODE_COUNT)) #define numlines (*(uint*) DD_GetVariable(DD_LINE_COUNT)) #define numsides (*(uint*) DD_GetVariable(DD_SIDE_COUNT)) diff --git a/doomsday/plugins/common/src/hu_automap.c b/doomsday/plugins/common/src/hu_automap.c index 30306df986..f42c514231 100644 --- a/doomsday/plugins/common/src/hu_automap.c +++ b/doomsday/plugins/common/src/hu_automap.c @@ -675,9 +675,9 @@ static int rendSeg(void* hedge_, void* data) } } -static int rendSegsOfSubsector(subsector_t* ssec, void* context) +static int rendBspLeafHEdges(BspLeaf* bspLeaf, void* context) { - return P_Iteratep(ssec, DMU_HEDGE, context, rendSeg); + return P_Iteratep(bspLeaf, DMU_HEDGE, context, rendSeg); } /** @@ -703,14 +703,14 @@ static void renderWalls(uiwidget_t* obj, int objType, boolean addToLists) { AABoxf aaBox; UIAutomap_PVisibleAABounds(obj, &aaBox.minX, &aaBox.maxX, &aaBox.minY, &aaBox.maxY); - P_SubsectorsBoxIterator(&aaBox, NULL, rendSegsOfSubsector, obj); + P_BspLeafsBoxIterator(&aaBox, NULL, rendBspLeafHEdges, obj); } else { // No. As the map lists are considered static we want them to contain all // walls, not just those visible *now* (note rotation). - for(i = 0; i < numsubsectors; ++i) + for(i = 0; i < numbspleafs; ++i) { - P_Iteratep(P_ToPtr(DMU_SUBSECTOR, i), DMU_HEDGE, obj, rendSeg); + P_Iteratep(P_ToPtr(DMU_BSPLEAF, i), DMU_HEDGE, obj, rendSeg); } } } diff --git a/doomsday/plugins/common/src/mobj.c b/doomsday/plugins/common/src/mobj.c index d20defe8c6..77048313d8 100644 --- a/doomsday/plugins/common/src/mobj.c +++ b/doomsday/plugins/common/src/mobj.c @@ -54,7 +54,7 @@ static float getFriction(mobj_t* mo) } #ifdef __JHERETIC__ - if(P_ToXSector(P_GetPtrp(mo->subsector, DMU_SECTOR))->special == 15) + if(P_ToXSector(P_GetPtrp(mo->bspLeaf, DMU_SECTOR))->special == 15) { // Friction_Low return FRICTION_LOW; } @@ -103,7 +103,7 @@ void Mobj_XYMoveStopping(mobj_t* mo) if(!INRANGE_OF(mo->mom[MX], 0, DROPOFFMOMENTUM_THRESHOLD) || !INRANGE_OF(mo->mom[MY], 0, DROPOFFMOMENTUM_THRESHOLD)) { - if(mo->floorZ != P_GetFloatp(mo->subsector, DMU_FLOOR_HEIGHT)) + if(mo->floorZ != P_GetFloatp(mo->bspLeaf, DMU_FLOOR_HEIGHT)) return; } } diff --git a/doomsday/plugins/common/src/p_map.c b/doomsday/plugins/common/src/p_map.c index cd0e76ba04..ac5a265ee6 100644 --- a/doomsday/plugins/common/src/p_map.c +++ b/doomsday/plugins/common/src/p_map.c @@ -182,7 +182,7 @@ float P_GetGravity(void) * Checks the reject matrix to find out if the two sectors are visible * from each other. */ -static boolean checkReject(subsector_t* a, subsector_t* b) +static boolean checkReject(BspLeaf* a, BspLeaf* b) { if(rejectMatrix != NULL) { @@ -190,7 +190,7 @@ static boolean checkReject(subsector_t* a, subsector_t* b) sector_t* sec1 = P_GetPtrp(a, DMU_SECTOR); sector_t* sec2 = P_GetPtrp(b, DMU_SECTOR); - // Determine subsector entries in REJECT table. + // Determine BSP leaf entries in REJECT table. s1 = P_ToIndex(sec1); s2 = P_ToIndex(sec2); pnum = s1 * numsectors + s2; @@ -222,14 +222,14 @@ boolean P_CheckSight(const mobj_t* from, const mobj_t* to) float fPos[3]; // If either is unlinked, they can't see each other. - if(!from->subsector || !to->subsector) + if(!from->bspLeaf || !to->bspLeaf) return false; if(to->dPlayer && (to->dPlayer->flags & DDPF_CAMERA)) return false; // Cameramen don't exist! // Check for trivial rejection. - if(!checkReject(from->subsector, to->subsector)) + if(!checkReject(from->bspLeaf, to->bspLeaf)) return false; fPos[VX] = from->pos[VX]; @@ -290,7 +290,7 @@ int PIT_StompThing(mobj_t* mo, void* data) boolean P_TeleportMove(mobj_t* thing, float x, float y, boolean alwaysStomp) { int stomping; - subsector_t* newSSec; + BspLeaf* newSSec; AABoxf tmBoxExpanded; // Kill anything occupying the position. @@ -305,7 +305,7 @@ boolean P_TeleportMove(mobj_t* thing, float x, float y, boolean alwaysStomp) tmBox.maxX = tm[VX] + tmThing->radius; tmBox.maxY = tm[VY] + tmThing->radius; - newSSec = P_SubsectorAtPointXY(tm[VX], tm[VY]); + newSSec = P_BspLeafAtPointXY(tm[VX], tm[VY]); ceilingLine = floorLine = NULL; #if !__JHEXEN__ @@ -313,7 +313,7 @@ boolean P_TeleportMove(mobj_t* thing, float x, float y, boolean alwaysStomp) tmUnstuck = thing->dPlayer && thing->dPlayer->mo == thing; #endif - // The base floor / ceiling is from the subsector that contains the + // The base floor / ceiling is from the BSP leaf that contains the // point. Any contacted lines the step closer together will adjust them. tmFloorZ = tmDropoffZ = P_GetFloatp(newSSec, DMU_FLOOR_HEIGHT); tmCeilingZ = P_GetFloatp(newSSec, DMU_CEILING_HEIGHT); @@ -1160,7 +1160,7 @@ boolean P_CheckPosition3f(mobj_t* thing, float x, float y, float z) tmBox.maxX = tm[VX] + tmThing->radius; tmBox.maxY = tm[VY] + tmThing->radius; - newSec = P_GetPtrp(P_SubsectorAtPointXY(tm[VX], tm[VY]), DMU_SECTOR); + newSec = P_GetPtrp(P_BspLeafAtPointXY(tm[VX], tm[VY]), DMU_SECTOR); ceilingLine = floorLine = NULL; #if !__JHEXEN__ @@ -1168,7 +1168,7 @@ boolean P_CheckPosition3f(mobj_t* thing, float x, float y, float z) tmUnstuck = ((thing->dPlayer && thing->dPlayer->mo == thing)? true : false); #endif - // The base floor/ceiling is from the subsector that contains the point. + // The base floor/ceiling is from the BSP leaf that contains the point. // Any contacted lines the step closer together will adjust them. tmFloorZ = tmDropoffZ = P_GetFloatp(newSec, DMU_FLOOR_HEIGHT); tmCeilingZ = P_GetFloatp(newSec, DMU_CEILING_HEIGHT); @@ -1279,7 +1279,7 @@ static boolean P_TryMove2(mobj_t* thing, float x, float y, boolean dropoff) goto pushline; } else if(blockingMobj->pos[VZ] + blockingMobj->height - thing->pos[VZ] > 24 || - (P_GetFloatp(blockingMobj->subsector, DMU_CEILING_HEIGHT) - + (P_GetFloatp(blockingMobj->bspLeaf, DMU_CEILING_HEIGHT) - (blockingMobj->pos[VZ] + blockingMobj->height) < thing->height) || (tmCeilingZ - (blockingMobj->pos[VZ] + blockingMobj->height) < thing->height)) @@ -1450,7 +1450,7 @@ static boolean P_TryMove2(mobj_t* thing, float x, float y, boolean dropoff) #if __JHEXEN__ // Must stay within a sector of a certain floor type? if((thing->flags2 & MF2_CANTLEAVEFLOORPIC) && - (tmFloorMaterial != P_GetPtrp(thing->subsector, DMU_FLOOR_MATERIAL) || + (tmFloorMaterial != P_GetPtrp(thing->bspLeaf, DMU_FLOOR_MATERIAL) || !FEQUAL(tmFloorZ, thing->pos[VZ]))) { return false; @@ -1490,7 +1490,7 @@ static boolean P_TryMove2(mobj_t* thing, float x, float y, boolean dropoff) { thing->floorClip = 0; - if(thing->pos[VZ] == P_GetFloatp(thing->subsector, DMU_FLOOR_HEIGHT)) + if(thing->pos[VZ] == P_GetFloatp(thing->bspLeaf, DMU_FLOOR_HEIGHT)) { const terraintype_t* tt = P_MobjGetFloorTerrainType(thing); @@ -1649,7 +1649,7 @@ int PTR_ShootTraverse(const intercept_t* in, void* paramaters) const divline_t* trace = P_TraceLOS(); const TraceOpening* opening; sector_t* frontSec = NULL, *backSec = NULL; - subsector_t* contact, *originSub; + BspLeaf* contact, *originSub; xline_t* xline; boolean lineWasHit; @@ -1732,8 +1732,8 @@ int PTR_ShootTraverse(const intercept_t* in, void* paramaters) lineWasHit = true; - // This is the subsector where the trace originates. - originSub = P_SubsectorAtPointXY(tracePos[VX], tracePos[VY]); + // This is the BSP leaf where the trace originates. + originSub = P_BspLeafAtPointXY(tracePos[VX], tracePos[VY]); d[VX] = pos[VX] - tracePos[VX]; d[VY] = pos[VY] - tracePos[VY]; @@ -1741,7 +1741,7 @@ int PTR_ShootTraverse(const intercept_t* in, void* paramaters) if(!INRANGE_OF(d[VZ], 0, .0001f)) // Epsilon { - contact = P_SubsectorAtPointXY(pos[VX], pos[VY]); + contact = P_BspLeafAtPointXY(pos[VX], pos[VY]); step = P_ApproxDistance3(d[VX], d[VY], d[VZ]); stepv[VX] = d[VX] / step; stepv[VY] = d[VY] / step; @@ -1758,7 +1758,7 @@ int PTR_ShootTraverse(const intercept_t* in, void* paramaters) pos[VX] = tracePos[VX] + d[VX]; pos[VY] = tracePos[VY] + d[VY]; pos[VZ] = tracePos[VZ] + d[VZ]; - contact = P_SubsectorAtPointXY(pos[VX], pos[VY]); + contact = P_BspLeafAtPointXY(pos[VX], pos[VY]); } // Should we backtrack to hit a plane instead? @@ -2941,7 +2941,7 @@ int PIT_CheckOnmobjZ(mobj_t* thing, void* data) mobj_t* P_CheckOnMobj(mobj_t* thing) { - subsector_t* newSSec; + BspLeaf* newSSec; float pos[3]; mobj_t oldMo; AABoxf tmBoxExpanded; @@ -2972,11 +2972,11 @@ mobj_t* P_CheckOnMobj(mobj_t* thing) tmBox.maxX = pos[VX] + tmThing->radius; tmBox.maxY = pos[VY] + tmThing->radius; - newSSec = P_SubsectorAtPointXY(pos[VX], pos[VY]); + newSSec = P_BspLeafAtPointXY(pos[VX], pos[VY]); ceilingLine = floorLine = NULL; - // The base floor/ceiling is from the subsector that contains the - // point. Any contacted lines the step closer together will adjust them. + // The base floor/ceiling is from the BSP leaf that contains the point. + // Any contacted lines the step closer together will adjust them. tmFloorZ = tmDropoffZ = P_GetFloatp(newSSec, DMU_FLOOR_HEIGHT); tmCeilingZ = P_GetFloatp(newSSec, DMU_CEILING_HEIGHT); diff --git a/doomsday/plugins/common/src/p_mapsetup.c b/doomsday/plugins/common/src/p_mapsetup.c index b6027ec454..e76d3fa844 100644 --- a/doomsday/plugins/common/src/p_mapsetup.c +++ b/doomsday/plugins/common/src/p_mapsetup.c @@ -150,16 +150,15 @@ xsector_t* P_ToXSector(sector_t* sector) } /** - * Given a subsector - find its parent xsector. + * Given a BSP leaf - find its parent xsector. */ -xsector_t* P_ToXSectorOfSubsector(subsector_t* sub) +xsector_t* P_ToXSectorOfBspLeaf(BspLeaf* bspLeaf) { - sector_t* sec; + sector_t* sec; - if(!sub) - return NULL; + if(!bspLeaf) return NULL; - sec = P_GetPtrp(sub, DMU_SECTOR); + sec = P_GetPtrp(bspLeaf, DMU_SECTOR); // Is it a dummy? if(P_IsDummy(sec)) @@ -556,8 +555,8 @@ static void loadMapSpots(void) // Sound sequence origin? if(spot->doomEdNum >= 1400 && spot->doomEdNum < 1410) { - subsector_t* ssec = P_SubsectorAtPointXY(spot->pos[VX], spot->pos[VY]); - xsector_t* xsector = P_ToXSector(P_GetPtrp(ssec, DMU_SECTOR)); + BspLeaf* bspLeaf = P_BspLeafAtPointXY(spot->pos[VX], spot->pos[VY]); + xsector_t* xsector = P_ToXSector(P_GetPtrp(bspLeaf, DMU_SECTOR)); xsector->seqType = spot->doomEdNum - 1400; continue; diff --git a/doomsday/plugins/common/src/p_saveg.c b/doomsday/plugins/common/src/p_saveg.c index 839b6548f6..5d1583e9c1 100644 --- a/doomsday/plugins/common/src/p_saveg.c +++ b/doomsday/plugins/common/src/p_saveg.c @@ -1463,9 +1463,9 @@ static void RestoreMobj(mobj_t *mo, int ver) P_MobjSetPosition(mo); mo->floorZ = - P_GetFloatp(mo->subsector, DMU_FLOOR_HEIGHT); + P_GetFloatp(mo->bspLeaf, DMU_FLOOR_HEIGHT); mo->ceilingZ = - P_GetFloatp(mo->subsector, DMU_CEILING_HEIGHT); + P_GetFloatp(mo->bspLeaf, DMU_CEILING_HEIGHT); return; } @@ -4201,7 +4201,7 @@ static void P_ArchiveSounds(void) if(i == numpolyobjs) { // Sound is attached to a sector, not a polyobj. - sec = P_GetPtrp(P_SubsectorAtPointXY(node->mobj->pos[VX], node->mobj->pos[VY]), + sec = P_GetPtrp(P_BspLeafAtPointXY(node->mobj->pos[VX], node->mobj->pos[VY]), DMU_SECTOR); difference = P_ToIndex(sec); SV_WriteLong(0); // 0 -- sector sound origin. diff --git a/doomsday/plugins/common/src/p_user.c b/doomsday/plugins/common/src/p_user.c index 636f74e270..4cf565c124 100644 --- a/doomsday/plugins/common/src/p_user.c +++ b/doomsday/plugins/common/src/p_user.c @@ -263,7 +263,7 @@ void P_Thrust(player_t *player, angle_t angle, float move) if(!(player->powers[PT_FLIGHT] && !(mo->pos[VZ] <= mo->floorZ))) { #if __JDOOM__ || __JDOOM64__ || __JHERETIC__ - sector_t* sec = P_GetPtrp(mo->subsector, DMU_SECTOR); + sector_t* sec = P_GetPtrp(mo->bspLeaf, DMU_SECTOR); #endif #if __JHEXEN__ const terraintype_t* tt = P_MobjGetFloorTerrainType(mo); @@ -1195,7 +1195,7 @@ void P_PlayerThinkSpecial(player_t* player) { if(!player->plr->mo) return; - if(P_ToXSector(P_GetPtrp(player->plr->mo->subsector, DMU_SECTOR))->special) + if(P_ToXSector(P_GetPtrp(player->plr->mo->bspLeaf, DMU_SECTOR))->special) P_PlayerInSpecialSector(player); #if __JHEXEN__ diff --git a/doomsday/plugins/common/src/p_xgline.c b/doomsday/plugins/common/src/p_xgline.c index 9b8103a01d..39ea9754de 100644 --- a/doomsday/plugins/common/src/p_xgline.c +++ b/doomsday/plugins/common/src/p_xgline.c @@ -1728,7 +1728,7 @@ int C_DECL XLTrav_LineTeleport(linedef_t* newLine, boolean dummy, { mobj->floorClip = 0; - if(mobj->pos[VZ] == P_GetFloatp(mobj->subsector, DMU_FLOOR_HEIGHT)) + if(mobj->pos[VZ] == P_GetFloatp(mobj->bspLeaf, DMU_FLOOR_HEIGHT)) { const terraintype_t* tt = P_MobjGetFloorTerrainType(mobj); diff --git a/doomsday/plugins/common/src/p_xgsec.c b/doomsday/plugins/common/src/p_xgsec.c index 7e38624440..13c7f67d1f 100644 --- a/doomsday/plugins/common/src/p_xgsec.c +++ b/doomsday/plugins/common/src/p_xgsec.c @@ -2198,8 +2198,8 @@ int C_DECL XSTrav_Teleport(sector_t* sector, boolean ceiling, void* context, memcpy(oldpos, thing->pos, sizeof(thing->pos)); oldAngle = thing->angle; - thfloorz = P_GetFloatp(thing->subsector, DMU_FLOOR_HEIGHT); - thceilz = P_GetFloatp(thing->subsector, DMU_CEILING_HEIGHT); + thfloorz = P_GetFloatp(thing->bspLeaf, DMU_FLOOR_HEIGHT); + thceilz = P_GetFloatp(thing->bspLeaf, DMU_CEILING_HEIGHT); aboveFloor = thing->pos[VZ] - thfloorz; // Players get special consideration @@ -2291,7 +2291,7 @@ int C_DECL XSTrav_Teleport(sector_t* sector, boolean ceiling, void* context, thing->floorClip = 0; if(thing->pos[VZ] == - P_GetFloatp(thing->subsector, DMU_FLOOR_HEIGHT)) + P_GetFloatp(thing->bspLeaf, DMU_FLOOR_HEIGHT)) { const terraintype_t* tt = P_MobjGetFloorTerrainType(thing); @@ -2772,7 +2772,7 @@ int XSTrav_SectorChain(thinker_t* th, void* context) (xstrav_sectorchainparams_t*) context; mobj_t* mo = (mobj_t *) th; - if(params->sec == P_GetPtrp(mo->subsector, DMU_SECTOR)) + if(params->sec == P_GetPtrp(mo->bspLeaf, DMU_SECTOR)) { boolean activating; @@ -2808,9 +2808,9 @@ void P_ApplyWind(mobj_t* mo, sector_t* sec) ((info->flags & STF_MISSILE_WIND) && (mo->flags & MF_MISSILE))) { float thfloorz = - P_GetFloatp(mo->subsector, DMU_FLOOR_HEIGHT); + P_GetFloatp(mo->bspLeaf, DMU_FLOOR_HEIGHT); float thceilz = - P_GetFloatp(mo->subsector, DMU_CEILING_HEIGHT); + P_GetFloatp(mo->bspLeaf, DMU_CEILING_HEIGHT); if(!(info->flags & (STF_FLOOR_WIND | STF_CEILING_WIND)) || ((info->flags & STF_FLOOR_WIND) && mo->pos[VZ] <= thfloorz) || @@ -2836,7 +2836,7 @@ int XSTrav_Wind(thinker_t* th, void* context) xstrav_windparams_t* params = (xstrav_windparams_t*) context; mobj_t* mo = (mobj_t *) th; - if(params->sec == P_GetPtrp(mo->subsector, DMU_SECTOR)) + if(params->sec == P_GetPtrp(mo->bspLeaf, DMU_SECTOR)) { P_ApplyWind(mo, params->sec); } @@ -3134,12 +3134,12 @@ D_CMD(MovePlane) p = 2; if(!players[CONSOLEPLAYER].plr->mo) return false; - sector = P_GetPtrp(players[CONSOLEPLAYER].plr->mo->subsector, DMU_SECTOR); + sector = P_GetPtrp(players[CONSOLEPLAYER].plr->mo->bspLeaf, DMU_SECTOR); } else if(!stricmp(argv[1], "at") && argc >= 4) { p = 4; - sector = P_GetPtrp(P_SubsectorAtPointXY((float) strtol(argv[2], 0, 0), (float) strtol(argv[3], 0, 0)), DMU_SECTOR); + sector = P_GetPtrp(P_BspLeafAtPointXY((float) strtol(argv[2], 0, 0), (float) strtol(argv[3], 0, 0)), DMU_SECTOR); } else if(!stricmp(argv[1], "tag") && argc >= 3) { diff --git a/doomsday/plugins/jdoom/include/r_defs.h b/doomsday/plugins/jdoom/include/r_defs.h index 9d135c645b..69fcf810fd 100644 --- a/doomsday/plugins/jdoom/include/r_defs.h +++ b/doomsday/plugins/jdoom/include/r_defs.h @@ -88,7 +88,7 @@ extern xline_t* xlines; xline_t* P_ToXLine(linedef_t* line); xsector_t* P_ToXSector(sector_t* sector); -xsector_t* P_ToXSectorOfSubsector(subsector_t* sub); +xsector_t* P_ToXSectorOfBspLeaf(BspLeaf* sub); /** * Update the specified player's automap. diff --git a/doomsday/plugins/jdoom/src/m_cheat.c b/doomsday/plugins/jdoom/src/m_cheat.c index 570e40dc2e..b03ea87480 100644 --- a/doomsday/plugins/jdoom/src/m_cheat.c +++ b/doomsday/plugins/jdoom/src/m_cheat.c @@ -528,7 +528,7 @@ int Cht_MyPosFunc(const int* args, int player) static void printDebugInfo(player_t* plr) { char textBuffer[256]; - subsector_t* sub; + BspLeaf* sub; ddstring_t* path, *mapPath; Uri* uri, *mapUri; @@ -546,8 +546,8 @@ static void printDebugInfo(player_t* plr) // Also print some information to the console. Con_Message("%s", textBuffer); - sub = plr->plr->mo->subsector; - Con_Message("\nSubsector %i / Sector %i:\n", P_ToIndex(sub), P_ToIndex(P_GetPtrp(sub, DMU_SECTOR))); + sub = plr->plr->mo->bspLeaf; + Con_Message("\nBspLeaf %i / Sector %i:\n", P_ToIndex(sub), P_ToIndex(P_GetPtrp(sub, DMU_SECTOR))); uri = Materials_ComposeUri(P_GetIntp(sub, DMU_FLOOR_MATERIAL)); path = Uri_ToString(uri); diff --git a/doomsday/plugins/jdoom/src/p_enemy.c b/doomsday/plugins/jdoom/src/p_enemy.c index 134318b495..f78eb8b9ca 100644 --- a/doomsday/plugins/jdoom/src/p_enemy.c +++ b/doomsday/plugins/jdoom/src/p_enemy.c @@ -101,7 +101,7 @@ static const float dirSpeed[8][2] = void P_NoiseAlert(mobj_t *target, mobj_t *emitter) { VALIDCOUNT++; - P_RecursiveSound(target, P_GetPtrp(emitter->subsector, DMU_SECTOR), 0); + P_RecursiveSound(target, P_GetPtrp(emitter->bspLeaf, DMU_SECTOR), 0); } static boolean checkMeleeRange(mobj_t *actor) @@ -531,7 +531,7 @@ void C_DECL A_Look(mobj_t* actor) sector_t* sec = NULL; mobj_t* targ; - sec = P_GetPtrp(actor->subsector, DMU_SECTOR); + sec = P_GetPtrp(actor->bspLeaf, DMU_SECTOR); if(!sec) return; @@ -1379,7 +1379,7 @@ void C_DECL A_PainShootSkull(mobj_t* actor, angle_t angle) if(!(newmobj = P_SpawnMobj3fv(MT_SKULL, pos, angle, 0))) return; - sec = P_GetPtrp(newmobj->subsector, DMU_SECTOR); + sec = P_GetPtrp(newmobj->bspLeaf, DMU_SECTOR); // Check to see if the new Lost Soul's z value is above the // ceiling of its new sector, or below the floor. If so, kill it. diff --git a/doomsday/plugins/jdoom/src/p_inter.c b/doomsday/plugins/jdoom/src/p_inter.c index 08cf513869..8bd154af26 100644 --- a/doomsday/plugins/jdoom/src/p_inter.c +++ b/doomsday/plugins/jdoom/src/p_inter.c @@ -1112,7 +1112,7 @@ int P_DamageMobj2(mobj_t* target, mobj_t* inflictor, mobj_t* source, if(player) { // Player specific. // End of game hell hack. - if(P_ToXSectorOfSubsector(target->subsector)->special == 11 && + if(P_ToXSectorOfBspLeaf(target->bspLeaf)->special == 11 && damage >= target->health) { damage = target->health - 1; diff --git a/doomsday/plugins/jdoom/src/p_mobj.c b/doomsday/plugins/jdoom/src/p_mobj.c index d33ee08c46..c02bc77528 100644 --- a/doomsday/plugins/jdoom/src/p_mobj.c +++ b/doomsday/plugins/jdoom/src/p_mobj.c @@ -71,7 +71,7 @@ const terraintype_t* P_MobjGetFloorTerrainType(mobj_t* mo) { - sector_t* sec = P_GetPtrp(mo->subsector, DMU_SECTOR); + sector_t* sec = P_GetPtrp(mo->bspLeaf, DMU_SECTOR); return P_PlaneMaterialTerrainType(sec, PLN_FLOOR); } @@ -150,7 +150,7 @@ float P_MobjGetFriction(mobj_t *mo) return FRICTION_FLY; } - return XS_Friction(P_GetPtrp(mo->subsector, DMU_SECTOR)); + return XS_Friction(P_GetPtrp(mo->bspLeaf, DMU_SECTOR)); } static __inline boolean isInWalkState(player_t* pl) @@ -167,7 +167,7 @@ static float getFriction(mobj_t* mo) } #if __JHERETIC__ - if(P_ToXSector(P_GetPtrp(mo->subsector, DMU_SECTOR))->special == 15) + if(P_ToXSector(P_GetPtrp(mo->bspLeaf, DMU_SECTOR))->special == 15) { // Friction_Low return FRICTION_LOW; } @@ -330,7 +330,7 @@ void P_MobjMoveZ(mobj_t* mo) targetZ = mo->pos[VZ] + mo->mom[MZ]; floorZ = (mo->onMobj? mo->onMobj->pos[VZ] + mo->onMobj->height : mo->floorZ); ceilingZ = mo->ceilingZ; - gravity = XS_Gravity(P_GetPtrp(mo->subsector, DMU_SECTOR)); + gravity = XS_Gravity(P_GetPtrp(mo->bspLeaf, DMU_SECTOR)); if((mo->flags2 & MF2_FLY) && mo->player && mo->onMobj && mo->pos[VZ] > mo->onMobj->pos[VZ] + mo->onMobj->height) @@ -478,7 +478,7 @@ void P_MobjMoveZ(mobj_t* mo) if(!((mo->flags ^ MF_MISSILE) & (MF_MISSILE | MF_NOCLIP))) { material_t* mat = - P_GetPtrp(mo->subsector, DMU_FLOOR_MATERIAL); + P_GetPtrp(mo->bspLeaf, DMU_FLOOR_MATERIAL); // Don't explode against sky. if(P_GetIntp(mat, DMU_FLAGS) & MATF_SKYMASK) @@ -508,7 +508,7 @@ void P_MobjMoveZ(mobj_t* mo) if(!((mo->flags ^ MF_MISSILE) & (MF_MISSILE | MF_NOCLIP))) { material_t* mat = - P_GetPtrp(mo->subsector, DMU_CEILING_MATERIAL); + P_GetPtrp(mo->bspLeaf, DMU_CEILING_MATERIAL); // Don't explode against sky. if(P_GetIntp(mat, DMU_FLAGS) & MATF_SKYMASK) @@ -597,10 +597,10 @@ void P_MobjThinker(mobj_t* mo) { if(mo->moveDir > 0) mo->pos[VZ] = - P_GetFloatp(mo->subsector, DMU_FLOOR_HEIGHT); + P_GetFloatp(mo->bspLeaf, DMU_FLOOR_HEIGHT); else mo->pos[VZ] = - P_GetFloatp(mo->subsector, DMU_CEILING_HEIGHT); + P_GetFloatp(mo->bspLeaf, DMU_CEILING_HEIGHT); mo->pos[VZ] += FIX2FLT(mo->moveDir); return; @@ -828,9 +828,9 @@ mobj_t* P_SpawnMobj3f(mobjtype_t type, float x, float y, float z, P_MobjSetState(mo, P_GetState(mo->type, SN_SPAWN)); P_MobjSetPosition(mo); - mo->floorZ = P_GetFloatp(mo->subsector, DMU_FLOOR_HEIGHT); + mo->floorZ = P_GetFloatp(mo->bspLeaf, DMU_FLOOR_HEIGHT); mo->dropOffZ = mo->floorZ; - mo->ceilingZ = P_GetFloatp(mo->subsector, DMU_CEILING_HEIGHT); + mo->ceilingZ = P_GetFloatp(mo->bspLeaf, DMU_CEILING_HEIGHT); if((spawnFlags & MSF_Z_CEIL) || (info->flags & MF_SPAWNCEILING)) { @@ -859,7 +859,7 @@ mobj_t* P_SpawnMobj3f(mobjtype_t type, float x, float y, float z, mo->floorClip = 0; if((mo->flags2 & MF2_FLOORCLIP) && - mo->pos[VZ] == P_GetFloatp(mo->subsector, DMU_FLOOR_HEIGHT)) + mo->pos[VZ] == P_GetFloatp(mo->bspLeaf, DMU_FLOOR_HEIGHT)) { const terraintype_t* tt = P_MobjGetFloorTerrainType(mo); diff --git a/doomsday/plugins/jdoom/src/p_oldsvg.c b/doomsday/plugins/jdoom/src/p_oldsvg.c index 816382ad62..1ff64065ce 100644 --- a/doomsday/plugins/jdoom/src/p_oldsvg.c +++ b/doomsday/plugins/jdoom/src/p_oldsvg.c @@ -338,8 +338,8 @@ static void SV_ReadMobj(void) mo->dPlayer->lookDir = 0; /* $unifiedangles */ } P_MobjSetPosition(mo); - mo->floorZ = P_GetFloatp(mo->subsector, DMU_FLOOR_HEIGHT); - mo->ceilingZ = P_GetFloatp(mo->subsector, DMU_CEILING_HEIGHT); + mo->floorZ = P_GetFloatp(mo->bspLeaf, DMU_FLOOR_HEIGHT); + mo->ceilingZ = P_GetFloatp(mo->bspLeaf, DMU_CEILING_HEIGHT); } void P_v19_UnArchivePlayers(void) diff --git a/doomsday/plugins/jdoom/src/p_spec.c b/doomsday/plugins/jdoom/src/p_spec.c index b8c0db5377..c5f521fbd4 100644 --- a/doomsday/plugins/jdoom/src/p_spec.c +++ b/doomsday/plugins/jdoom/src/p_spec.c @@ -794,7 +794,7 @@ static void shootSpecialLine(mobj_t *thing, linedef_t *line) */ void P_PlayerInSpecialSector(player_t* player) { - sector_t* sector = P_GetPtrp(player->plr->mo->subsector, DMU_SECTOR); + sector_t* sector = P_GetPtrp(player->plr->mo->bspLeaf, DMU_SECTOR); if(IS_CLIENT) return; diff --git a/doomsday/plugins/jdoom/src/p_telept.c b/doomsday/plugins/jdoom/src/p_telept.c index 0983c3283e..1cb42eecdc 100644 --- a/doomsday/plugins/jdoom/src/p_telept.c +++ b/doomsday/plugins/jdoom/src/p_telept.c @@ -77,7 +77,7 @@ static int findMobj(thinker_t* th, void* context) // Must be in the specified sector? if(params->sec && - params->sec != P_GetPtrp(mo->subsector, DMU_SECTOR)) + params->sec != P_GetPtrp(mo->bspLeaf, DMU_SECTOR)) return false; // Continue iteration. // Found it! @@ -171,7 +171,7 @@ int EV_Teleport(linedef_t* line, int side, mobj_t* mo, boolean spawnFog) { mo->floorClip = 0; - if(mo->pos[VZ] == P_GetFloatp(mo->subsector, DMU_FLOOR_HEIGHT)) + if(mo->pos[VZ] == P_GetFloatp(mo->bspLeaf, DMU_FLOOR_HEIGHT)) { const terraintype_t* tt = P_MobjGetFloorTerrainType(mo); diff --git a/doomsday/plugins/jdoom64/include/p_mobj.h b/doomsday/plugins/jdoom64/include/p_mobj.h index e594f97478..bc37f1b3c6 100644 --- a/doomsday/plugins/jdoom64/include/p_mobj.h +++ b/doomsday/plugins/jdoom64/include/p_mobj.h @@ -94,7 +94,7 @@ * A walking creature will have its z equal to the floor * it is standing on. * - * The sound code uses the x,y, and subsector fields + * The sound code uses the x,y, and BSP leaf fields * to do stereo positioning of any sound effited by the mobj_t. * * The play simulation uses the blocklinks, x,y,z, radius, height @@ -106,8 +106,8 @@ * * Every mobj_t is linked into a single sector * based on its origin coordinates. - * The subsector_t is found with P_SubsectorAtPointXY(x,y), - * and the sector_t can be found with subsector->sector. + * The BspLeaf is found with P_BspLeafAtPointXY(x,y), + * and the sector_t can be found with bspLeaf->sector. * The sector links are only used by the rendering code, * the play simulation does not care about them at all. * @@ -122,10 +122,10 @@ * every linedef_t that it contains a piece of, and every * interactable mobj_t that has its origin contained. * - * A valid mobj_t is a mobj_t that has the proper subsector_t + * A valid mobj_t is a mobj_t that has the proper BspLeaf * filled in for its xy coordinates and is linked into the - * sector from which the subsector was made, or has the - * MF_NOSECTOR flag set (the subsector_t needs to be valid + * sector from which the BSP leaf was made, or has the + * MF_NOSECTOR flag set (the BspLeaf needs to be valid * even if MF_NOSECTOR is set). * Links should only be modified by the P_[Un]SetThingPosition() * functions. diff --git a/doomsday/plugins/jdoom64/include/r_defs.h b/doomsday/plugins/jdoom64/include/r_defs.h index 879ec4ad01..a8930fa14d 100644 --- a/doomsday/plugins/jdoom64/include/r_defs.h +++ b/doomsday/plugins/jdoom64/include/r_defs.h @@ -122,7 +122,7 @@ extern boolean mapSetup; xline_t* P_ToXLine(linedef_t* line); xsector_t* P_ToXSector(sector_t* sector); -xsector_t* P_ToXSectorOfSubsector(subsector_t* sub); +xsector_t* P_ToXSectorOfBspLeaf(BspLeaf* sub); /** * Update the specified player's automap. diff --git a/doomsday/plugins/jdoom64/src/m_cheat.c b/doomsday/plugins/jdoom64/src/m_cheat.c index 4e76f68932..5692885e2d 100644 --- a/doomsday/plugins/jdoom64/src/m_cheat.c +++ b/doomsday/plugins/jdoom64/src/m_cheat.c @@ -214,7 +214,7 @@ boolean Cht_PowerUpFunc(player_t* plr, cheatseq_t* cheat) void printDebugInfo(player_t* plr) { char textBuffer[256]; - subsector_t* sub; + BspLeaf* sub; ddstring_t* path, *mapPath; Uri* uri, *mapUri; @@ -232,8 +232,8 @@ void printDebugInfo(player_t* plr) // Also print some information to the console. Con_Message("%s", textBuffer); - sub = plr->plr->mo->subsector; - Con_Message("\nSubsector %i:\n", P_ToIndex(sub)); + sub = plr->plr->mo->bspLeaf; + Con_Message("\nBspLeaf %i:\n", P_ToIndex(sub)); uri = Materials_ComposeUri(P_GetIntp(sub, DMU_FLOOR_MATERIAL)); path = Uri_ToString(uri); diff --git a/doomsday/plugins/jdoom64/src/p_enemy.c b/doomsday/plugins/jdoom64/src/p_enemy.c index 5168e39abb..9b06b84c94 100644 --- a/doomsday/plugins/jdoom64/src/p_enemy.c +++ b/doomsday/plugins/jdoom64/src/p_enemy.c @@ -115,7 +115,7 @@ static const float dirSpeed[8][2] = void P_NoiseAlert(mobj_t *target, mobj_t *emitter) { VALIDCOUNT++; - P_RecursiveSound(target, P_GetPtrp(emitter->subsector, DMU_SECTOR), 0); + P_RecursiveSound(target, P_GetPtrp(emitter->bspLeaf, DMU_SECTOR), 0); } static boolean checkMeleeRange(mobj_t *actor) @@ -863,7 +863,7 @@ void C_DECL A_Look(mobj_t *actor) sector_t *sec = NULL; mobj_t *targ; - sec = P_GetPtrp(actor->subsector, DMU_SECTOR); + sec = P_GetPtrp(actor->bspLeaf, DMU_SECTOR); if(!sec) return; @@ -1741,7 +1741,7 @@ void C_DECL A_PainShootSkull(mobj_t *actor, angle_t angle) if(!(newmobj = P_SpawnMobj3fv(MT_SKULL, pos, angle, 0))) return; - sec = P_GetPtrp(newmobj->subsector, DMU_SECTOR); + sec = P_GetPtrp(newmobj->bspLeaf, DMU_SECTOR); // Check to see if the new Lost Soul's z value is above the // ceiling of its new sector, or below the floor. If so, kill it. diff --git a/doomsday/plugins/jdoom64/src/p_inter.c b/doomsday/plugins/jdoom64/src/p_inter.c index f999ec174c..98f4de9a2d 100644 --- a/doomsday/plugins/jdoom64/src/p_inter.c +++ b/doomsday/plugins/jdoom64/src/p_inter.c @@ -1154,7 +1154,7 @@ int P_DamageMobj2(mobj_t* target, mobj_t* inflictor, mobj_t* source, if(player) { // End of game hell hack. - if(P_ToXSectorOfSubsector(target->subsector)->special == 11 && + if(P_ToXSectorOfBspLeaf(target->bspLeaf)->special == 11 && damage >= target->health) { damage = target->health - 1; diff --git a/doomsday/plugins/jdoom64/src/p_mobj.c b/doomsday/plugins/jdoom64/src/p_mobj.c index 4e07667562..f20326fbbc 100644 --- a/doomsday/plugins/jdoom64/src/p_mobj.c +++ b/doomsday/plugins/jdoom64/src/p_mobj.c @@ -77,7 +77,7 @@ const terraintype_t* P_MobjGetFloorTerrainType(mobj_t* mo) { - sector_t* sec = P_GetPtrp(mo->subsector, DMU_SECTOR); + sector_t* sec = P_GetPtrp(mo->bspLeaf, DMU_SECTOR); return P_PlaneMaterialTerrainType(sec, PLN_FLOOR); } @@ -156,7 +156,7 @@ float P_MobjGetFriction(mobj_t *mo) return FRICTION_FLY; } - return XS_Friction(P_GetPtrp(mo->subsector, DMU_SECTOR)); + return XS_Friction(P_GetPtrp(mo->bspLeaf, DMU_SECTOR)); } static float getFriction(mobj_t* mo) @@ -168,7 +168,7 @@ static float getFriction(mobj_t* mo) } #if __JHERETIC__ - if(P_ToXSector(P_GetPtrp(mo->subsector, DMU_SECTOR))->special == 15) + if(P_ToXSector(P_GetPtrp(mo->bspLeaf, DMU_SECTOR))->special == 15) { // Friction_Low return FRICTION_LOW; } @@ -324,7 +324,7 @@ void P_MobjMoveZ(mobj_t* mo) { float gravity, dist, delta; - gravity = XS_Gravity(P_GetPtrp(mo->subsector, DMU_SECTOR)); + gravity = XS_Gravity(P_GetPtrp(mo->bspLeaf, DMU_SECTOR)); // $democam: cameramen get special z movement. if(P_CameraZMovement(mo)) @@ -561,7 +561,7 @@ void P_MobjMoveZ(mobj_t* mo) if(!((mo->flags ^ MF_MISSILE) & (MF_MISSILE | MF_NOCLIP))) { // Don't explode against sky. - if(P_GetIntp(P_GetPtrp(mo->subsector, DMU_CEILING_MATERIAL), + if(P_GetIntp(P_GetPtrp(mo->bspLeaf, DMU_CEILING_MATERIAL), DMU_FLAGS) & MATF_SKYMASK) { P_MobjRemove(mo, false); @@ -623,10 +623,10 @@ void P_MobjThinker(mobj_t *mobj) { if(mobj->moveDir > 0) mobj->pos[VZ] = - P_GetFloatp(mobj->subsector, DMU_FLOOR_HEIGHT); + P_GetFloatp(mobj->bspLeaf, DMU_FLOOR_HEIGHT); else mobj->pos[VZ] = - P_GetFixedp(mobj->subsector, DMU_CEILING_HEIGHT); + P_GetFixedp(mobj->bspLeaf, DMU_CEILING_HEIGHT); mobj->pos[VZ] += FIX2FLT(mobj->moveDir); return; @@ -848,12 +848,12 @@ mobj_t* P_SpawnMobj3f(mobjtype_t type, float x, float y, float z, // Must link before setting state (ID assigned for the mo). P_MobjSetState(mo, P_GetState(mo->type, SN_SPAWN)); - // Set subsector and/or block links. + // Set BSP leaf and/or block links. P_MobjSetPosition(mo); - mo->floorZ = P_GetFloatp(mo->subsector, DMU_FLOOR_HEIGHT); + mo->floorZ = P_GetFloatp(mo->bspLeaf, DMU_FLOOR_HEIGHT); mo->dropOffZ = mo->floorZ; - mo->ceilingZ = P_GetFloatp(mo->subsector, DMU_CEILING_HEIGHT); + mo->ceilingZ = P_GetFloatp(mo->bspLeaf, DMU_CEILING_HEIGHT); if((spawnFlags & MSF_Z_CEIL) || (info->flags & MF_SPAWNCEILING)) { @@ -889,7 +889,7 @@ mobj_t* P_SpawnMobj3f(mobjtype_t type, float x, float y, float z, mo->floorClip = 0; if((mo->flags2 & MF2_FLOORCLIP) && - mo->pos[VZ] == P_GetFloatp(mo->subsector, DMU_FLOOR_HEIGHT)) + mo->pos[VZ] == P_GetFloatp(mo->bspLeaf, DMU_FLOOR_HEIGHT)) { const terraintype_t* tt = P_MobjGetFloorTerrainType(mo); diff --git a/doomsday/plugins/jdoom64/src/p_spec.c b/doomsday/plugins/jdoom64/src/p_spec.c index 2c36eb5aca..cc6a71457d 100644 --- a/doomsday/plugins/jdoom64/src/p_spec.c +++ b/doomsday/plugins/jdoom64/src/p_spec.c @@ -884,7 +884,7 @@ void P_ShootSpecialLine(mobj_t *thing, linedef_t *line) */ void P_PlayerInSpecialSector(player_t *player) { - sector_t *sector = P_GetPtrp(player->plr->mo->subsector, DMU_SECTOR); + sector_t *sector = P_GetPtrp(player->plr->mo->bspLeaf, DMU_SECTOR); if(IS_CLIENT) return; diff --git a/doomsday/plugins/jdoom64/src/p_telept.c b/doomsday/plugins/jdoom64/src/p_telept.c index 156bc646d5..4e8279b260 100644 --- a/doomsday/plugins/jdoom64/src/p_telept.c +++ b/doomsday/plugins/jdoom64/src/p_telept.c @@ -82,7 +82,7 @@ static int findMobj(thinker_t* th, void* context) // Must be in the specified sector? if(params->sec && - params->sec != P_GetPtrp(mo->subsector, DMU_SECTOR)) + params->sec != P_GetPtrp(mo->bspLeaf, DMU_SECTOR)) return false; // Continue iteration. // Found it! @@ -173,7 +173,7 @@ int EV_Teleport(linedef_t* line, int side, mobj_t* mo, boolean spawnFog) { mo->floorClip = 0; - if(mo->pos[VZ] == P_GetFloatp(mo->subsector, DMU_FLOOR_HEIGHT)) + if(mo->pos[VZ] == P_GetFloatp(mo->bspLeaf, DMU_FLOOR_HEIGHT)) { const terraintype_t* tt = P_MobjGetFloorTerrainType(mo); @@ -313,7 +313,7 @@ static int fadeSpawn(thinker_t* th, void* context) mobjtype_t spawntype; if(params->sec && - params->sec != P_GetPtrp(origin->subsector, DMU_SECTOR)) + params->sec != P_GetPtrp(origin->bspLeaf, DMU_SECTOR)) return false; // Continue iteration. // Only fade spawn origins of a certain type. @@ -400,7 +400,7 @@ int PIT_ChangeMobjFlags(thinker_t* th, void* context) mobj_t* mo = (mobj_t*) th; if(params->sec && - params->sec != P_GetPtrp(mo->subsector, DMU_SECTOR)) + params->sec != P_GetPtrp(mo->bspLeaf, DMU_SECTOR)) return false; // Continue iteration. if(params->notPlayers && mo->player) diff --git a/doomsday/plugins/jheretic/include/r_defs.h b/doomsday/plugins/jheretic/include/r_defs.h index 92d05405a4..4d12d21f58 100644 --- a/doomsday/plugins/jheretic/include/r_defs.h +++ b/doomsday/plugins/jheretic/include/r_defs.h @@ -97,7 +97,7 @@ xline_t* P_ToXLine(linedef_t* line); xline_t* P_GetXLine(uint index); xsector_t* P_ToXSector(sector_t* sector); xsector_t* P_GetXSector(uint index); -xsector_t* P_ToXSectorOfSubsector(subsector_t* sub); +xsector_t* P_ToXSectorOfBspLeaf(BspLeaf* sub); /** * Update the specified player's automap. diff --git a/doomsday/plugins/jheretic/src/m_cheat.c b/doomsday/plugins/jheretic/src/m_cheat.c index ee311665ed..5955612462 100644 --- a/doomsday/plugins/jheretic/src/m_cheat.c +++ b/doomsday/plugins/jheretic/src/m_cheat.c @@ -374,7 +374,7 @@ static void printDebugInfo(int player) { player_t* plr = &players[player]; char textBuffer[256]; - subsector_t* sub; + BspLeaf* sub; ddstring_t* path, *mapPath; Uri* uri, *mapUri; @@ -391,8 +391,8 @@ static void printDebugInfo(int player) // Also print some information to the console. Con_Message("%s", textBuffer); - sub = plr->plr->mo->subsector; - Con_Message("\nSubsector %i:\n", P_ToIndex(sub)); + sub = plr->plr->mo->bspLeaf; + Con_Message("\nBspLeaf %i:\n", P_ToIndex(sub)); uri = Materials_ComposeUri(P_GetIntp(sub, DMU_FLOOR_MATERIAL)); path = Uri_ToString(uri); diff --git a/doomsday/plugins/jheretic/src/p_enemy.c b/doomsday/plugins/jheretic/src/p_enemy.c index 3956f77a80..073e7f4bc4 100644 --- a/doomsday/plugins/jheretic/src/p_enemy.c +++ b/doomsday/plugins/jheretic/src/p_enemy.c @@ -110,7 +110,7 @@ void P_ClearBodyQueue(void) void P_NoiseAlert(mobj_t *target, mobj_t *emitter) { VALIDCOUNT++; - P_RecursiveSound(target, P_GetPtrp(emitter->subsector, DMU_SECTOR), 0); + P_RecursiveSound(target, P_GetPtrp(emitter->bspLeaf, DMU_SECTOR), 0); } boolean P_CheckMeleeRange(mobj_t *actor) @@ -552,7 +552,7 @@ void C_DECL A_Look(mobj_t *actor) // Any shot will wake up actor->threshold = 0; - sec = P_GetPtrp(actor->subsector, DMU_SECTOR); + sec = P_GetPtrp(actor->bspLeaf, DMU_SECTOR); targ = P_ToXSector(sec)->soundTarget; if(targ && (targ->flags & MF_SHOOTABLE)) { @@ -2136,7 +2136,7 @@ void C_DECL A_SpawnTeleGlitter(mobj_t* actor) if((mo = P_SpawnMobj3f(MT_TELEGLITTER, actor->pos[VX] + ((P_Random() & 31) - 16), actor->pos[VY] + ((P_Random() & 31) - 16), - P_GetFloatp(actor->subsector, DMU_FLOOR_HEIGHT), + P_GetFloatp(actor->bspLeaf, DMU_FLOOR_HEIGHT), P_Random() << 24, 0))) { mo->mom[MZ] = 1.0f / 4; @@ -2154,7 +2154,7 @@ void C_DECL A_SpawnTeleGlitter2(mobj_t* actor) if((mo = P_SpawnMobj3f(MT_TELEGLITTER2, actor->pos[VX] + ((P_Random() & 31) - 16), actor->pos[VY] + ((P_Random() & 31) - 16), - P_GetFloatp(actor->subsector, DMU_FLOOR_HEIGHT), + P_GetFloatp(actor->bspLeaf, DMU_FLOOR_HEIGHT), P_Random() << 24, 0))) { mo->mom[MZ] = 1.0f / 4; diff --git a/doomsday/plugins/jheretic/src/p_mobj.c b/doomsday/plugins/jheretic/src/p_mobj.c index 01e657f4f1..12415dd4e4 100644 --- a/doomsday/plugins/jheretic/src/p_mobj.c +++ b/doomsday/plugins/jheretic/src/p_mobj.c @@ -71,7 +71,7 @@ mobj_t *missileMobj; const terraintype_t* P_MobjGetFloorTerrainType(mobj_t* mo) { - sector_t* sec = P_GetPtrp(mo->subsector, DMU_SECTOR); + sector_t* sec = P_GetPtrp(mo->bspLeaf, DMU_SECTOR); return P_PlaneMaterialTerrainType(sec, PLN_FLOOR); } @@ -275,7 +275,7 @@ void P_WindThrust(mobj_t *mo) { static int windTab[3] = { 2048 * 5, 2048 * 10, 2048 * 25 }; - sector_t *sec = P_GetPtrp(mo->subsector, DMU_SECTOR); + sector_t *sec = P_GetPtrp(mo->bspLeaf, DMU_SECTOR); int special = P_ToXSector(sec)->special; switch(special) @@ -317,7 +317,7 @@ float P_MobjGetFriction(mobj_t *mo) } else { - sector_t *sec = P_GetPtrp(mo->subsector, DMU_SECTOR); + sector_t *sec = P_GetPtrp(mo->bspLeaf, DMU_SECTOR); if(P_ToXSector(sec)->special == 15) { @@ -471,7 +471,7 @@ void P_MobjMoveZ(mobj_t *mo) if(P_CameraZMovement(mo)) return; - gravity = XS_Gravity(P_GetPtrp(mo->subsector, DMU_SECTOR)); + gravity = XS_Gravity(P_GetPtrp(mo->bspLeaf, DMU_SECTOR)); // $voodoodolls: Check for smooth step up unless a voodoo doll. if(mo->player && mo->player->plr->mo == mo && mo->pos[VZ] < mo->floorZ) @@ -683,7 +683,7 @@ void P_MobjMoveZ(mobj_t *mo) if((mo->flags & MF_MISSILE) && !(mo->flags & MF_NOCLIP)) { - if(P_GetIntp(P_GetPtrp(mo->subsector, DMU_CEILING_MATERIAL), + if(P_GetIntp(P_GetPtrp(mo->bspLeaf, DMU_CEILING_MATERIAL), DMU_FLAGS) & MATF_SKYMASK) { #if __JHERETIC__ @@ -1041,12 +1041,12 @@ mobj_t* P_SpawnMobj3f(mobjtype_t type, float x, float y, float z, mo->type == MT_MACEFX3) mo->special3 = 1000; - // Set subsector and/or block links. + // Link the mobj into the world. P_MobjSetPosition(mo); - mo->floorZ = P_GetFloatp(mo->subsector, DMU_FLOOR_HEIGHT); + mo->floorZ = P_GetFloatp(mo->bspLeaf, DMU_FLOOR_HEIGHT); mo->dropOffZ = mo->floorZ; - mo->ceilingZ = P_GetFloatp(mo->subsector, DMU_CEILING_HEIGHT); + mo->ceilingZ = P_GetFloatp(mo->bspLeaf, DMU_CEILING_HEIGHT); if((spawnFlags & MSF_Z_CEIL) || (info->flags & MF_SPAWNCEILING)) { @@ -1076,7 +1076,7 @@ mobj_t* P_SpawnMobj3f(mobjtype_t type, float x, float y, float z, mo->floorClip = 0; if((mo->flags2 & MF2_FLOORCLIP) && - mo->pos[VZ] == P_GetFloatp(mo->subsector, DMU_FLOOR_HEIGHT)) + mo->pos[VZ] == P_GetFloatp(mo->bspLeaf, DMU_FLOOR_HEIGHT)) { const terraintype_t* tt = P_MobjGetFloorTerrainType(mo); @@ -1108,13 +1108,13 @@ mobj_t* P_SpawnMobj3fv(mobjtype_t type, const float pos[3], angle_t angle, void P_RepositionMace(mobj_t* mo) { mapspotid_t spot; - subsector_t* ss; + BspLeaf* ss; P_MobjUnsetPosition(mo); spot = maceSpots[P_Random() % maceSpotCount]; mo->pos[VX] = mapSpots[spot].pos[VX]; mo->pos[VY] = mapSpots[spot].pos[VY]; - ss = P_SubsectorAtPointXY(mo->pos[VX], mo->pos[VY]); + ss = P_BspLeafAtPointXY(mo->pos[VX], mo->pos[VY]); mo->floorZ = P_GetFloatp(ss, DMU_CEILING_HEIGHT); mo->pos[VZ] = mo->floorZ; @@ -1186,7 +1186,7 @@ boolean P_HitFloor(mobj_t* thing) return false; } - if(thing->floorZ != P_GetFloatp(thing->subsector, DMU_FLOOR_HEIGHT)) + if(thing->floorZ != P_GetFloatp(thing->bspLeaf, DMU_FLOOR_HEIGHT)) { // Don't splash if landing on the edge above water/lava/etc.... return false; diff --git a/doomsday/plugins/jheretic/src/p_oldsvg.c b/doomsday/plugins/jheretic/src/p_oldsvg.c index cfe688c23a..a0c1dd1c6b 100644 --- a/doomsday/plugins/jheretic/src/p_oldsvg.c +++ b/doomsday/plugins/jheretic/src/p_oldsvg.c @@ -252,7 +252,7 @@ static void SV_v13_ReadMobj(void) SV_v13_ReadLong(); SV_v13_ReadLong(); - // Subsector. + // BspLeaf. SV_v13_ReadLong(); floorz = FIX2FLT(SV_v13_ReadLong()); @@ -355,8 +355,8 @@ static void SV_v13_ReadMobj(void) mo->player->plr->mo->dPlayer = mo->player->plr; } P_MobjSetPosition(mo); - mo->floorZ = P_GetFloatp(mo->subsector, DMU_FLOOR_HEIGHT); - mo->ceilingZ = P_GetFloatp(mo->subsector, DMU_CEILING_HEIGHT); + mo->floorZ = P_GetFloatp(mo->bspLeaf, DMU_FLOOR_HEIGHT); + mo->ceilingZ = P_GetFloatp(mo->bspLeaf, DMU_CEILING_HEIGHT); } void P_v13_UnArchivePlayers(void) diff --git a/doomsday/plugins/jheretic/src/p_spec.c b/doomsday/plugins/jheretic/src/p_spec.c index b621ad6719..ba8ffbbca8 100644 --- a/doomsday/plugins/jheretic/src/p_spec.c +++ b/doomsday/plugins/jheretic/src/p_spec.c @@ -959,7 +959,7 @@ static void P_ShootSpecialLine(mobj_t* thing, linedef_t* line) */ void P_PlayerInSpecialSector(player_t *player) { - sector_t *sector = P_GetPtrp(player->plr->mo->subsector, DMU_SECTOR); + sector_t *sector = P_GetPtrp(player->plr->mo->bspLeaf, DMU_SECTOR); // Falling, not all the way down yet? if(player->plr->mo->pos[VZ] != P_GetFloatp(sector, DMU_FLOOR_HEIGHT)) @@ -1332,7 +1332,7 @@ void P_PlayerInWindSector(player_t* player) 2048.0 / FRACUNIT * 30, 2048.0 / FRACUNIT * 35 }; - sector_t* sector = P_GetPtrp(player->plr->mo->subsector, DMU_SECTOR); + sector_t* sector = P_GetPtrp(player->plr->mo->bspLeaf, DMU_SECTOR); xsector_t* xsector = P_ToXSector(sector); switch(xsector->special) diff --git a/doomsday/plugins/jheretic/src/p_telept.c b/doomsday/plugins/jheretic/src/p_telept.c index 560f60ac7e..cccb3a000b 100644 --- a/doomsday/plugins/jheretic/src/p_telept.c +++ b/doomsday/plugins/jheretic/src/p_telept.c @@ -143,7 +143,7 @@ boolean P_Teleport(mobj_t* mo, float x, float y, angle_t angle, boolean spawnFog mo->floorClip = 0; if(mo->pos[VZ] == - P_GetFloatp(mo->subsector, DMU_FLOOR_HEIGHT)) + P_GetFloatp(mo->bspLeaf, DMU_FLOOR_HEIGHT)) { const terraintype_t* tt = P_MobjGetFloorTerrainType(mo); @@ -186,7 +186,7 @@ static int findMobj(thinker_t* th, void* context) // Must be in the specified sector? if(params->sec && - params->sec != P_GetPtrp(mo->subsector, DMU_SECTOR)) + params->sec != P_GetPtrp(mo->bspLeaf, DMU_SECTOR)) return false; // Continue iteration. // Found it! diff --git a/doomsday/plugins/jhexen/include/r_defs.h b/doomsday/plugins/jhexen/include/r_defs.h index 044b92044d..05061e7a0b 100644 --- a/doomsday/plugins/jhexen/include/r_defs.h +++ b/doomsday/plugins/jhexen/include/r_defs.h @@ -65,7 +65,7 @@ xline_t* P_ToXLine(linedef_t* line); xline_t* P_GetXLine(uint index); xsector_t* P_ToXSector(sector_t* sector); xsector_t* P_GetXSector(uint index); -xsector_t* P_ToXSectorOfSubsector(subsector_t* sub); +xsector_t* P_ToXSectorOfBspLeaf(BspLeaf* sub); /** * Update the specified player's automap. diff --git a/doomsday/plugins/jhexen/src/hrefresh.c b/doomsday/plugins/jhexen/src/hrefresh.c index 8b6555590b..e6b7a86d27 100644 --- a/doomsday/plugins/jhexen/src/hrefresh.c +++ b/doomsday/plugins/jhexen/src/hrefresh.c @@ -213,7 +213,7 @@ static void rendPlayerView(int player) // Check for the sector special 200: use sky2. // I wonder where this is used? - if(P_ToXSectorOfSubsector(plr->plr->mo->subsector)->special == 200) + if(P_ToXSectorOfBspLeaf(plr->plr->mo->bspLeaf)->special == 200) { special200 = true; R_SkyParams(0, DD_DISABLE, NULL); diff --git a/doomsday/plugins/jhexen/src/m_cheat.c b/doomsday/plugins/jhexen/src/m_cheat.c index 4d9481f0c3..da4925a2e0 100644 --- a/doomsday/plugins/jhexen/src/m_cheat.c +++ b/doomsday/plugins/jhexen/src/m_cheat.c @@ -463,7 +463,7 @@ static void printDebugInfo(int player) { player_t* plr = &players[player]; char textBuffer[256]; - subsector_t* sub; + BspLeaf* sub; ddstring_t* path, *mapPath; Uri* uri, *mapUri; @@ -481,8 +481,8 @@ static void printDebugInfo(int player) // Also print some information to the console. Con_Message("%s", textBuffer); - sub = plr->plr->mo->subsector; - Con_Message("\nSubsector %i:\n", P_ToIndex(sub)); + sub = plr->plr->mo->bspLeaf; + Con_Message("\nBspLeaf %i:\n", P_ToIndex(sub)); uri = Materials_ComposeUri(P_GetIntp(sub, DMU_FLOOR_MATERIAL)); path = Uri_ToString(uri); diff --git a/doomsday/plugins/jhexen/src/p_enemy.c b/doomsday/plugins/jhexen/src/p_enemy.c index 1bbf44e93b..9dbf547bee 100644 --- a/doomsday/plugins/jhexen/src/p_enemy.c +++ b/doomsday/plugins/jhexen/src/p_enemy.c @@ -146,7 +146,7 @@ void P_ClearBodyQueue(void) void P_NoiseAlert(mobj_t *target, mobj_t *emitter) { VALIDCOUNT++; - P_RecursiveSound(target, P_GetPtrp(emitter->subsector, DMU_SECTOR), 0); + P_RecursiveSound(target, P_GetPtrp(emitter->bspLeaf, DMU_SECTOR), 0); } boolean P_CheckMeleeRange(mobj_t *actor, boolean midrange) @@ -504,7 +504,7 @@ void C_DECL A_Look(mobj_t* actor) mobj_t *targ; actor->threshold = 0; // Any shot will wake up. - targ = P_ToXSectorOfSubsector(actor->subsector)->soundTarget; + targ = P_ToXSectorOfBspLeaf(actor->bspLeaf)->soundTarget; if(targ && (targ->flags & MF_SHOOTABLE)) { actor->target = targ; @@ -1808,13 +1808,13 @@ void C_DECL A_SerpentChase(mobj_t* actor) // Chase towards player. memcpy(oldpos, actor->pos, sizeof(oldpos)); - oldMaterial = P_GetPtrp(actor->subsector, DMU_FLOOR_MATERIAL); + oldMaterial = P_GetPtrp(actor->bspLeaf, DMU_FLOOR_MATERIAL); if(--actor->moveCount < 0 || !P_Move(actor)) { P_NewChaseDir(actor); } - if(P_GetPtrp(actor->subsector, DMU_FLOOR_MATERIAL) != oldMaterial) + if(P_GetPtrp(actor->bspLeaf, DMU_FLOOR_MATERIAL) != oldMaterial) { P_TryMove(actor, oldpos[VX], oldpos[VY]); P_NewChaseDir(actor); diff --git a/doomsday/plugins/jhexen/src/p_mobj.c b/doomsday/plugins/jhexen/src/p_mobj.c index 901b9342f0..e7edcf7b67 100644 --- a/doomsday/plugins/jhexen/src/p_mobj.c +++ b/doomsday/plugins/jhexen/src/p_mobj.c @@ -88,7 +88,7 @@ static mobj_t *TIDMobj[MAX_TID_COUNT]; const terraintype_t* P_MobjGetFloorTerrainType(mobj_t* mo) { - sector_t* sec = P_GetPtrp(mo->subsector, DMU_SECTOR); + sector_t* sec = P_GetPtrp(mo->bspLeaf, DMU_SECTOR); return P_PlaneMaterialTerrainType(sec, PLN_FLOOR); } @@ -401,7 +401,7 @@ void P_MobjMoveXY(mobj_t* mo) if(mo->flags2 & MF2_WINDTHRUST) { - int special = P_ToXSectorOfSubsector(mo->subsector)->special; + int special = P_ToXSectorOfBspLeaf(mo->bspLeaf)->special; switch(special) { case 40: @@ -668,7 +668,7 @@ void P_MobjMoveXY(mobj_t* mo) if(!INRANGE_OF(mo->mom[MX], 0, DROPOFFMOM_THRESHOLD) || !INRANGE_OF(mo->mom[MY], 0, DROPOFFMOM_THRESHOLD)) { - if(mo->floorZ != P_GetFloatp(mo->subsector, DMU_FLOOR_HEIGHT)) + if(mo->floorZ != P_GetFloatp(mo->bspLeaf, DMU_FLOOR_HEIGHT)) return; } } @@ -940,7 +940,7 @@ void P_MobjMoveZ(mobj_t *mo) if(mo->type == MT_LIGHTNING_CEILING) return; - if(P_GetIntp(P_GetPtrp(mo->subsector, DMU_CEILING_MATERIAL), + if(P_GetIntp(P_GetPtrp(mo->bspLeaf, DMU_CEILING_MATERIAL), DMU_FLAGS) & MATF_SKYMASK) { if(mo->type == MT_BLOODYSKULL) @@ -1265,14 +1265,13 @@ mobj_t* P_SpawnMobj3f(mobjtype_t type, float x, float y, float z, } mo->lastLook = P_Random() % MAXPLAYERS; - // Must link before setting state. P_MobjSetState(mo, P_GetState(mo->type, SN_SPAWN)); - // Set subsector and/or block links. + // Link the mobj into the world. P_MobjSetPosition(mo); - mo->floorZ = P_GetFloatp(mo->subsector, DMU_FLOOR_HEIGHT); - mo->ceilingZ = P_GetFloatp(mo->subsector, DMU_CEILING_HEIGHT); + mo->floorZ = P_GetFloatp(mo->bspLeaf, DMU_FLOOR_HEIGHT); + mo->ceilingZ = P_GetFloatp(mo->bspLeaf, DMU_CEILING_HEIGHT); if((spawnFlags & MSF_Z_CEIL) || (info->flags & MF_SPAWNCEILING)) { @@ -1304,7 +1303,7 @@ mobj_t* P_SpawnMobj3f(mobjtype_t type, float x, float y, float z, mo->floorClip = 0; if((mo->flags2 & MF2_FLOORCLIP) && - mo->pos[VZ] == P_GetFloatp(mo->subsector, DMU_FLOOR_HEIGHT)) + mo->pos[VZ] == P_GetFloatp(mo->bspLeaf, DMU_FLOOR_HEIGHT)) { const terraintype_t* tt = P_MobjGetFloorTerrainType(mo); @@ -1504,7 +1503,7 @@ boolean P_HitFloor(mobj_t *thing) return false; } - if(thing->floorZ != P_GetFloatp(thing->subsector, DMU_FLOOR_HEIGHT)) + if(thing->floorZ != P_GetFloatp(thing->bspLeaf, DMU_FLOOR_HEIGHT)) { // Don't splash if landing on the edge above water/lava/etc.... return false; } diff --git a/doomsday/plugins/jhexen/src/p_spec.c b/doomsday/plugins/jhexen/src/p_spec.c index 28a54294f9..f7b7a81631 100644 --- a/doomsday/plugins/jhexen/src/p_spec.c +++ b/doomsday/plugins/jhexen/src/p_spec.c @@ -668,7 +668,7 @@ void P_PlayerInSpecialSector(player_t* player) 1.0 / 32 * 10, 1.0 / 32 * 25 }; - sector_t* sector = P_GetPtrp(player->plr->mo->subsector, DMU_SECTOR); + sector_t* sector = P_GetPtrp(player->plr->mo->bspLeaf, DMU_SECTOR); xsector_t* xsector; if(player->plr->mo->pos[VZ] != P_GetFloatp(sector, DMU_FLOOR_HEIGHT)) @@ -772,7 +772,7 @@ void P_PlayerOnSpecialFloor(player_t* player) return; if(player->plr->mo->pos[VZ] > - P_GetFloatp(player->plr->mo->subsector, DMU_FLOOR_HEIGHT)) + P_GetFloatp(player->plr->mo->bspLeaf, DMU_FLOOR_HEIGHT)) { return; // Player is not touching the floor } diff --git a/doomsday/plugins/jhexen/src/p_telept.c b/doomsday/plugins/jhexen/src/p_telept.c index 0a7a44b45d..67641dee3a 100644 --- a/doomsday/plugins/jhexen/src/p_telept.c +++ b/doomsday/plugins/jhexen/src/p_telept.c @@ -185,7 +185,7 @@ boolean P_Teleport(mobj_t* mo, float x, float y, angle_t angle, boolean useFog) { mo->floorClip = 0; - if(mo->pos[VZ] == P_GetFloatp(mo->subsector, DMU_FLOOR_HEIGHT)) + if(mo->pos[VZ] == P_GetFloatp(mo->bspLeaf, DMU_FLOOR_HEIGHT)) { const terraintype_t* tt = P_MobjGetFloorTerrainType(mo);