shithub: nanobsp

Download patch

ref: 47c5c8b5dfd6b287fe1e670aeaada92bcd8bf643
parent: 210c1a12d99069e6b8a3442c42b1d08d13742339
author: Andrew Apted <ajapted@gmail.com>
date: Sat Dec 9 07:50:37 EST 2023

fixed a bug in BSP_PickNode_Fast().

--- a/nano_bsp.c
+++ b/nano_bsp.c
@@ -308,6 +308,7 @@
 	seg_t * horiz_part = NULL;
 	fixed_t horiz_dist = (1 << 30);
 
+	// find the segs closest to middle of bbox
 	seg_t * part;
 	for (part = soup ; part != NULL ; part = part->next)
 	{
@@ -333,11 +334,12 @@
 		}
 	}
 
+	// check that each partition is viable
 	struct NodeEval v_eval;
 	struct NodeEval h_eval;
 
-	boolean vert_ok  = BSP_EvalPartition (vert_part,  soup, &v_eval);
-	boolean horiz_ok = BSP_EvalPartition (horiz_part, soup, &h_eval);
+	boolean vert_ok  = (vert_part  != NULL) && BSP_EvalPartition (vert_part,  soup, &v_eval);
+	boolean horiz_ok = (horiz_part != NULL) && BSP_EvalPartition (horiz_part, soup, &h_eval);
 
 	if (vert_ok && horiz_ok)
 	{
--