Skip to content

Commit

Permalink
Refactor: Relocated de::Plane's ddmobj_base_t sound origin to de::Sur…
Browse files Browse the repository at this point in the history
…face

All map surfaces including planes and wall sections are modelled
using de::Surface. By relocating the sound origin to the surface
it will be possible to extend the existing sound manager to play
sounds originating from wall sections in addition to sectors and
planes.

Todo: The existing sound packet type(s) have fully utilized the
single byte which encodes the sound origin flags. We now need to
add an additional 3 flag bits for the wall surface origins...
  • Loading branch information
danij-deng committed Apr 21, 2012
1 parent 144656a commit ccdce26
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 35 deletions.
2 changes: 1 addition & 1 deletion doomsday/engine/api/dd_maptypes.h
Expand Up @@ -28,6 +28,7 @@
#define DMT_MATERIAL_WIDTH DDVT_INT
#define DMT_MATERIAL_HEIGHT DDVT_INT

#define DMT_SURFACE_BASE DDVT_PTR
#define DMT_SURFACE_FLAGS DDVT_INT // SUF_ flags
#define DMT_SURFACE_MATERIAL DDVT_PTR
#define DMT_SURFACE_BLENDMODE DDVT_BLENDMODE
Expand All @@ -37,7 +38,6 @@
#define DMT_SURFACE_OFFSET DDVT_FLOAT // [X, Y] Planar offset to surface material origin.
#define DMT_SURFACE_RGBA DDVT_FLOAT // Surface color tint

