Skip to content

Commit

Permalink
- use floats for vertices.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Feb 15, 2022
1 parent cf17cff commit cd55658
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 62 deletions.
8 changes: 4 additions & 4 deletions source/core/gamestruct.h
Expand Up @@ -56,10 +56,10 @@ struct GeoEffect
sectortype** geosectorwarp;
sectortype** geosectorwarp2;
sectortype** geosector;
int* geox;
int* geoy;
int* geox2;
int* geoy2;
double* geox;
double* geoy;
double* geox2;
double* geoy2;
int geocnt;

};
Expand Down
8 changes: 4 additions & 4 deletions source/core/interpolate.cpp
Expand Up @@ -50,8 +50,8 @@ double Get(int index, DCoreActor* actor, int type)
case Interp_Sect_CeilingPanX: return sector[index].ceilingxpan_;
case Interp_Sect_CeilingPanY: return sector[index].ceilingypan_;

case Interp_Wall_X: return wall[index].wall_int_pos().X;
case Interp_Wall_Y: return wall[index].wall_int_pos().Y;
case Interp_Wall_X: return wall[index].__wall_pos.X;
case Interp_Wall_Y: return wall[index].__wall_pos.Y;
case Interp_Wall_PanX: return wall[index].xpan_;
case Interp_Wall_PanY: return wall[index].ypan_;

Expand All @@ -74,8 +74,8 @@ void Set(int index, DCoreActor* actor, int type, double val)
case Interp_Sect_CeilingPanX: sector[index].ceilingxpan_ = float(val); break;
case Interp_Sect_CeilingPanY: sector[index].ceilingypan_ = float(val); break;

case Interp_Wall_X: old = wall[index].wall_int_pos().X; wall[index].__wall_int_pos.X = xs_CRoundToInt(val); if (wall[index].wall_int_pos().X != old) wall[index].moved(); break;
case Interp_Wall_Y: old = wall[index].wall_int_pos().Y; wall[index].__wall_int_pos.Y = xs_CRoundToInt(val); if (wall[index].wall_int_pos().Y != old) wall[index].moved(); break;
case Interp_Wall_X: old = wall[index].__wall_pos.X; wall[index].__wall_pos.X = val; if (wall[index].__wall_pos.X != old) wall[index].moved(); break;
case Interp_Wall_Y: old = wall[index].__wall_pos.Y; wall[index].__wall_pos.Y = val; if (wall[index].__wall_pos.Y != old) wall[index].moved(); break;
case Interp_Wall_PanX: wall[index].xpan_ = float(val); break;
case Interp_Wall_PanY: wall[index].ypan_ = float(val); break;

Expand Down
13 changes: 8 additions & 5 deletions source/core/maptypes.h
Expand Up @@ -36,6 +36,9 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms

void MarkVerticesForSector(int sector);

static constexpr double maptoworld = (1 / 16.);
static constexpr double worldtomap = 16.;

//=============================================================================
//
// Constants
Expand Down Expand Up @@ -358,10 +361,10 @@ struct sectortype

