From d11f6819db2a25133b7d44703c39b9ba2ec756ff Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 29 Sep 2022 15:26:36 +0200 Subject: [PATCH] - got rid of the getzrange wrapper. --- source/build/include/build.h | 15 +-------------- source/build/src/clip.cpp | 32 +++++++++++++++++--------------- 2 files changed, 18 insertions(+), 29 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index 01691bb8f..bfb83107f 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -111,20 +111,7 @@ void setVideoMode(); class F2DDrawer; -void getzrange_(const vec3_t& pos, sectortype* sect, int32_t* ceilz, CollisionBase& ceilhit, int32_t* florz, - CollisionBase& florhit, int32_t walldist, uint32_t cliptype); - -inline void getzrange(const DVector3& pos, sectortype* sect, double* ceilz, CollisionBase& ceilhit, double* florz, - CollisionBase& florhit, int32_t walldist, uint32_t cliptype) -{ - vec3_t ipos(int(pos.X * worldtoint), int(pos.Y * worldtoint), int(pos.Z * zworldtoint) ); - - int c = int(*ceilz * zworldtoint); - int f = int(*florz * zworldtoint); - getzrange_(ipos, sect, &c, ceilhit, &f, florhit, walldist, cliptype); - *ceilz = c * zinttoworld; - *florz = f * zinttoworld; -} +void getzrange(const DVector3& pos, sectortype* sect, double* ceilz, CollisionBase& ceilhit, double* florz, CollisionBase& florhit, int32_t walldist, uint32_t cliptype); struct HitInfoBase; diff --git a/source/build/src/clip.cpp b/source/build/src/clip.cpp index b57ec1bae..0b1382cbc 100644 --- a/source/build/src/clip.cpp +++ b/source/build/src/clip.cpp @@ -887,12 +887,15 @@ int pushmove_(vec3_t *const vect, int *const sectnum, // getzrange // -void getzrange_(const vec3_t& pos, sectortype* sect, int32_t* ceilz, CollisionBase& ceilhit, int32_t* florz, CollisionBase& florhit, int32_t walldist, uint32_t cliptype) + +void getzrange(const DVector3& pos_, sectortype* sect, double* ceilz_, CollisionBase& ceilhit, double* florz_, CollisionBase& florhit, int32_t walldist, uint32_t cliptype) { + vec3_t pos(int(pos_.X * worldtoint), int(pos_.Y * worldtoint), int(pos_.Z * zworldtoint) ); + if (sect == nullptr) { - *ceilz = INT32_MIN; ceilhit.setVoid(); - *florz = INT32_MAX; florhit.setVoid(); + *ceilz_ = -FLT_MAX; ceilhit.setVoid(); + *florz_ = FLT_MAX; florhit.setVoid(); return; } @@ -917,7 +920,7 @@ void getzrange_(const vec3_t& pos, sectortype* sect, int32_t* ceilz, CollisionBa closest = { int(v.X * worldtoint), int(v.Y * worldtoint) }; } - int_getzsofslopeptr(sect,closest.X,closest.Y,ceilz,florz); + getzsofslopeptr(sect, closest.X * inttoworld, closest.Y * inttoworld, ceilz_, florz_); ceilhit.setSector(sect); florhit.setSector(sect); @@ -974,7 +977,7 @@ void getzrange_(const vec3_t& pos, sectortype* sect, int32_t* ceilz, CollisionBa if (da.X >= da.Y) continue; //It actually got here, through all the continue's!!! - int32_t daz = 0, daz2 = 0; + double daz = 0, daz2 = 0; closest = pos.vec2; if (enginecompatibility_mode == ENGINECOMPATIBILITY_NONE) { @@ -983,14 +986,14 @@ void getzrange_(const vec3_t& pos, sectortype* sect, int32_t* ceilz, CollisionBa closest = { int(v.X * worldtoint), int(v.Y * worldtoint) }; } - int_getzsofslopeptr(nextsect, closest.X,closest.Y, &daz,&daz2); + getzsofslopeptr(nextsect, closest.X * inttoworld,closest.Y * inttoworld, &daz,&daz2); { - if (daz > *ceilz) - *ceilz = daz, ceilhit.setSector(nextsect); + if (daz > *ceilz_) + *ceilz_ = daz, ceilhit.setSector(nextsect); - if (daz2 < *florz) - *florz = daz2, florhit.setSector(nextsect); + if (daz2 < *florz_) + *florz_ = daz2, florhit.setSector(nextsect); } } } @@ -1072,20 +1075,19 @@ void getzrange_(const vec3_t& pos, sectortype* sect, int32_t* ceilz, CollisionBa if (clipyou != 0) { - if ((pos.Z > daz) && (daz > *ceilz)) + if ((pos.Z > daz) && (daz * zinttoworld > *ceilz_)) { - *ceilz = daz; + *ceilz_ = daz * zinttoworld; ceilhit.setSprite(actor); } - if ((pos.Z < daz2) && (daz2 < *florz)) + if ((pos.Z < daz2) && (daz2 * zinttoworld < *florz_)) { - *florz = daz2; + *florz_ = daz2 * zinttoworld; florhit.setSprite(actor); } } } } } - }