From 4ba0e99d3fee274860cbcaf643c6b9dbdea8fc30 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Fri, 21 May 2021 22:35:41 -0600 Subject: [PATCH] Light_PointInSolid: add check against model bounds --- common/bsputils.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/bsputils.cc b/common/bsputils.cc index 77afb42a..e9e50b45 100644 --- a/common/bsputils.cc +++ b/common/bsputils.cc @@ -294,6 +294,14 @@ static bool Light_PointInSolid_r(const mbsp_t *bsp, const int nodenum, const vec // Tests hull 0 of the given model bool Light_PointInSolid(const mbsp_t *bsp, const dmodel_t *model, const vec3_t point) { + // fast bounds check + for (int i = 0; i < 3; ++i) { + if (point[i] < model->mins[i]) + return false; + if (point[i] > model->maxs[i]) + return false; + } + return Light_PointInSolid_r(bsp, model->headnode[0], point); }