Add vertex height manipulation functions to LevelPostProcessor

This commit is contained in:
ZZYZX 2022-09-04 11:06:23 +03:00 committed by Rachael Alexanderson
parent dbe696751b
commit a58acfc625
3 changed files with 77 additions and 2 deletions

View file

@ -110,8 +110,6 @@ private:
int firstglvertex; // helpers for loading GL nodes from GWA files. int firstglvertex; // helpers for loading GL nodes from GWA files.
bool format5; bool format5;
TArray<vertexdata_t> vertexdatas;
TMap<unsigned, unsigned> MapThingsUserDataIndex; // from mapthing idx -> user data idx TMap<unsigned, unsigned> MapThingsUserDataIndex; // from mapthing idx -> user data idx
TArray<FUDMFKey> MapThingsUserData; TArray<FUDMFKey> MapThingsUserData;
int sidecount = 0; int sidecount = 0;
@ -120,6 +118,8 @@ private:
public: // for the scripted compatibility system these two members need to be public. public: // for the scripted compatibility system these two members need to be public.
TArray<FMapThing> MapThingsConverted; TArray<FMapThing> MapThingsConverted;
bool ForceNodeBuild = false; bool ForceNodeBuild = false;
// This needs to be public to fetch this from DLevelPostProcessor native functions
TArray<vertexdata_t> vertexdatas;
private: private:
// Extradata loader // Extradata loader

View file

@ -437,6 +437,77 @@ DEFINE_ACTION_FUNCTION(DLevelPostProcessor, SetVertex)
return 0; 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) DEFINE_ACTION_FUNCTION(DLevelPostProcessor, SetLineVertexes)
{ {
PARAM_SELF_PROLOGUE(DLevelPostProcessor); PARAM_SELF_PROLOGUE(DLevelPostProcessor);

View file

@ -47,6 +47,10 @@ class LevelPostProcessor native play
protected native void SetThingStringArgument(uint thing, Name value); protected native void SetThingStringArgument(uint thing, Name value);
protected native void SetVertex(uint vertex, double x, double y); 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 SetLineVertexes(uint Line, uint v1, uint v2);
protected native void FlipLineSideRefs(uint Line); protected native void FlipLineSideRefs(uint Line);
protected native void SetLineSectorRef(uint line, uint side, uint sector); protected native void SetLineSectorRef(uint line, uint side, uint sector);