struct walltype
{
vec2_t __wall_int_pos;
DVector2 __wall_pos;

const vec2_t wall_int_pos() const { return __wall_int_pos; }
void setPosFromLoad(int x, int y) { __wall_int_pos = { x, y }; }
vec2_t wall_int_pos() const { return vec2_t(__wall_pos.X * worldtomap, __wall_pos.Y * worldtomap); };
void setPosFromLoad(int x, int y) { __wall_pos = { x * maptoworld, y * maptoworld }; }

int32_t point2;
int32_t nextwall;
Expand Down Expand Up @@ -552,8 +555,8 @@ inline void walltype::moved()

inline void walltype::move(int newx, int newy)
{
__wall_int_pos.X = newx;
__wall_int_pos.Y = newy;
__wall_pos.X = newx * maptoworld;
__wall_pos.Y = newy * maptoworld;
lengthflags = 3;
sectorp()->dirty = EDirty::AllDirty;
}
Expand Down
16 changes: 8 additions & 8 deletions source/core/rendering/scene/hw_drawinfo.cpp
Expand Up @@ -415,8 +415,8 @@ void HWDrawInfo::CreateScene(bool portal)
for (auto w = 0; w < sect->wallnum; w++)
{
auto wal = sect->firstWall() + w;
wal->__wall_int_pos.X += eff.geox[i];
wal->__wall_int_pos.Y += eff.geoy[i];
wal->__wall_pos.X += eff.geox[i];
wal->__wall_pos.Y += eff.geoy[i];
}
sect->dirty = EDirty::AllDirty;
if (eff.geosector[i] == drawsectp) drawsectp = eff.geosectorwarp[i];
Expand All @@ -434,8 +434,8 @@ void HWDrawInfo::CreateScene(bool portal)
for (auto w = 0; w < sect->wallnum; w++)
{
auto wal = sect->firstWall() + w;
wal->__wall_int_pos.X -= eff.geox[i];
wal->__wall_int_pos.Y -= eff.geoy[i];
wal->__wall_pos.X -= eff.geox[i];
wal->__wall_pos.Y -= eff.geoy[i];
}
}

