Skip to content

Commit

Permalink
Changed seg_t->offset, surface_t->texmove and surface_t->oldtexmove t…
Browse files Browse the repository at this point in the history
…o float.

Added missing vtx member initialization.
  • Loading branch information
danij committed Jan 12, 2007
1 parent 45d0c0d commit 25fe3be
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 72 deletions.
14 changes: 5 additions & 9 deletions doomsday/engine/api/dd_maptypes.h
Expand Up @@ -7,7 +7,7 @@

#define DMT_SEG_V DDVT_PTR // [Start, End] of the segment.
#define DMT_SEG_LENGTH DDVT_FLOAT // Accurate length of the segment (v1 -> v2).
#define DMT_SEG_OFFSET DDVT_FIXED
#define DMT_SEG_OFFSET DDVT_FLOAT
#define DMT_SEG_SIDEDEF DDVT_PTR
#define DMT_SEG_LINEDEF DDVT_PTR
#define DMT_SEG_SEC DDVT_PTR
Expand All @@ -22,7 +22,7 @@

#define DMT_SURFACE_FLAGS DDVT_INT // SUF_ flags
#define DMT_SURFACE_TEXTURE DDVT_SHORT
#define DMT_SURFACE_TEXMOVE DDVT_FIXED // Texture movement X and Y
#define DMT_SURFACE_TEXMOVE DDVT_FLOAT // Texture movement X and Y
#define DMT_SURFACE_OFFX DDVT_FLOAT // Texture x offset
#define DMT_SURFACE_OFFY DDVT_FLOAT // Texture y offset
#define DMT_SURFACE_RGBA DDVT_BYTE // Surface color tint
Expand All @@ -33,10 +33,7 @@
#define DMT_PLANE_TARGET DDVT_FLOAT // Target height
#define DMT_PLANE_SPEED DDVT_FLOAT // Move speed
#define DMT_PLANE_SOUNDORG DDVT_PTR // Sound origin for plane

#define DMT_PLANE_SECTOR DDVT_PTR
#define DMT_PLANE_OFFX DDVT_FLOAT
#define DMT_PLANE_OFFY DDVT_FLOAT
#define DMT_PLANE_SECTOR DDVT_PTR // Owner of the plane (temp)

#define DMT_SECTOR_LIGHTLEVEL DDVT_SHORT
#define DMT_SECTOR_RGB DDVT_BYTE
Expand Down Expand Up @@ -83,8 +80,7 @@
#define DMT_NODE_Y DDVT_FLOAT // Partition line.
#define DMT_NODE_DX DDVT_FLOAT // Partition line.
#define DMT_NODE_DY DDVT_FLOAT // Partition line.

#define DMT_NODE_BBOX DDVT_FIXED
#define DMT_NODE_CHILDREN DDVT_UINT
#define DMT_NODE_BBOX DDVT_FLOAT // Bounding box for each child.
#define DMT_NODE_CHILDREN DDVT_UINT // If NF_SUBSECTOR it's a subsector.

#endif
23 changes: 6 additions & 17 deletions doomsday/engine/portable/include/mapdata.hs
Expand Up @@ -28,7 +28,7 @@ end
struct seg
PTR vertex_s*[2] v // [Start, End] of the segment.
FLOAT float length // Accurate length of the segment (v1 -> v2).
FIXED fixed_t offset
FLOAT float offset
PTR side_s* sidedef
PTR line_s* linedef
PTR sector_s*[2] sec
Expand Down Expand Up @@ -76,8 +76,8 @@ struct surface
- boolean oldisflat
- float[3] normal // Surface normal
- float[3] oldnormal
FIXED fixed_t[2] texmove // Texture movement X and Y
- fixed_t[2] oldtexmove
FLOAT float[2] texmove // Texture movement X and Y
- float[2] oldtexmove
FLOAT float offx // Texture x offset
- float oldoffx
FLOAT float offy // Texture y offset
Expand All @@ -96,18 +96,12 @@ struct plane
FLOAT float target // Target height
FLOAT float speed // Move speed
PTR degenmobj_t soundorg // Sound origin for plane
- sector_s* sector // Owner of the plane (temp)
PTR sector_s* sector // Owner of the plane (temp)
- float visheight // Visible plane height (smoothed)
- float visoffset
- sector_s* linked // Plane attached to another sector.
end

