diff --git a/src/maploader/maploader.h b/src/maploader/maploader.h index cc7e08187e..93c65f9838 100644 --- a/src/maploader/maploader.h +++ b/src/maploader/maploader.h @@ -110,8 +110,6 @@ private: int firstglvertex; // helpers for loading GL nodes from GWA files. bool format5; - TArray vertexdatas; - TMap MapThingsUserDataIndex; // from mapthing idx -> user data idx TArray MapThingsUserData; int sidecount = 0; @@ -120,6 +118,8 @@ private: public: // for the scripted compatibility system these two members need to be public. TArray MapThingsConverted; bool ForceNodeBuild = false; + // This needs to be public to fetch this from DLevelPostProcessor native functions + TArray vertexdatas; private: // Extradata loader diff --git a/src/maploader/postprocessor.cpp b/src/maploader/postprocessor.cpp index d47b2df8ee..4c0875dbb0 100644 --- a/src/maploader/postprocessor.cpp +++ b/src/maploader/postprocessor.cpp @@ -437,6 +437,77 @@ DEFINE_ACTION_FUNCTION(DLevelPostProcessor, SetVertex) return 0; } +DEFINE_ACTION_FUNCTION(DLevelPostProcessor, GetVertexZ) +{ + PARAM_SELF_PROLOGUE(DLevelPostProcessor); + PARAM_UINT(vertex); + PARAM_INT(planeval); + + if (vertex < self->Level->vertexes.Size() && vertex < self->loader->vertexdatas.Size()) + { + vertexdata_t& data = self->loader->vertexdatas[vertex]; + double value = planeval ? data.zFloor : data.zCeiling; + ACTION_RETURN_FLOAT(value); + } + + ACTION_RETURN_FLOAT(0); +} + +DEFINE_ACTION_FUNCTION(DLevelPostProcessor, IsVertexZSet) +{ + PARAM_SELF_PROLOGUE(DLevelPostProcessor); + PARAM_UINT(vertex); + PARAM_INT(planeval); + + if (vertex < self->Level->vertexes.Size() && vertex < self->loader->vertexdatas.Size()) + { + vertexdata_t& data = self->loader->vertexdatas[vertex]; + bool value = data.flags & (planeval ? VERTEXFLAG_ZFloorEnabled : VERTEXFLAG_ZCeilingEnabled); + ACTION_RETURN_BOOL(value); + } + + ACTION_RETURN_BOOL(false); +} + +DEFINE_ACTION_FUNCTION(DLevelPostProcessor, SetVertexZ) +{ + PARAM_SELF_PROLOGUE(DLevelPostProcessor); + PARAM_UINT(vertex); + PARAM_INT(planeval); + PARAM_FLOAT(z); + + if (vertex < self->Level->vertexes.Size() && vertex < self->loader->vertexdatas.Size()) + { + vertexdata_t& data = self->loader->vertexdatas[vertex]; + if (planeval) { + data.flags |= VERTEXFLAG_ZFloorEnabled; + data.zFloor = z; + } + else + { + data.flags |= VERTEXFLAG_ZCeilingEnabled; + data.zCeiling = z; + } + } + + return 0; +} + +DEFINE_ACTION_FUNCTION(DLevelPostProcessor, UnsetVertexZ) +{ + PARAM_SELF_PROLOGUE(DLevelPostProcessor); + PARAM_UINT(vertex); + PARAM_INT(planeval); + + 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); + } + + return 0; +} + DEFINE_ACTION_FUNCTION(DLevelPostProcessor, SetLineVertexes) { PARAM_SELF_PROLOGUE(DLevelPostProcessor); diff --git a/wadsrc/static/zscript/level_postprocessor.zs b/wadsrc/static/zscript/level_postprocessor.zs index 93ee8343de..266ad6404c 100644 --- a/wadsrc/static/zscript/level_postprocessor.zs +++ b/wadsrc/static/zscript/level_postprocessor.zs @@ -47,6 +47,10 @@ class LevelPostProcessor native play protected native void SetThingStringArgument(uint thing, Name value); protected native void SetVertex(uint vertex, double x, double y); + protected native double GetVertexZ(uint vertex, int plane); + protected native bool IsVertexZSet(uint vertex, int plane); + protected native void SetVertexZ(uint vertex, int plane, double z); + protected native void UnsetVertexZ(uint vertex, int plane); protected native void SetLineVertexes(uint Line, uint v1, uint v2); protected native void FlipLineSideRefs(uint Line); protected native void SetLineSectorRef(uint line, uint side, uint sector);