Skip to content

Commit

Permalink
Fix planeval; add direct sector slope manipulation
Browse files Browse the repository at this point in the history
  • Loading branch information
ZZYZX authored and madame-rachelle committed Sep 20, 2022
1 parent f049421 commit a4a4e4e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
39 changes: 35 additions & 4 deletions src/maploader/postprocessor.cpp
Expand Up @@ -110,6 +110,37 @@ DEFINE_ACTION_FUNCTION(DLevelPostProcessor, OffsetSectorPlane)
return 0;
}

DEFINE_ACTION_FUNCTION(DLevelPostProcessor, SetSectorPlane)
{
PARAM_SELF_PROLOGUE(DLevelPostProcessor);
PARAM_INT(sector);
PARAM_INT(planeval);
PARAM_FLOAT(normal_x);
PARAM_FLOAT(normal_y);
PARAM_FLOAT(normal_z);
PARAM_FLOAT(d);

if ((unsigned)sector < self->Level->sectors.Size())
{
sector_t* sec = &self->Level->sectors[sector];
secplane_t& plane = sector_t::floor == planeval ? sec->floorplane : sec->ceilingplane;
if (normal_z != 0)
{
plane.normal = DVector3(normal_x, normal_y, normal_z);
plane.D = d;
plane.negiC = -1 / normal_z;
}
else
{
plane.normal = DVector3(0, 0, sector_t::floor == planeval ? 1 : -1);
plane.D = d;
plane.negiC = -1 / plane.normal.Z;
}
}

return 0;
}

DEFINE_ACTION_FUNCTION(DLevelPostProcessor, ClearSectorTags)
{
PARAM_SELF_PROLOGUE(DLevelPostProcessor);
Expand Down Expand Up @@ -449,8 +480,8 @@ DEFINE_ACTION_FUNCTION(DLevelPostProcessor, GetVertexZ)
if (vertex < self->Level->vertexes.Size() && vertex < self->loader->vertexdatas.Size())
{
vertexdata_t& data = self->loader->vertexdatas[vertex];
value = planeval ? data.zFloor : data.zCeiling;
isset = data.flags & (planeval ? VERTEXFLAG_ZFloorEnabled : VERTEXFLAG_ZCeilingEnabled);
value = sector_t::floor == planeval ? data.zFloor : data.zCeiling;
isset = data.flags & (sector_t::floor == planeval ? VERTEXFLAG_ZFloorEnabled : VERTEXFLAG_ZCeilingEnabled);
}

if (numret > 1)
Expand All @@ -477,7 +508,7 @@ DEFINE_ACTION_FUNCTION(DLevelPostProcessor, SetVertexZ)
if (vertex < self->Level->vertexes.Size() && vertex < self->loader->vertexdatas.Size())
{
vertexdata_t& data = self->loader->vertexdatas[vertex];
if (planeval) {
if (sector_t::floor == planeval) {
data.flags |= VERTEXFLAG_ZFloorEnabled;
data.zFloor = z;
}
Expand All @@ -500,7 +531,7 @@ DEFINE_ACTION_FUNCTION(DLevelPostProcessor, RemoveVertexZ)
if (vertex < self->Level->vertexes.Size() && vertex < self->loader->vertexdatas.Size())
{
vertexdata_t& data = self->loader->vertexdatas[vertex];
data.flags &= ~(planeval ? VERTEXFLAG_ZFloorEnabled : VERTEXFLAG_ZCeilingEnabled);
data.flags &= ~(sector_t::floor == planeval ? VERTEXFLAG_ZFloorEnabled : VERTEXFLAG_ZCeilingEnabled);
}

return 0;
Expand Down
1 change: 1 addition & 0 deletions wadsrc/static/zscript/level_postprocessor.zs
Expand Up @@ -12,6 +12,7 @@ class LevelPostProcessor native play
protected native void ClearLineIDs(int line);
protected native void AddLineID(int line, int tag);
protected native void OffsetSectorPlane(int sector, int plane, double offset);
protected native void SetSectorPlane(int sector, int plane, vector3 normal, double d);

const SKILLS_ALL = 31;
const MODES_ALL = MTF_SINGLE | MTF_COOPERATIVE | MTF_DEATHMATCH;
Expand Down

0 comments on commit a4a4e4e

Please sign in to comment.