mirror of
https://github.com/DrBeef/Raze.git
synced 2025-01-19 07:31:03 +00:00
- use floats for ceilingz/floorz storage.
This commit is contained in:
parent
367a998b40
commit
a59a771209
11 changed files with 65 additions and 58 deletions
|
@ -522,12 +522,13 @@ int inside(double x, double y, const sectortype* sect)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
sectortype* nextsectorneighborzptr(sectortype* sectp, int startz, int flags)
|
||||
sectortype* nextsectorneighborzptr(sectortype* sectp, int startz_, int flags)
|
||||
{
|
||||
int factor = (flags & Find_Up)? -1 : 1;
|
||||
double startz = startz_ * zinttoworld;
|
||||
double factor = (flags & Find_Up)? -1 : 1;
|
||||
int bestz = INT_MAX;
|
||||
sectortype* bestsec = (flags & Find_Safe)? sectp : nullptr;
|
||||
const auto planez = (flags & Find_Ceiling)? §ortype::__int_ceilingz : §ortype::__int_floorz;
|
||||
const auto planez = (flags & Find_Ceiling)? §ortype::ceilingz : §ortype::floorz;
|
||||
|
||||
startz *= factor;
|
||||
for(auto& wal : wallsofsector(sectp))
|
||||
|
|
|
@ -41,8 +41,8 @@ double Get(int index, DCoreActor* actor, int type)
|
|||
{
|
||||
switch(type)
|
||||
{
|
||||
case Interp_Sect_Floorz: return sector[index].int_floorz();
|
||||
case Interp_Sect_Ceilingz: return sector[index].int_ceilingz();
|
||||
case Interp_Sect_Floorz: return sector[index].floorz;
|
||||
case Interp_Sect_Ceilingz: return sector[index].ceilingz;
|
||||
case Interp_Sect_Floorheinum: return sector[index].floorheinum;
|
||||
case Interp_Sect_Ceilingheinum: return sector[index].ceilingheinum;
|
||||
case Interp_Sect_FloorPanX: return sector[index].floorxpan_;
|
||||
|
@ -65,8 +65,8 @@ void Set(int index, DCoreActor* actor, int type, double val)
|
|||
int old;
|
||||
switch(type)
|
||||
{
|
||||
case Interp_Sect_Floorz: sector[index].set_int_floorz(xs_CRoundToInt(val)); break;
|
||||
case Interp_Sect_Ceilingz: sector[index].set_int_ceilingz(xs_CRoundToInt(val)); break;
|
||||
case Interp_Sect_Floorz: sector[index].setfloorz(val); break;
|
||||
case Interp_Sect_Ceilingz: sector[index].setceilingz(val); break;
|
||||
case Interp_Sect_Floorheinum: sector[index].floorheinum = (short)xs_CRoundToInt(val); break;
|
||||
case Interp_Sect_Ceilingheinum: sector[index].ceilingheinum = (short)xs_CRoundToInt(val); break;
|
||||
case Interp_Sect_FloorPanX: sector[index].floorxpan_ = float(val); break;
|
||||
|
|
|
@ -98,8 +98,9 @@ static void ReadSectorV7(FileReader& fr, sectortype& sect)
|
|||
{
|
||||
sect.wallptr = fr.ReadInt16();
|
||||
sect.wallnum = fr.ReadInt16();
|
||||
sect.set_int_ceilingz(fr.ReadInt32(), true);
|
||||
sect.set_int_floorz(fr.ReadInt32(), true);
|
||||
int c = fr.ReadInt32();
|
||||
int f = fr.ReadInt32();
|
||||
sect.setzfrommap(c, f);
|
||||
sect.ceilingstat = ESectorFlags::FromInt(fr.ReadUInt16());
|
||||
sect.floorstat = ESectorFlags::FromInt(fr.ReadUInt16());
|
||||
sect.ceilingpicnum = fr.ReadUInt16();
|
||||
|
@ -129,8 +130,9 @@ static void ReadSectorV6(FileReader& fr, sectortype& sect)
|
|||
sect.floorpicnum = fr.ReadUInt16();
|
||||
sect.ceilingheinum = clamp(fr.ReadInt16() << 5, -32768, 32767);
|
||||
sect.floorheinum = clamp(fr.ReadInt16() << 5, -32768, 32767);
|
||||
sect.set_int_ceilingz(fr.ReadInt32(), true);
|
||||
sect.set_int_floorz(fr.ReadInt32(), true);
|
||||
int c = fr.ReadInt32();
|
||||
int f = fr.ReadInt32();
|
||||
sect.setzfrommap(c, f);
|
||||
sect.ceilingshade = fr.ReadInt8();
|
||||
sect.floorshade = fr.ReadInt8();
|
||||
sect.ceilingxpan_ = fr.ReadUInt8();
|
||||
|
@ -156,8 +158,9 @@ static void ReadSectorV5(FileReader& fr, sectortype& sect)
|
|||
sect.floorpicnum = fr.ReadUInt16();
|
||||
sect.ceilingheinum = clamp(fr.ReadInt16() << 5, -32768, 32767);
|
||||
sect.floorheinum = clamp(fr.ReadInt16() << 5, -32768, 32767);
|
||||
sect.set_int_ceilingz(fr.ReadInt32(), true);
|
||||
sect.set_int_floorz(fr.ReadInt32(), true);
|
||||
int c = fr.ReadInt32();
|
||||
int f = fr.ReadInt32();
|
||||
sect.setzfrommap(c, f);
|
||||
sect.ceilingshade = fr.ReadInt8();
|
||||
sect.floorshade = fr.ReadInt8();
|
||||
sect.ceilingxpan_ = fr.ReadUInt8();
|
||||
|
|
|
@ -227,9 +227,8 @@ struct sectortype
|
|||
// Debug hack job for finding all places where ceilingz and floorz get written to.
|
||||
// If the engine does not compile with this block on, we got a problem.
|
||||
// Since this is only for compile verification there's no need to provide a working implementation.
|
||||
const int32_t __int_ceilingz;
|
||||
const int32_t __int_floorz;
|
||||
sectortype(int a = 0, int b = 0) : ceilingz(a), floorz(b) {}
|
||||
const double floorz, ceilingz;
|
||||
sectortype(double a = 0, double b = 0) : ceilingz(a), floorz(b) {}
|
||||
|
||||
void set_int_ceilingz(int cc, bool temp = false) {}
|
||||
void set_int_floorz(int cc, bool temp = false) {}
|
||||
|
@ -238,28 +237,30 @@ struct sectortype
|
|||
|
||||
#else
|
||||
// Do not change directly!
|
||||
int32_t __int_ceilingz;
|
||||
int32_t __int_floorz;
|
||||
double floorz, ceilingz;
|
||||
|
||||
/*
|
||||
void setceilingz(double cc, bool temp = false);
|
||||
void setfloorz(double cc, bool temp = false);
|
||||
void addceilingz(double cc, bool temp = false);
|
||||
void addfloorz(double cc, bool temp = false);
|
||||
*/
|
||||
|
||||
void set_int_ceilingz(int cc, bool temp = false) { setceilingz(cc * zinttoworld, temp); }
|
||||
void set_int_floorz(int cc, bool temp = false) { setfloorz(cc * zinttoworld, temp); }
|
||||
void add_int_ceilingz(int cc, bool temp = false) { addceilingz(cc * zinttoworld, temp); }
|
||||
void add_int_floorz(int cc, bool temp = false) { addfloorz(cc * zinttoworld, temp); }
|
||||
|
||||
void set_int_ceilingz(int cc, bool temp = false);
|
||||
void set_int_floorz(int cc, bool temp = false);
|
||||
void add_int_ceilingz(int cc, bool temp = false);
|
||||
void add_int_floorz(int cc, bool temp = false);
|
||||
void setzfrommap(int c, int f)
|
||||
{
|
||||
ceilingz = c * zmaptoworld;
|
||||
floorz = f * zmaptoworld;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int int_ceilingz() const { return __int_ceilingz; }
|
||||
int int_floorz() const { return __int_floorz; }
|
||||
float render_ceilingz() const { return __int_ceilingz * (float)zinttoworld; }
|
||||
float render_floorz() const { return __int_floorz * (float)zinttoworld; }
|
||||
int int_ceilingz() const { return ceilingz * zworldtoint; }
|
||||
int int_floorz() const { return floorz * zworldtoint; }
|
||||
float render_ceilingz() const { return (float)-ceilingz; }
|
||||
float render_floorz() const { return (float)-floorz; }
|
||||
|
||||
|
||||
// panning byte fields were promoted to full floats to enable panning interpolation.
|
||||
|
@ -673,24 +674,24 @@ inline int walltype::Length()
|
|||
|
||||
#ifndef SECTOR_HACKJOB
|
||||
|
||||
inline void sectortype::set_int_ceilingz(int cc, bool temp)
|
||||
inline void sectortype::setceilingz(double cc, bool temp)
|
||||
{
|
||||
__int_ceilingz = cc;
|
||||
ceilingz = cc;
|
||||
if (!temp) MarkVerticesForSector(sector.IndexOf(this));
|
||||
}
|
||||
inline void sectortype::set_int_floorz(int cc, bool temp)
|
||||
inline void sectortype::setfloorz(double cc, bool temp)
|
||||
{
|
||||
__int_floorz = cc;
|
||||
floorz = cc;
|
||||
if (!temp) MarkVerticesForSector(sector.IndexOf(this));
|
||||
}
|
||||
inline void sectortype::add_int_ceilingz(int cc, bool temp)
|
||||
inline void sectortype::addceilingz(double cc, bool temp)
|
||||
{
|
||||
__int_ceilingz += cc;
|
||||
ceilingz += cc;
|
||||
if (!temp) MarkVerticesForSector(sector.IndexOf(this));
|
||||
}
|
||||
inline void sectortype::add_int_floorz(int cc, bool temp)
|
||||
inline void sectortype::addfloorz(double cc, bool temp)
|
||||
{
|
||||
__int_floorz += cc;
|
||||
floorz += cc;
|
||||
if (!temp) MarkVerticesForSector(sector.IndexOf(this));
|
||||
}
|
||||
|
||||
|
|
|
@ -179,7 +179,7 @@ public:
|
|||
HWSkyInfo * sky; // for normal sky
|
||||
//HWHorizonInfo * horizon; // for horizon information
|
||||
PortalDesc * portal; // stacked sector portals
|
||||
const int * planemirror; // for plane mirrors
|
||||
const double * planemirror; // for plane mirrors
|
||||
};
|
||||
|
||||
unsigned int vertindex;
|
||||
|
|
|
@ -114,7 +114,7 @@ void HWWall::SkyPlane(HWDrawInfo *di, sectortype *sector, int plane, bool allowr
|
|||
ptype = PORTALTYPE_PLANEMIRROR;
|
||||
if (plane == plane_ceiling && (sector->ceilingstat & CSTAT_SECTOR_SLOPE)) return;
|
||||
if (plane == plane_floor && (sector->floorstat & CSTAT_SECTOR_SLOPE)) return;
|
||||
planemirror = plane == plane_floor ? §or->__int_floorz : §or->__int_ceilingz;
|
||||
planemirror = plane == plane_floor ? §or->floorz : §or->ceilingz;
|
||||
PutPortal(di, PORTALTYPE_PLANEMIRROR, plane);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -512,8 +512,8 @@ FSerializer &Serialize(FSerializer &arc, const char *key, sectortype &c, sectort
|
|||
("wallptr", c.wallptr, def->wallptr)
|
||||
("wallnum", c.wallnum, def->wallnum)
|
||||
#ifndef SECTOR_HACKJOB // can't save these in test mode...
|
||||
("ceilingz", c.__int_ceilingz, def->__int_ceilingz)
|
||||
("floorz", c.__int_floorz, def->__int_floorz)
|
||||
("ceilingz", c.ceilingz, def->ceilingz)
|
||||
("floorz", c.floorz, def->floorz)
|
||||
#endif
|
||||
("ceilingstat", c.ceilingstat, def->ceilingstat)
|
||||
("floorstat", c.floorstat, def->floorstat)
|
||||
|
|
|
@ -61,6 +61,8 @@ DEFINE_FIELD_X(sectortype, sectortype, floorpal)
|
|||
DEFINE_FIELD_X(sectortype, sectortype, visibility)
|
||||
DEFINE_FIELD_X(sectortype, sectortype, fogpal)
|
||||
DEFINE_FIELD_X(sectortype, sectortype, exflags)
|
||||
DEFINE_FIELD_X(sectortype, sectortype, floorz)
|
||||
DEFINE_FIELD_X(sectortype, sectortype, ceilingz)
|
||||
|
||||
DEFINE_FIELD_NAMED_X(walltype, walltype, xpan_, xpan)
|
||||
DEFINE_FIELD_NAMED_X(walltype, walltype, ypan_, ypan)
|
||||
|
@ -107,56 +109,56 @@ DEFINE_GLOBAL(sector)
|
|||
void sector_setfloorz(sectortype* sect, double val)
|
||||
{
|
||||
if (!sect) ThrowAbortException(X_READ_NIL, nullptr);
|
||||
sect->set_int_floorz(int(val * zworldtoint));
|
||||
sect->setfloorz(val);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_sectortype, setfloorz, sector_floorz)
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_sectortype, setfloorz, sector_setfloorz)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(sectortype);
|
||||
PARAM_FLOAT(z);
|
||||
self->set_int_floorz(z);
|
||||
self->setfloorz(z);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sector_setceilingz(sectortype* sect, double val)
|
||||
{
|
||||
if (!sect) ThrowAbortException(X_READ_NIL, nullptr);
|
||||
sect->set_int_ceilingz(int(val * zworldtoint));
|
||||
sect->setceilingz(val);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_sectortype, setceilingz, sector_ceilingz)
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_sectortype, setceilingz, sector_setceilingz)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(sectortype);
|
||||
PARAM_FLOAT(z);
|
||||
self->set_int_ceilingz(z);
|
||||
self->setceilingz(z);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sector_addfloorz(sectortype* sect, double val)
|
||||
{
|
||||
if (!sect) ThrowAbortException(X_READ_NIL, nullptr);
|
||||
sect->add_int_floorz(int(val * zworldtoint));
|
||||
sect->addfloorz(val);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_sectortype, addfloorz, sector_floorz)
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_sectortype, addfloorz, sector_addfloorz)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(sectortype);
|
||||
PARAM_FLOAT(z);
|
||||
self->add_int_floorz(z);
|
||||
self->addfloorz(z);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sector_addceilingz(sectortype* sect, double val)
|
||||
{
|
||||
if (!sect) ThrowAbortException(X_READ_NIL, nullptr);
|
||||
sect->add_int_ceilingz(int(val * zworldtoint));
|
||||
sect->addceilingz(val);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_sectortype, addceilingz, sector_ceilingz)
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_sectortype, addceilingz, sector_addceilingz)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(sectortype);
|
||||
PARAM_FLOAT(z);
|
||||
self->add_int_ceilingz(z);
|
||||
self->addceilingz(z);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -257,8 +257,7 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, int*
|
|||
}
|
||||
pSector->wallptr = LittleShort(load.wallptr);
|
||||
pSector->wallnum = LittleShort(load.wallnum);
|
||||
pSector->set_int_ceilingz(LittleLong(load.ceilingz), true);
|
||||
pSector->set_int_floorz(LittleLong(load.floorz), true);
|
||||
pSector->setzfrommap(LittleLong(load.ceilingz), LittleLong(load.floorz));
|
||||
pSector->ceilingstat = ESectorFlags::FromInt(LittleShort(load.ceilingstat));
|
||||
pSector->floorstat = ESectorFlags::FromInt(LittleShort(load.floorstat));
|
||||
pSector->ceilingpicnum = LittleShort(load.ceilingpicnum);
|
||||
|
|
|
@ -99,9 +99,9 @@ static double getvalue(so_interp::interp_data& element)
|
|||
case soi_wally:
|
||||
return wall[index].pos.Y;
|
||||
case soi_ceil:
|
||||
return sector[index].int_ceilingz();
|
||||
return sector[index].ceilingz;
|
||||
case soi_floor:
|
||||
return sector[index].int_floorz();
|
||||
return sector[index].floorz;
|
||||
case soi_sox:
|
||||
return SectorObject[index].pmid.X;
|
||||
case soi_soy:
|
||||
|
@ -141,10 +141,10 @@ static void setvalue(so_interp::interp_data& element, double value)
|
|||
wall[index].moved();
|
||||
break;
|
||||
case soi_ceil:
|
||||
sector[index].set_int_ceilingz((int)value);
|
||||
sector[index].setceilingz(value);
|
||||
break;
|
||||
case soi_floor:
|
||||
sector[index].set_int_floorz((int)value);
|
||||
sector[index].setfloorz(value);
|
||||
break;
|
||||
case soi_sox:
|
||||
SectorObject[index].pmid.X = (int)value;
|
||||
|
|
|
@ -114,6 +114,7 @@ struct sectortype native
|
|||
native readonly float ceilingypan;
|
||||
native readonly float floorxpan;
|
||||
native readonly float floorypan;
|
||||
native readonly double ceilingz, floorz;
|
||||
|
||||
native readonly int wallptr;
|
||||
native readonly int16 wallnum;
|
||||
|
|
Loading…
Reference in a new issue