public
#define DMT_PLANE_SECTOR DDVT_PTR
#define DMT_PLANE_OFFX DDVT_FLOAT
#define DMT_PLANE_OFFY DDVT_FLOAT
end

internal
// Helper macros for accessing sector floor/ceiling plane data elements.
#define SP_ceilsurface planes[PLN_CEILING]->surface
Expand Down Expand Up @@ -303,11 +297,6 @@ struct node
FLOAT float y // Partition line.
FLOAT float dx // Partition line.
FLOAT float dy // Partition line.
- float[2][4] bbox // Bounding box for each child.
- uint[2] children // If NF_SUBSECTOR it's a subsector.
end

public
#define DMT_NODE_BBOX DDVT_FIXED
#define DMT_NODE_CHILDREN DDVT_UINT
FLOAT float[2][4] bbox // Bounding box for each child.
UINT uint[2] children // If NF_SUBSECTOR it's a subsector.
end
6 changes: 3 additions & 3 deletions doomsday/engine/portable/include/p_maptypes.h
Expand Up @@ -32,7 +32,7 @@ typedef struct seg_s {
runtime_mapdata_header_t header;
struct vertex_s* v[2]; // [Start, End] of the segment.
float length; // Accurate length of the segment (v1 -> v2).
fixed_t offset;
float offset;
struct side_s* sidedef;
struct line_s* linedef;
struct sector_s* sec[2];
Expand Down Expand Up @@ -80,8 +80,8 @@ typedef struct surface_s {
boolean oldisflat;
float normal[3]; // Surface normal
float oldnormal[3];
fixed_t texmove[2]; // Texture movement X and Y
fixed_t oldtexmove[2];
float texmove[2]; // Texture movement X and Y
float oldtexmove[2];
float offx; // Texture x offset
float oldoffx;
float offy; // Texture y offset
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/include/sv_pool.h
Expand Up @@ -256,7 +256,7 @@ typedef struct {
short texture;
boolean isflat;
byte rgba[4]; // Surface color tint
fixed_t texmove[2]; // Texture movement X and Y.
float texmove[2]; // Texture movement X and Y.
} dt_surface_t;

typedef struct {
Expand Down
8 changes: 4 additions & 4 deletions doomsday/engine/portable/src/cl_oldworld.c
Expand Up @@ -95,8 +95,8 @@ int Cl_ReadSectorDelta(void)
}
if(df & SDF_FLOOR_TEXMOVE)
{
sec->SP_floortexmove[0] = Msg_ReadShort() << 8;
sec->SP_floortexmove[1] = Msg_ReadShort() << 8;
sec->SP_floortexmove[0] = FIX2FLT(Msg_ReadShort() << 8);
sec->SP_floortexmove[1] = FIX2FLT(Msg_ReadShort() << 8);
}
if(df & SDF_CEILING_TARGET)
sec->planes[PLN_CEILING]->target = FIX2FLT(Msg_ReadShort() << 16);
Expand All @@ -107,8 +107,8 @@ int Cl_ReadSectorDelta(void)
}
if(df & SDF_CEILING_TEXMOVE)
{
sec->SP_ceiltexmove[0] = Msg_ReadShort() << 8;
sec->SP_ceiltexmove[1] = Msg_ReadShort() << 8;
sec->SP_ceiltexmove[0] = FIX2FLT(Msg_ReadShort() << 8);
sec->SP_ceiltexmove[1] = FIX2FLT(Msg_ReadShort() << 8);
}
if(df & SDF_COLOR_RED)
sec->rgb[0] = Msg_ReadByte();
Expand Down
13 changes: 9 additions & 4 deletions doomsday/engine/portable/src/cl_world.c
Expand Up @@ -523,8 +523,8 @@ void Cl_ReadSectorDelta2(int deltaType, boolean skip)
fixed_t moveY = Msg_ReadShort() << 8;
if(!skip)
{
sec->SP_floortexmove[0] = moveX;
sec->SP_floortexmove[1] = moveY;
sec->SP_floortexmove[0] = FIX2FLT(moveX);
sec->SP_floortexmove[1] = FIX2FLT(moveY);
}
}
if(df & SDF_CEILING_TARGET)
Expand Down Expand Up @@ -552,8 +552,13 @@ void Cl_ReadSectorDelta2(int deltaType, boolean skip)
}
if(df & SDF_CEILING_TEXMOVE)
{
sec->SP_ceiltexmove[0] = Msg_ReadShort() << 8;
sec->SP_ceiltexmove[1] = Msg_ReadShort() << 8;
fixed_t moveX = Msg_ReadShort() << 8;
fixed_t moveY = Msg_ReadShort() << 8;
if(!skip)
{
sec->SP_ceiltexmove[0] = FIX2FLT(moveX);
sec->SP_ceiltexmove[1] = FIX2FLT(moveY);
}
}
if(df & SDF_COLOR_RED)
sec->rgb[0] = Msg_ReadByte();
Expand Down
26 changes: 18 additions & 8 deletions doomsday/engine/portable/src/p_arch.c
Expand Up @@ -1628,7 +1628,14 @@ static boolean ReadMapData(gamemap_t* map, int doClass)
memset(&map->vertexes[oldNum], 0, elements * sizeof(vertex_t));
for(k = oldNum; k < newNum; ++k)
{
map->vertexes[k].header.type = DMU_VERTEX;
vertex_t *vtx = &map->vertexes[k];

vtx->header.type = DMU_VERTEX;
vtx->numlineowners = 0;
vtx->lineowners = NULL;
vtx->anchored = false;
vtx->numsecowners = 0;
vtx->secowners = NULL;
}

