From ccdce26996f2d7eb29dbd7afae3bb89e9f1ebcc0 Mon Sep 17 00:00:00 2001 From: danij Date: Sat, 21 Apr 2012 02:13:00 +0100 Subject: [PATCH] Refactor: Relocated de::Plane's ddmobj_base_t sound origin to de::Surface 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... --- doomsday/engine/api/dd_maptypes.h | 2 +- doomsday/engine/portable/include/mapdata.hs | 6 ++---- doomsday/engine/portable/include/p_maptypes.h | 3 ++- doomsday/engine/portable/src/cl_sound.c | 4 ++-- doomsday/engine/portable/src/dam_file.c | 6 +++--- doomsday/engine/portable/src/edit_map.c | 6 +++--- doomsday/engine/portable/src/gamemap.c | 2 +- doomsday/engine/portable/src/p_dmu.c | 1 + doomsday/engine/portable/src/plane.c | 5 ----- doomsday/engine/portable/src/r_lumobjs.c | 2 +- doomsday/engine/portable/src/r_world.c | 6 +++--- doomsday/engine/portable/src/surface.c | 7 +++++-- doomsday/engine/portable/src/sv_pool.c | 17 ++++++++--------- 13 files changed, 32 insertions(+), 35 deletions(-) diff --git a/doomsday/engine/api/dd_maptypes.h b/doomsday/engine/api/dd_maptypes.h index 18d1c7145a..c518f7e4b9 100644 --- a/doomsday/engine/api/dd_maptypes.h +++ b/doomsday/engine/api/dd_maptypes.h @@ -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 @@ -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 diff --git a/doomsday/engine/portable/include/mapdata.hs b/doomsday/engine/portable/include/mapdata.hs index 90a0b5a249..2fb3e0f416 100644 --- a/doomsday/engine/portable/include/mapdata.hs +++ b/doomsday/engine/portable/include/mapdata.hs @@ -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 @@ -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 @@ -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 @@ -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) @@ -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) @@ -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] diff --git a/doomsday/engine/portable/include/p_maptypes.h b/doomsday/engine/portable/include/p_maptypes.h index 88799bc575..1cc715ae28 100644 --- a/doomsday/engine/portable/include/p_maptypes.h +++ b/doomsday/engine/portable/include/p_maptypes.h @@ -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; @@ -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 @@ -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 diff --git a/doomsday/engine/portable/src/cl_sound.c b/doomsday/engine/portable/src/cl_sound.c index e93dc12d43..10e2fa6f3e 100644 --- a/doomsday/engine/portable/src/cl_sound.c +++ b/doomsday/engine/portable/src/cl_sound.c @@ -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*) §or->planes[PLN_FLOOR]->base; + emitter = (mobj_t*) §or->SP_floorsurface.base; else if(flags & SNDDF_CEILING) - emitter = (mobj_t*) §or->planes[PLN_CEILING]->base; + emitter = (mobj_t*) §or->SP_ceilsurface.base; else emitter = (mobj_t*) §or->base; } diff --git a/doomsday/engine/portable/src/dam_file.c b/doomsday/engine/portable/src/dam_file.c index 4b2673b66b..4887e1bd1d 100644 --- a/doomsday/engine/portable/src/dam_file.c +++ b/doomsday/engine/portable/src/dam_file.c @@ -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) diff --git a/doomsday/engine/portable/src/edit_map.c b/doomsday/engine/portable/src/edit_map.c index 714dd5b446..b8bee7b9ce 100644 --- a/doomsday/engine/portable/src/edit_map.c +++ b/doomsday/engine/portable/src/edit_map.c @@ -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; } diff --git a/doomsday/engine/portable/src/gamemap.c b/doomsday/engine/portable/src/gamemap.c index 8533e80fa2..ad4b856111 100644 --- a/doomsday/engine/portable/src/gamemap.c +++ b/doomsday/engine/portable/src/gamemap.c @@ -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; } diff --git a/doomsday/engine/portable/src/p_dmu.c b/doomsday/engine/portable/src/p_dmu.c index caa099cc44..ecec70da42 100644 --- a/doomsday/engine/portable/src/p_dmu.c +++ b/doomsday/engine/portable/src/p_dmu.c @@ -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; diff --git a/doomsday/engine/portable/src/plane.c b/doomsday/engine/portable/src/plane.c index 9f536ff496..33c5aec8a6 100644 --- a/doomsday/engine/portable/src/plane.c +++ b/doomsday/engine/portable/src/plane.c @@ -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; diff --git a/doomsday/engine/portable/src/r_lumobjs.c b/doomsday/engine/portable/src/r_lumobjs.c index fdd1d92c92..c929d08ec8 100644 --- a/doomsday/engine/portable/src/r_lumobjs.c +++ b/doomsday/engine/portable/src/r_lumobjs.c @@ -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); diff --git a/doomsday/engine/portable/src/r_world.c b/doomsday/engine/portable/src/r_world.c index b7f2407986..e0891d7dc1 100644 --- a/doomsday/engine/portable/src/r_world.c +++ b/doomsday/engine/portable/src/r_world.c @@ -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; @@ -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) diff --git a/doomsday/engine/portable/src/surface.c b/doomsday/engine/portable/src/surface.c index 7a6aa2b7cd..c4be56dcbe 100644 --- a/doomsday/engine/portable/src/surface.c +++ b/doomsday/engine/portable/src/surface.c @@ -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; diff --git a/doomsday/engine/portable/src/sv_pool.c b/doomsday/engine/portable/src/sv_pool.c index 3e037a0baf..e0385ad624 100644 --- a/doomsday/engine/portable/src/sv_pool.c +++ b/doomsday/engine/portable/src/sv_pool.c @@ -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); @@ -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 }