From 928d0b277870618230f370df0016875441e8cb54 Mon Sep 17 00:00:00 2001 From: ZZYZX Date: Thu, 19 Jan 2017 10:56:28 +0200 Subject: [PATCH 1/2] Exposed P_ChangeSector as Sector.ChangeSector --- src/p_map.cpp | 15 +++++++++++++++ wadsrc/static/zscript/mapdata.txt | 11 ++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index ae3dfd0f2..9ca2d3a8f 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -6358,6 +6358,21 @@ void PIT_CeilingRaise(AActor *thing, FChangePosition *cpos) // //============================================================================= +// +DEFINE_ACTION_FUNCTION(_Sector, ChangeSector) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(crunch); + PARAM_FLOAT(amt); + PARAM_INT(floorOrCeil); + PARAM_BOOL(isreset); + PARAM_BOOL(instant); + + bool b = P_ChangeSector(self, crunch, amt, floorOrCeil, isreset, instant); + + ACTION_RETURN_BOOL(b); +} + bool P_ChangeSector(sector_t *sector, int crunch, double amt, int floorOrCeil, bool isreset, bool instant) { FChangePosition cpos; diff --git a/wadsrc/static/zscript/mapdata.txt b/wadsrc/static/zscript/mapdata.txt index b7589f8d4..15f798460 100644 --- a/wadsrc/static/zscript/mapdata.txt +++ b/wadsrc/static/zscript/mapdata.txt @@ -270,7 +270,7 @@ struct Sector native SECF_NOMODIFY = SECF_SECRET|SECF_WASSECRET, // not modifiable by Sector_ChangeFlags SECF_SPECIALFLAGS = SECF_DAMAGEFLAGS|SECF_FRICTION|SECF_PUSH, // these flags originate from 'special and must be transferrable by floor thinkers } - + enum EMoveResult { MOVE_OK, @@ -289,6 +289,15 @@ struct Sector native native int Index(); + enum EChangeSectorMode + { + CS_Floor = 0, + CS_Ceiling = 1, + CS_3DMidTex = 2 + }; + + native bool ChangeSector(int crunch, double amt, EChangeSectorMode mode/*floorOrCeiling*/, bool isreset, bool instant); + native double, Sector, F3DFloor NextHighestCeilingAt(double x, double y, double bottomz, double topz, int flags = 0); native double, Sector, F3DFloor NextLowestFloorAt(double x, double y, double z, int flags = 0, double steph = 0); From 4815d5a8353b29e08ed9bffa593915daff05bf3c Mon Sep 17 00:00:00 2001 From: ZZYZX Date: Thu, 19 Jan 2017 11:25:06 +0200 Subject: [PATCH 2/2] Made plane normal changes trigger the VBO update as well --- src/gl/data/gl_vertexbuffer.cpp | 26 +++++++++++++++++--------- src/r_defs.h | 1 + 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 4973ad39d..957884bb0 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -397,7 +397,9 @@ void FFlatVertexBuffer::CreateFlatVBO() { for(auto &sec : level.sectors) { - CreateVertices(h, &sec, sec.GetSecPlane(h), h == sector_t::floor); + secplane_t& plane = sec.GetSecPlane(h); + CreateVertices(h, &sec, plane, h == sector_t::floor); + plane.vbonormal = plane.normal; } } @@ -464,15 +466,21 @@ void FFlatVertexBuffer::CreateVBO() void FFlatVertexBuffer::CheckPlanes(sector_t *sector) { - if (sector->GetPlaneTexZ(sector_t::ceiling) != sector->vboheight[sector_t::ceiling]) + for (int i = sector_t::floor; i <= sector_t::ceiling; i++) { - UpdatePlaneVertices(sector, sector_t::ceiling); - sector->vboheight[sector_t::ceiling] = sector->GetPlaneTexZ(sector_t::ceiling); - } - if (sector->GetPlaneTexZ(sector_t::floor) != sector->vboheight[sector_t::floor]) - { - UpdatePlaneVertices(sector, sector_t::floor); - sector->vboheight[sector_t::floor] = sector->GetPlaneTexZ(sector_t::floor); + if (sector->GetPlaneTexZ(i) != sector->vboheight[i]) + { + UpdatePlaneVertices(sector, i); + sector->vboheight[i] = sector->GetPlaneTexZ(i); + continue; + } + + secplane_t &splane = sector->GetSecPlane(i); + if (splane.normal != splane.vbonormal) + { + UpdatePlaneVertices(sector, i); + splane.vbonormal = splane.normal; + } } } diff --git a/src/r_defs.h b/src/r_defs.h index a6e8358ee..d697805f0 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -300,6 +300,7 @@ struct secplane_t //private: DVector3 normal; double D, negiC; // negative iC because that also saves a negation in all methods using this. + DVector3 vbonormal; // [ZZ] for opengl update. it's critical that this member is the last one, so that {{x,y,z},...} works properly public: friend FSerializer &Serialize(FSerializer &arc, const char *key, secplane_t &p, secplane_t *def);