if(mapLump->lumpClass == LCM_VERTEXES && oldNum == 0)
Expand All @@ -1653,7 +1660,12 @@ static boolean ReadMapData(gamemap_t* map, int doClass)
memset(&map->lines[oldNum], 0, elements * sizeof(line_t));
for(k = oldNum; k < newNum; ++k)
{
map->lines[k].header.type = DMU_LINE;
line_t *lin = &map->lines[k];

lin->header.type = DMU_LINE;
lin->L_vo1 = NULL;
lin->L_vo2 = NULL;
lin->selfrefhackroot = false;
}

// for missing front detection
Expand Down Expand Up @@ -2852,13 +2864,11 @@ static void P_ProcessSegs(gamemap_t* map, int version)
if(seg->offset == -1)
{
if(side == 0)
seg->offset =
FRACUNIT * P_AccurateDistancef(seg->v[0]->pos[VX] - ldef->v[0]->pos[VX],
seg->v[0]->pos[VY] - ldef->v[0]->pos[VY]);
seg->offset = P_AccurateDistancef(seg->v[0]->pos[VX] - ldef->v[0]->pos[VX],
seg->v[0]->pos[VY] - ldef->v[0]->pos[VY]);
else
seg->offset =
FRACUNIT * P_AccurateDistancef(seg->v[0]->pos[VX] - ldef->v[1]->pos[VX],
seg->v[0]->pos[VY] - ldef->v[1]->pos[VY]);
seg->offset = P_AccurateDistancef(seg->v[0]->pos[VX] - ldef->v[1]->pos[VX],
seg->v[0]->pos[VY] - ldef->v[1]->pos[VY]);
}

