mathlib: refactor ProjectPointOntoPlane

This commit is contained in:
Eric Wasylishen 2017-06-20 16:01:34 -06:00
parent af264821b7
commit 98c5dd2913
1 changed files with 5 additions and 5 deletions

View File

@ -214,17 +214,17 @@ GetDir(const vec3_t start, const vec3_t stop, vec3_t dir)
}
static inline vec_t
DistanceAbovePlane(const plane_t *plane, const vec3_t point)
DistanceAbovePlane(const vec3_t normal, const vec_t dist, const vec3_t point)
{
return DotProduct(plane->normal, point) - plane->dist;
return DotProduct(normal, point) - dist;
}
static inline void
ProjectPointOntoPlane(const plane_t *plane, vec3_t point)
ProjectPointOntoPlane(const vec3_t normal, const vec_t dist, vec3_t point)
{
vec_t dist = DistanceAbovePlane(plane, point);
vec_t distAbove = DistanceAbovePlane(normal, dist, point);
vec3_t move;
VectorScale(plane->normal, -dist, move);
VectorScale(normal, -distAbove, move);
VectorAdd(point, move, point);
}