From a89c260592001360a44a45aa07844ae738a40caf Mon Sep 17 00:00:00 2001 From: terminx Date: Thu, 18 Apr 2019 17:25:07 +0000 Subject: [PATCH] Add optional output parameter to getwalldist(), to return the coordinates of the closest point on the wall git-svn-id: https://svn.eduke32.com/eduke32@7600 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/include/build.h | 2 +- source/build/src/engine.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index 66be2f341..ed4297483 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -1169,7 +1169,7 @@ int32_t try_facespr_intersect(uspritetype const * const spr, const vec3_t *refpo vec3_t *intp, int32_t strictly_smaller_than_p); bool sectoradjacent(int sect1, int sect2); -int32_t getwalldist(vec2_t const &p, int const wallnum); +int32_t getwalldist(vec2_t const &p, int const wallnum, vec2_t * const output = nullptr); int32_t getsectordist(vec2_t const &p, int const sectnum); extern const int16_t *chsecptr_onextwall; int32_t checksectorpointer(int16_t i, int16_t sectnum); diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 25e7e955a..8a9b1e109 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -10971,10 +10971,11 @@ static inline bool inside_z_p(int32_t const x, int32_t const y, int32_t const z, return (z >= cz && z <= fz && inside_p(x, y, sectnum)); } -int32_t getwalldist(vec2_t const &p, int const wallnum) +int32_t getwalldist(vec2_t const &p, int const wallnum, vec2_t * const output) { vec2_t closest; getclosestpointonwall_internal(p, wallnum, &closest); + if (output) *output = closest; return klabs(closest.x - p.x) + klabs(closest.y - p.y); }