if(seg->angle == -1)
Expand Down
16 changes: 8 additions & 8 deletions doomsday/engine/portable/src/p_dmu.c
Expand Up @@ -1094,14 +1094,14 @@ static int SetProperty(void* ptr, void* context)
p->surface.isflat = true; // Kludge
break;
case DMU_PLANE_OFFSET_X:
SetValue(DMT_PLANE_OFFX, &p->surface.offx, args, 0);
SetValue(DMT_SURFACE_OFFX, &p->surface.offx, args, 0);
break;
case DMU_PLANE_OFFSET_Y:
SetValue(DMT_PLANE_OFFY, &p->surface.offy, args, 0);
SetValue(DMT_SURFACE_OFFY, &p->surface.offy, args, 0);
break;
case DMU_PLANE_OFFSET_XY:
SetValue(DMT_PLANE_OFFX, &p->surface.offx, args, 0);
SetValue(DMT_PLANE_OFFY, &p->surface.offy, args, 1);
SetValue(DMT_SURFACE_OFFX, &p->surface.offx, args, 0);
SetValue(DMT_SURFACE_OFFY, &p->surface.offy, args, 1);
break;
case DMU_PLANE_TEXTURE_MOVE_X:
SetValue(DMT_SURFACE_TEXMOVE, &p->surface.texmove[0], args, 0);
Expand Down Expand Up @@ -1777,14 +1777,14 @@ static int GetProperty(void* ptr, void* context)
break;
}
case DMU_PLANE_OFFSET_X:
GetValue(DMT_PLANE_OFFX, &p->surface.offx, args, 0);
GetValue(DMT_SURFACE_OFFX, &p->surface.offx, args, 0);
break;
case DMU_PLANE_OFFSET_Y:
GetValue(DMT_PLANE_OFFY, &p->surface.offy, args, 0);
GetValue(DMT_SURFACE_OFFY, &p->surface.offy, args, 0);
break;
case DMU_PLANE_OFFSET_XY:
GetValue(DMT_PLANE_OFFX, &p->surface.offx, args, 0);
GetValue(DMT_PLANE_OFFY, &p->surface.offy, args, 1);
GetValue(DMT_SURFACE_OFFX, &p->surface.offx, args, 0);
GetValue(DMT_SURFACE_OFFY, &p->surface.offy, args, 1);
break;
case DMU_PLANE_TEXTURE_MOVE_X:
GetValue(DMT_SURFACE_TEXMOVE, &p->surface.texmove[0], args, 0);
Expand Down
15 changes: 7 additions & 8 deletions doomsday/engine/portable/src/rend_fakeradio.c
Expand Up @@ -701,7 +701,7 @@ static float Rend_RadioLongWallBonus(float span)
void Rend_RadioWallSection(const seg_t *seg, rendpoly_t *origQuad)
{
sector_t *backSector;
float bFloor, bCeil, limit, size, segOffset;
float bFloor, bCeil, limit, size;
rendpoly_t *quad;
int i, texture = 0, sideNum;
shadowcorner_t topCn[2], botCn[2], sideCn[2];
Expand All @@ -713,7 +713,6 @@ void Rend_RadioWallSection(const seg_t *seg, rendpoly_t *origQuad)
return;

backSector = seg->SG_backsector;
segOffset = FIX2FLT(seg->offset);

// Choose the correct side.
if(seg->linedef->L_frontsector == frontSector)
Expand All @@ -725,7 +724,7 @@ void Rend_RadioWallSection(const seg_t *seg, rendpoly_t *origQuad)
for(i = 0; i < 2; ++i)
{
spans[i].length = seg->linedef->length;
spans[i].shift = segOffset;
spans[i].shift = seg->offset;
}

Rend_RadioScanEdges(topCn, botCn, sideCn, seg->linedef, sideNum, spans);
Expand All @@ -744,7 +743,7 @@ void Rend_RadioWallSection(const seg_t *seg, rendpoly_t *origQuad)

// Init the quad.
quad->flags = RPF_SHADOW;
quad->texoffx = segOffset;
quad->texoffx = seg->offset;
quad->texoffy = 0;
quad->tex.id = GL_PrepareLSTexture(LST_RADIO_CC);
quad->tex.detail = NULL;
Expand Down Expand Up @@ -1037,9 +1036,9 @@ void Rend_RadioWallSection(const seg_t *seg, rendpoly_t *origQuad)
// Left Shadow
if(i == 0)
{
if(sideCn[0].corner > 0 && segOffset < size)
if(sideCn[0].corner > 0 && seg->offset < size)
{
quad->texoffx = segOffset;
quad->texoffx = seg->offset;
// Make sure the shadow isn't too big
if(size > seg->linedef->length)
{
Expand All @@ -1056,9 +1055,9 @@ void Rend_RadioWallSection(const seg_t *seg, rendpoly_t *origQuad)
}
else // Right Shadow
{
if(sideCn[1].corner > 0 && segOffset + seg->length > seg->linedef->length - size)
if(sideCn[1].corner > 0 && seg->offset + seg->length > seg->linedef->length - size)
{
quad->texoffx = -seg->linedef->length + segOffset;
quad->texoffx = -seg->linedef->length + seg->offset;
// Make sure the shadow isn't too big
if(size > seg->linedef->length)
{
Expand Down
8 changes: 4 additions & 4 deletions doomsday/engine/portable/src/rend_main.c
Expand Up @@ -1175,7 +1175,7 @@ static void Rend_RenderSSWallSeg(seg_t *seg, sector_t *frontsec)
vTL[VZ] = vTR[VZ] = fceil;
vBL[VZ] = vBR[VZ] = ffloor;

quad->texoffx = side->SW_middleoffx + FIX2FLT(seg->offset);
quad->texoffx = side->SW_middleoffx + seg->offset;
quad->texoffy = side->SW_middleoffy;
if(ldef->flags & ML_DONTPEGBOTTOM)
quad->texoffy += texh - fsh;
Expand Down Expand Up @@ -1316,7 +1316,7 @@ static void Rend_RenderWallSeg(seg_t *seg, sector_t *frontsec)
vTL[VZ] = vTR[VZ] = gaptop = MIN_OF(rbceil, rfceil);
vBL[VZ] = vBR[VZ] = gapbottom = MAX_OF(rbfloor, rffloor);

quad->texoffx = side->SW_middleoffx + FIX2FLT(seg->offset);
quad->texoffx = side->SW_middleoffx + seg->offset;

if(Rend_MidTexturePos
(&vBL[VZ], &vBR[VZ], &vTL[VZ], &vTR[VZ],
Expand Down Expand Up @@ -1418,7 +1418,7 @@ static void Rend_RenderWallSeg(seg_t *seg, sector_t *frontsec)
float tcyoff;

// Calculate texture coordinates.
quad->texoffx = side->SW_topoffx + FIX2FLT(seg->offset);
quad->texoffx = side->SW_topoffx + seg->offset;
tcyoff = side->SW_middleoffy;

quad->flags = 0;
Expand Down Expand Up @@ -1507,7 +1507,7 @@ static void Rend_RenderWallSeg(seg_t *seg, sector_t *frontsec)
{
short tempflags = 0;
// Calculate texture coordinates.
quad->texoffx = side->SW_bottomoffx + FIX2FLT(seg->offset);
quad->texoffx = side->SW_bottomoffx + seg->offset;
quad->texoffy = side->SW_bottomoffy;
if(ldef->flags & ML_DONTPEGBOTTOM)
quad->texoffy += fceil - bfloor; // Align with normal middle texture.
Expand Down
8 changes: 4 additions & 4 deletions doomsday/engine/portable/src/sv_frame.c
Expand Up @@ -493,17 +493,17 @@ void Sv_WriteSectorDelta(const void *deltaPtr)
Msg_WriteByte(floorspd);
if(df & SDF_FLOOR_TEXMOVE)
{
Msg_WriteShort(d->planes[PLN_FLOOR].surface.texmove[0] >> 8);
Msg_WriteShort(d->planes[PLN_FLOOR].surface.texmove[1] >> 8);
Msg_WriteShort(FLT2FIX(d->planes[PLN_FLOOR].surface.texmove[0]) >> 8);
Msg_WriteShort(FLT2FIX(d->planes[PLN_FLOOR].surface.texmove[1]) >> 8);
}
if(df & SDF_CEILING_TARGET)
Msg_WriteShort(FLT2FIX(d->planes[PLN_CEILING].target) >> 16);
if(df & SDF_CEILING_SPEED) // 7.1/4.4 fixed-point
Msg_WriteByte(ceilspd);
if(df & SDF_CEILING_TEXMOVE)
{
Msg_WriteShort(d->planes[PLN_CEILING].surface.texmove[0] >> 8);
Msg_WriteShort(d->planes[PLN_CEILING].surface.texmove[1] >> 8);
Msg_WriteShort(FLT2FIX(d->planes[PLN_CEILING].surface.texmove[0]) >> 8);
Msg_WriteShort(FLT2FIX(d->planes[PLN_CEILING].surface.texmove[1]) >> 8);
}
if(df & SDF_COLOR_RED)
Msg_WriteByte(d->rgb[0]);
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/sv_pool.c
Expand Up @@ -1365,7 +1365,7 @@ void Sv_ApplyDeltaData(void *destDelta, const void *srcDelta)
{
memcpy(d->planes[PLN_FLOOR].surface.texmove,
s->planes[PLN_FLOOR].surface.texmove,
sizeof(int) * 2);
sizeof(float) * 2);
}
if(sf & SDF_CEILING_TARGET)
d->planes[PLN_CEILING].target = s->planes[PLN_CEILING].target;
Expand All @@ -1375,7 +1375,7 @@ void Sv_ApplyDeltaData(void *destDelta, const void *srcDelta)
{
memcpy(d->planes[PLN_CEILING].surface.texmove,
s->planes[PLN_CEILING].surface.texmove,
sizeof(int) * 2);
sizeof(float) * 2);
}
if(sf & SDF_FLOOR_HEIGHT)
d->planes[PLN_FLOOR].height = s->planes[PLN_FLOOR].height;
Expand Down

0 comments on commit 25fe3be

Please sign in to comment.