#define DMT_PLANE_BASE DDVT_PTR
#define DMT_PLANE_SECTOR DDVT_PTR // Owner of the plane (temp)
#define DMT_PLANE_HEIGHT DDVT_DOUBLE // Current height
#define DMT_PLANE_GLOW DDVT_FLOAT // Glow amount
Expand Down
6 changes: 2 additions & 4 deletions doomsday/engine/portable/include/mapdata.hs
Expand Up @@ -174,6 +174,7 @@ typedef struct surfacedecor_s {
end

struct Surface
PTR ddmobj_base_t base
- void* owner // Either @c DMU_SIDEDEF, or @c DMU_PLANE
INT int flags // SUF_ flags
- int oldFlags
Expand Down Expand Up @@ -202,6 +203,7 @@ typedef enum {
end

internal
#define PS_base surface.base
#define PS_tangent surface.tangent
#define PS_bitangent surface.bitangent
#define PS_normal surface.normal
Expand All @@ -214,7 +216,6 @@ internal
end

struct Plane
PTR ddmobj_base_t base
PTR sector_s* sector // Owner of the plane (temp)
- Surface surface
DOUBLE coord_t height // Current height
Expand All @@ -241,7 +242,6 @@ internal
#define SP_planergb(n) SP_plane(n)->surface.rgba
#define SP_planetarget(n) SP_plane(n)->target
#define SP_planespeed(n) SP_plane(n)->speed
#define SP_planeorigin(n) SP_plane(n)->origin
#define SP_planevisheight(n) SP_plane(n)->visHeight

#define SP_ceilsurface SP_planesurface(PLN_CEILING)
Expand All @@ -254,7 +254,6 @@ internal
#define SP_ceilrgb SP_planergb(PLN_CEILING)
#define SP_ceiltarget SP_planetarget(PLN_CEILING)
#define SP_ceilspeed SP_planespeed(PLN_CEILING)
#define SP_ceilorigin SP_planeorigin(PLN_CEILING)
#define SP_ceilvisheight SP_planevisheight(PLN_CEILING)

#define SP_floorsurface SP_planesurface(PLN_FLOOR)
Expand All @@ -267,7 +266,6 @@ internal
#define SP_floorrgb SP_planergb(PLN_FLOOR)
#define SP_floortarget SP_planetarget(PLN_FLOOR)
#define SP_floorspeed SP_planespeed(PLN_FLOOR)
#define SP_floororigin SP_planeorigin(PLN_FLOOR)
#define SP_floorvisheight SP_planevisheight(PLN_FLOOR)

#define S_skyfix(n) skyFix[(n)? 1:0]
Expand Down
3 changes: 2 additions & 1 deletion doomsday/engine/portable/include/p_maptypes.h
Expand Up @@ -161,6 +161,7 @@ typedef struct surfacedecor_s {

typedef struct surface_s {
runtime_mapdata_header_t header;
ddmobj_base_t base;
void* owner; // Either @c DMU_SIDEDEF, or @c DMU_PLANE
int flags; // SUF_ flags
int oldFlags;
Expand All @@ -186,6 +187,7 @@ typedef enum {
NUM_PLANE_TYPES
} planetype_t;

#define PS_base surface.base
#define PS_tangent surface.tangent
#define PS_bitangent surface.bitangent
#define PS_normal surface.normal
Expand All @@ -198,7 +200,6 @@ typedef enum {

typedef struct plane_s {
runtime_mapdata_header_t header;
ddmobj_base_t base;
struct sector_s* sector; // Owner of the plane (temp)
Surface surface;
coord_t height; // Current height
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/cl_sound.c
Expand Up @@ -133,9 +133,9 @@ void Cl_ReadSoundDelta2(deltatype_t type, boolean skip)
{
// Should we use a specific origin?
if(flags & SNDDF_FLOOR)
emitter = (mobj_t*) &sector->planes[PLN_FLOOR]->base;
emitter = (mobj_t*) &sector->SP_floorsurface.base;
else if(flags & SNDDF_CEILING)
emitter = (mobj_t*) &sector->planes[PLN_CEILING]->base;
emitter = (mobj_t*) &sector->SP_ceilsurface.base;
else
emitter = (mobj_t*) &sector->base;
}
Expand Down
6 changes: 3 additions & 3 deletions doomsday/engine/portable/src/dam_file.c
Expand Up @@ -527,9 +527,9 @@ static void readSector(GameMap* map, uint idx)
for(i = 0; i < numPlanes; ++i)
{
Plane* p = s->planes[i];
p->base.origin[VX] = s->base.origin[VX];
p->base.origin[VY] = s->base.origin[VY];
p->base.origin[VZ] = p->height;
p->PS_base.origin[VX] = s->base.origin[VX];
p->PS_base.origin[VY] = s->base.origin[VY];
p->PS_base.origin[VZ] = p->height;
}

for(i = 0; i < NUM_REVERB_DATA; ++i)
Expand Down
6 changes: 3 additions & 3 deletions doomsday/engine/portable/src/edit_map.c
Expand Up @@ -656,9 +656,9 @@ static void finishSectors(GameMap* map)
{
Plane* plane = sec->planes[k];

plane->base.origin[VX] = sec->base.origin[VX];
plane->base.origin[VY] = sec->base.origin[VY];
plane->base.origin[VZ] = plane->height;
plane->PS_base.origin[VX] = sec->base.origin[VX];
plane->PS_base.origin[VY] = sec->base.origin[VY];
plane->PS_base.origin[VZ] = plane->height;

plane->target = plane->height;
}
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/gamemap.c
Expand Up @@ -189,7 +189,7 @@ Sector* GameMap_SectorByBase(GameMap* map, const void* ddMobjBase)
// Check the planes of this sector
for(k = 0; k < sec->planeCount; ++k)
{
if(ddMobjBase == &sec->planes[k]->base)
if(ddMobjBase == &sec->SP_plane(k)->PS_base)
{
return sec;
}
Expand Down
1 change: 1 addition & 0 deletions doomsday/engine/portable/src/p_dmu.c
Expand Up @@ -1577,6 +1577,7 @@ static int getProperty(void* obj, void* context)
case DMU_ALPHA:
case DMU_BLENDMODE:
case DMU_FLAGS:
case DMU_BASE:
obj = &((Plane*) obj)->surface;
args->type = DMU_SURFACE;
break;
Expand Down
5 changes: 0 additions & 5 deletions doomsday/engine/portable/src/plane.c
Expand Up @@ -60,11 +60,6 @@ int Plane_GetProperty(const Plane* pln, setargs_t* args)
case DMU_HEIGHT:
DMU_GetValue(DMT_PLANE_HEIGHT, &pln->height, args, 0);
break;
case DMU_BASE: {
const ddmobj_base_t* base = &pln->base;
DMU_GetValue(DMT_PLANE_BASE, &base, args, 0);
break;
}
case DMU_TARGET_HEIGHT:
DMU_GetValue(DMT_PLANE_TARGET, &pln->target, args, 0);
break;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/r_lumobjs.c
Expand Up @@ -990,7 +990,7 @@ static boolean createGlowLightForSurface(Surface* suf, void* paramaters)

// @note Plane lights do not spread so simply link to all BspLeafs of this sector.
lum = createLuminous(LT_PLANE, sec->bspLeafs[0]);
V3d_Set(lum->origin, pln->base.origin[VX], pln->base.origin[VY], pln->visHeight);
V3d_Copy(lum->origin, pln->PS_base.origin);

V3f_Copy(LUM_PLANE(lum)->normal, pln->PS_normal);
V3f_Copy(LUM_PLANE(lum)->color, avgColorAmplified->color.rgb);
Expand Down
6 changes: 3 additions & 3 deletions doomsday/engine/portable/src/r_world.c
Expand Up @@ -579,8 +579,8 @@ Plane* R_NewPlaneForSector(Sector* sec)
plane->sector = sec;
plane->height = plane->oldHeight[0] = plane->oldHeight[1] = 0;
plane->visHeight = plane->visHeightDelta = 0;
V3d_Copy(plane->base.origin, sec->base.origin);
memset(&plane->base.thinker, 0, sizeof(plane->base.thinker));
V3d_Copy(plane->PS_base.origin, sec->base.origin);
memset(&plane->PS_base.thinker, 0, sizeof(plane->PS_base.thinker));
plane->speed = 0;
plane->target = 0;
plane->type = PLN_MID;
Expand Down Expand Up @@ -1551,7 +1551,7 @@ boolean R_UpdatePlane(Plane* pln, boolean forceUpdate)
}}

// Update the z position of the degenmobj for this plane.
pln->base.origin[VZ] = pln->height;
pln->PS_base.origin[VZ] = pln->height;

// Inform the shadow bias of changed geometry.
if(sec->bspLeafs && *sec->bspLeafs)
Expand Down
7 changes: 5 additions & 2 deletions doomsday/engine/portable/src/surface.c
Expand Up @@ -334,13 +334,16 @@ int Surface_GetProperty(const Surface* suf, setargs_t* args)
{
switch(args->prop)
{
case DMU_BASE: {
const ddmobj_base_t* base = &suf->base;
DMU_GetValue(DMT_SURFACE_BASE, &base, args, 0);
break; }
case DMU_MATERIAL: {
material_t* mat = suf->material;
if(suf->inFlags & SUIF_FIX_MISSING_MATERIAL)
mat = NULL;
DMU_GetValue(DMT_SURFACE_MATERIAL, &mat, args, 0);
break;
}
break; }
case DMU_OFFSET_X:
DMU_GetValue(DMT_SURFACE_OFFSET, &suf->offset[VX], args, 0);
break;
Expand Down
17 changes: 8 additions & 9 deletions doomsday/engine/portable/src/sv_pool.c
Expand Up @@ -2304,17 +2304,16 @@ void Sv_NewPolyDeltas(cregister_t* reg, boolean doUpdate, pool_t** targets)
* there is no need for comparing or to have a register.
* Set 'volume' to zero to create a sound-stopping delta.
*
* \assume: No two sounds with the same ID play at the same time from the
* @assume: No two sounds with the same ID play at the same time from the
* same origin.
*/
void Sv_NewSoundDelta(int soundId, mobj_t* emitter, Sector* sourceSector,
Polyobj* sourcePoly, float volume,
boolean isRepeating, int clientsMask)
Polyobj* sourcePoly, float volume, boolean isRepeating, int clientsMask)
{
pool_t* targets[DDMAXPLAYERS + 1];
sounddelta_t soundDelta;
int type = DT_SOUND, df = 0;
uint id = soundId;
pool_t* targets[DDMAXPLAYERS + 1];
sounddelta_t soundDelta;
int type = DT_SOUND, df = 0;
uint id = soundId;

// Determine the target pools.
Sv_GetTargetPools(targets, clientsMask);
Expand All @@ -2327,9 +2326,9 @@ void Sv_NewSoundDelta(int soundId, mobj_t* emitter, Sector* sourceSector,
// Clients need to know which emitter to use.
if(emitter)
{
if(emitter == (mobj_t*) &sourceSector->planes[PLN_FLOOR]->base)
if(emitter == (mobj_t*) &sourceSector->SP_floorsurface.base)
df |= SNDDF_FLOOR;
else if(emitter == (mobj_t*) &sourceSector->planes[PLN_CEILING]->base)
else if(emitter == (mobj_t*) &sourceSector->SP_ceilsurface.base)
df |= SNDDF_CEILING;
// else client assumes sector->soundOrg
}
Expand Down

0 comments on commit ccdce26

Please sign in to comment.