Expand All @@ -447,8 +447,8 @@ void HWDrawInfo::CreateScene(bool portal)
for (auto w = 0; w < sect->wallnum; w++)
{
auto wal = sect->firstWall() + w;
wal->__wall_int_pos.X += eff.geox2[i];
wal->__wall_int_pos.Y += eff.geoy2[i];
wal->__wall_pos.X += eff.geox2[i];
wal->__wall_pos.Y += eff.geoy2[i];
}
sect->dirty = EDirty::AllDirty;
if (eff.geosector[i] == orgdrawsectp) drawsectp = eff.geosectorwarp2[i];
Expand All @@ -465,8 +465,8 @@ void HWDrawInfo::CreateScene(bool portal)
for (auto w = 0; w < sect->wallnum; w++)
{
auto wal = sect->firstWall() + w;
wal->__wall_int_pos.X -= eff.geox2[i];
wal->__wall_int_pos.Y -= eff.geoy2[i];
wal->__wall_pos.X -= eff.geox2[i];
wal->__wall_pos.Y -= eff.geoy2[i];
}
}
ingeo = false;
Expand Down
4 changes: 2 additions & 2 deletions source/core/savegamehelp.cpp
Expand Up @@ -606,8 +606,8 @@ FSerializer &Serialize(FSerializer &arc, const char *key, walltype &c, walltype
{
if (arc.BeginObject(key))
{
arc("x", c.__wall_int_pos.X, def->__wall_int_pos.X)
("y", c.__wall_int_pos.Y, def->__wall_int_pos.Y)
arc("x", c.__wall_pos.X, def->__wall_pos.X)
("y", c.__wall_pos.Y, def->__wall_pos.Y)
("point2", c.point2, def->point2)
("nextwall", c.nextwall, def->nextwall)
("nextsector", c.nextsector, def->nextsector)
Expand Down
2 changes: 1 addition & 1 deletion source/core/sectorgeometry.cpp
Expand Up @@ -115,7 +115,7 @@ class UVCalculator
sect = sec;
tex = tx;
myplane = plane;
offset = off;
offset = off * 16;

auto firstwall = sec->firstWall();
ix1 = firstwall->wall_int_pos().X;
Expand Down
16 changes: 8 additions & 8 deletions source/games/blood/src/_polymost.cpp
Expand Up @@ -220,14 +220,14 @@ void DrawMirrors(int x, int y, int z, fixed_t a, fixed_t horiz, int smooth, int
pWall->nextsector = mirrorsector;
wallarr[mirrorwall[0]].nextwall = nWall;
wallarr[mirrorwall[0]].nextsector = nSector;
wallarr[mirrorwall[0]].__wall_int_pos.X = pWall->point2Wall()->wall_int_pos().X;
wallarr[mirrorwall[0]].__wall_int_pos.Y = pWall->point2Wall()->wall_int_pos().Y;
wallarr[mirrorwall[1]].__wall_int_pos.X = pWall->wall_int_pos().X;
wallarr[mirrorwall[1]].__wall_int_pos.Y = pWall->wall_int_pos().Y;
wallarr[mirrorwall[2]].__wall_int_pos.X = wallarr[mirrorwall[1]].wall_int_pos().X + (wallarr[mirrorwall[1]].wall_int_pos().X - wallarr[mirrorwall[0]].wall_int_pos().X) * 16;
wallarr[mirrorwall[2]].__wall_int_pos.Y = wallarr[mirrorwall[1]].wall_int_pos().Y + (wallarr[mirrorwall[1]].wall_int_pos().Y - wallarr[mirrorwall[0]].wall_int_pos().Y) * 16;
wallarr[mirrorwall[3]].__wall_int_pos.X = wallarr[mirrorwall[0]].wall_int_pos().X + (wallarr[mirrorwall[0]].wall_int_pos().X - wallarr[mirrorwall[1]].wall_int_pos().X) * 16;
wallarr[mirrorwall[3]].__wall_int_pos.Y = wallarr[mirrorwall[0]].wall_int_pos().Y + (wallarr[mirrorwall[0]].wall_int_pos().Y - wallarr[mirrorwall[1]].wall_int_pos().Y) * 16;
wallarr[mirrorwall[0]].__wall_pos.X = pWall->point2Wall()->__wall_pos.X;
wallarr[mirrorwall[0]].__wall_pos.Y = pWall->point2Wall()->__wall_pos.Y;
wallarr[mirrorwall[1]].__wall_pos.X = pWall->__wall_pos.X;
wallarr[mirrorwall[1]].__wall_pos.Y = pWall->__wall_pos.Y;
wallarr[mirrorwall[2]].__wall_pos.X = wallarr[mirrorwall[1]].__wall_pos.X + (wallarr[mirrorwall[1]].__wall_pos.X - wallarr[mirrorwall[0]].__wall_pos.X) * 16;
wallarr[mirrorwall[2]].__wall_pos.Y = wallarr[mirrorwall[1]].__wall_pos.Y + (wallarr[mirrorwall[1]].__wall_pos.Y - wallarr[mirrorwall[0]].__wall_pos.Y) * 16;
wallarr[mirrorwall[3]].__wall_pos.X = wallarr[mirrorwall[0]].__wall_pos.X + (wallarr[mirrorwall[0]].__wall_pos.X - wallarr[mirrorwall[1]].__wall_pos.X) * 16;
wallarr[mirrorwall[3]].__wall_pos.Y = wallarr[mirrorwall[0]].__wall_pos.Y + (wallarr[mirrorwall[0]].__wall_pos.Y - wallarr[mirrorwall[1]].__wall_pos.Y) * 16;
sector.Data()[mirrorsector].setfloorz(sector[nSector].floorz, true);
sector.Data()[mirrorsector].setceilingz(sector[nSector].ceilingz, true);
int cx, cy, ca;
Expand Down
24 changes: 12 additions & 12 deletions source/games/duke/src/_polymost.cpp
Expand Up @@ -213,27 +213,27 @@ static void geometryEffect(int cposx, int cposy, int cposz, binangle cang, fixed
while (auto act = it.Next())
{
ChangeActorSect(act, geosectorwarp[gs]);
SetActor(act, { act->spr.pos.X -= geox[gs], act->spr.pos.Y -= geoy[gs], act->spr.pos.Z });
SetActor(act, { act->spr.pos.X -= int(geox[gs] * worldtomap), act->spr.pos.Y -= int(geoy[gs] * worldtomap), act->spr.pos.Z });
}
if (geosector[gs] == sectp)
{
geosect = geosectorwarp[gs];
geoid = gs;
}
}
cposx -= geox[geoid];
cposy -= geoy[geoid];
cposx -= int(geox[geoid] * worldtomap);
cposy -= int(geoy[geoid] * worldtomap);
renderDrawRoomsQ16(cposx, cposy, cposz, cang.asq16(), choriz.asq16(), sect, false);
cposx += geox[geoid];
cposy += geoy[geoid];
cposx += int(geox[geoid] * worldtomap);
cposy += int(geoy[geoid] * worldtomap);
for (gs = 0; gs < geocnt; gs++)
{
tgsect = geosectorwarp[gs];
DukeSectIterator it(tgsect);
while (auto act = it.Next())
{
ChangeActorSect(act, geosector[gs]);
SetActor(act, { act->spr.pos.X += geox[gs], act->spr.pos.Y += geoy[gs], act->spr.pos.Z });
SetActor(act, { act->spr.pos.X += int(geox[gs] * worldtomap), act->spr.pos.Y += int(geoy[gs] * worldtomap), act->spr.pos.Z });
}
}
fi.animatesprites(pm_tsprite, pm_spritesortcnt, cposx, cposy, cang.asbuild(), smoothratio);
Expand All @@ -245,27 +245,27 @@ static void geometryEffect(int cposx, int cposy, int cposz, binangle cang, fixed
while (auto act = it.Next())
{
ChangeActorSect(act, geosectorwarp2[gs]);
SetActor(act, { act->spr.pos.X -= geox2[gs], act->spr.pos.Y -= geoy2[gs], act->spr.pos.Z });
SetActor(act, { act->spr.pos.X -= int(geox2[gs] * worldtomap), act->spr.pos.Y -= int(geoy2[gs] * worldtomap), act->spr.pos.Z });
}
if (geosector[gs] == sectp)
{
geosect = geosectorwarp2[gs];
geoid = gs;
}
}
cposx -= geox2[geoid];
cposy -= geoy2[geoid];
cposx -= int(geox2[geoid] * worldtomap);
cposy -= int(geoy2[geoid] * worldtomap);
renderDrawRoomsQ16(cposx, cposy, cposz, cang.asq16(), choriz.asq16(), sect, false);
cposx += geox2[geoid];
cposy += geoy2[geoid];
cposx += int(geox2[geoid] * worldtomap);
cposy += int(geoy2[geoid] * worldtomap);
for (gs = 0; gs < geocnt; gs++)
{
tgsect = geosectorwarp2[gs];
DukeSectIterator it(tgsect);
while (auto act = it.Next())
{
ChangeActorSect(act, geosector[gs]);
SetActor(act, { act->spr.pos.X += geox2[gs], act->spr.pos.Y += geoy2[gs], act->spr.pos.Z });
SetActor(act, { act->spr.pos.X += int(geox2[gs] * worldtomap), act->spr.pos.Y += int(geoy2[gs] * worldtomap), act->spr.pos.Z });
}
}
fi.animatesprites(pm_tsprite, pm_spritesortcnt, cposx, cposy, cang.asbuild(), smoothratio);
Expand Down
8 changes: 4 additions & 4 deletions source/games/duke/src/global.cpp
Expand Up @@ -122,10 +122,10 @@ int wupass; // used to play the level entry sound only once.
sectortype* geosectorwarp[MAXGEOSECTORS]; // geometry render hack (overlay a secondary scene)
sectortype* geosectorwarp2[MAXGEOSECTORS];
sectortype* geosector[MAXGEOSECTORS];
int geox[MAXGEOSECTORS];
int geoy[MAXGEOSECTORS];
int geox2[MAXGEOSECTORS];
int geoy2[MAXGEOSECTORS];
double geox[MAXGEOSECTORS];
double geoy[MAXGEOSECTORS];
double geox2[MAXGEOSECTORS];
double geoy2[MAXGEOSECTORS];
int geocnt;


Expand Down
8 changes: 4 additions & 4 deletions source/games/duke/src/global.h
Expand Up @@ -113,10 +113,10 @@ extern int lastlevel;
extern sectortype* geosectorwarp[MAXGEOSECTORS];
extern sectortype* geosectorwarp2[MAXGEOSECTORS];
extern sectortype* geosector[MAXGEOSECTORS];
extern int geox[MAXGEOSECTORS];
extern int geoy[MAXGEOSECTORS];
extern int geox2[MAXGEOSECTORS];
extern int geoy2[MAXGEOSECTORS];
extern double geox[MAXGEOSECTORS];
extern double geoy[MAXGEOSECTORS];
extern double geox2[MAXGEOSECTORS];
extern double geoy2[MAXGEOSECTORS];
extern int geocnt;

extern short ambientlotag[64];
Expand Down
8 changes: 4 additions & 4 deletions source/games/duke/src/premap_r.cpp
Expand Up @@ -605,15 +605,15 @@ void prelevel_r(int g, TArray<DDukeActor*>& actors)
if (actor2->spr.hitag == 1)
{
geosectorwarp[geocnt] = actor2->sector();
geox[geocnt] = actor->spr.pos.X - actor2->spr.pos.X;
geoy[geocnt] = actor->spr.pos.Y - actor2->spr.pos.Y;
geox[geocnt] = (actor->spr.pos.X - actor2->spr.pos.X) * maptoworld;
geoy[geocnt] = (actor->spr.pos.Y - actor2->spr.pos.Y) * maptoworld;
//geoz[geocnt] = actor->spr.z - actor2->spr.z;
}
if (actor2->spr.hitag == 2)
{
geosectorwarp2[geocnt] = actor2->sector();
geox2[geocnt] = actor->spr.pos.X - actor2->spr.pos.X;
geoy2[geocnt] = actor->spr.pos.Y - actor2->spr.pos.Y;
geox2[geocnt] = (actor->spr.pos.X - actor2->spr.pos.X) * maptoworld;
geoy2[geocnt] = (actor->spr.pos.Y - actor2->spr.pos.Y) * maptoworld;
//geoz2[geocnt] = actor->spr.z - actor2->spr.z;
}
}
Expand Down
4 changes: 2 additions & 2 deletions source/games/duke/src/sectors.cpp
Expand Up @@ -319,11 +319,11 @@ void setanimatevalue(int type, int index, double value)
break;
case anim_vertexx:
wall[index].moved();
wall[index].__wall_int_pos.X = (int)value;
wall[index].__wall_pos.X = value * maptoworld;
break;
case anim_vertexy:
wall[index].moved();
wall[index].__wall_int_pos.Y = (int)value;
wall[index].__wall_pos.Y = value * maptoworld;
break;
default:
assert(false);
Expand Down
8 changes: 4 additions & 4 deletions source/games/sw/src/interpso.cpp
Expand Up @@ -95,9 +95,9 @@ static double getvalue(so_interp::interp_data& element)
switch (type)
{
case soi_wallx:
return wall[index].wall_int_pos().X;
return wall[index].__wall_pos.X;
case soi_wally:
return wall[index].wall_int_pos().Y;
return wall[index].__wall_pos.Y;
case soi_ceil:
return sector[index].ceilingz;
case soi_floor:
Expand Down Expand Up @@ -134,11 +134,11 @@ static void setvalue(so_interp::interp_data& element, double value)
{
case soi_wallx:
wall[index].moved();
wall[index].__wall_int_pos.X = (int)value;
wall[index].__wall_pos.X = value;
break;
case soi_wally:
wall[index].moved();
wall[index].__wall_int_pos.Y = (int)value;
wall[index].__wall_pos.Y = value;
break;
case soi_ceil:
sector[index].setceilingz((int)value);
Expand Down

0 comments on commit cd55658

Please sign in to comment.