From 7ce4402dfc3bd93a4bbedf82ba0a28f8e76ebb1d Mon Sep 17 00:00:00 2001 From: Tyrann Date: Sun, 23 Sep 2007 20:46:28 +0930 Subject: [PATCH] [PATCH] qbsp: Use fast sphere test in FaceSide Signed-off-by: Tyrann --- qbsp/solidbsp.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/qbsp/solidbsp.c b/qbsp/solidbsp.c index 858d7d61..13451a5a 100644 --- a/qbsp/solidbsp.c +++ b/qbsp/solidbsp.c @@ -41,7 +41,7 @@ For BSP hueristic ================== */ static int -FaceSide(face_t *in, plane_t *split) +FaceSide__(face_t *in, plane_t *split) { bool frontcount, backcount; vec_t dot; @@ -87,6 +87,23 @@ FaceSide(face_t *in, plane_t *split) return SIDE_ON; } +static int +FaceSide(face_t *in, plane_t *split) +{ + vec_t dist; + int ret; + + dist = DotProduct(in->origin, split->normal) - split->dist; + if (dist > in->radius) + ret = SIDE_FRONT; + else if (dist < -in->radius) + ret = SIDE_BACK; + else + ret = FaceSide__(in, split); + + return ret; +} + /* * Split a bounding box by a plane; The front and back bounds returned * are such that they completely contain the portion of the input box