ref: 81c7d03b48a5a15c16a93e4c39bf2508e91fcdff
parent: 582637378657b7ed70f39b3fcf0c615a9d9c2a30
author: Andrew Apted <ajapted@gmail.com>
date: Fri Dec 15 13:43:56 EST 2023
added SPLIT_COST constant, document it and FAST_THRESHOLD.
--- a/nano_bsp.c
+++ b/nano_bsp.c
@@ -46,9 +46,17 @@
#define DIST_EPSILON (FRACUNIT / 64)
+// this value is a trade-off. lower values will build nodes faster,
+// but higher values allow picking better BSP partitions (and hence
+// produce better BSP trees).
#define FAST_THRESHOLD 128
+// reducing splits is important to get good BSP trees. making this
+// value really low produces trees which have a *lot* more nodes
+// (I am not sure exactly why). higher values are okay.
+#define SPLIT_COST 11
+
#undef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
@@ -193,7 +201,6 @@
if (ld->sidenum[side] < 0)
return;
- // create the seg
seg_t * seg = BSP_NewSeg ();
seg->v1 = side ? ld->v2 : ld->v1;
@@ -438,8 +445,8 @@
if (vert_ok && horiz_ok)
{- int vert_cost = abs (v_eval.left - v_eval.right) * 2 + v_eval.split * 11;
- int horiz_cost = abs (h_eval.left - h_eval.right) * 2 + h_eval.split * 11;
+ int vert_cost = abs (v_eval.left - v_eval.right) * 2 + v_eval.split * SPLIT_COST;
+ int horiz_cost = abs (h_eval.left - h_eval.right) * 2 + h_eval.split * SPLIT_COST;
return (horiz_cost < vert_cost) ? horiz_part : vert_part;
}
@@ -467,7 +474,7 @@
if (BSP_EvalPartition (part, soup, &eval))
{- int cost = abs (eval.left - eval.right) * 2 + eval.split * 11;
+ int cost = abs (eval.left - eval.right) * 2 + eval.split * SPLIT_COST;
if (cost < best_cost)
{--
⑨