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
This commit is contained in:
terminx 2019-04-18 17:25:07 +00:00 committed by Christoph Oelckers
parent 0dcceb9147
commit a89c260592
2 changed files with 3 additions and 2 deletions

View file

@ -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); vec3_t *intp, int32_t strictly_smaller_than_p);
bool sectoradjacent(int sect1, int sect2); 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); int32_t getsectordist(vec2_t const &p, int const sectnum);
extern const int16_t *chsecptr_onextwall; extern const int16_t *chsecptr_onextwall;
int32_t checksectorpointer(int16_t i, int16_t sectnum); int32_t checksectorpointer(int16_t i, int16_t sectnum);

View file

@ -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)); 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; vec2_t closest;
getclosestpointonwall_internal(p, wallnum, &closest); getclosestpointonwall_internal(p, wallnum, &closest);
if (output) *output = closest;
return klabs(closest.x - p.x) + klabs(closest.y - p.y); return klabs(closest.x - p.x) + klabs(closest.y - p.y);
} }