shithub: nanobsp

Download patch

ref: 13a3ee197cee081a5ef480c9443f88dbf203ab35
parent: 8af421c562e52ddef0a57cf2c02a739c43934e54
author: Andrew Apted <ajapted@gmail.com>
date: Fri Dec 15 08:23:19 EST 2023

restored the original `subsector_t` and `node_t` structs.

The seg_t struct keeps my added `side` and `next` fields, which are
necessary for the BSP building algorithm.

--- a/r_defs.h
+++ b/r_defs.h
@@ -210,6 +210,23 @@
 
 
 //
+// A SubSector.
+// References a Sector.
+// Basically, this is a list of LineSegs,
+//  indicating the visible walls that define
+//  (all or some) sides of a convex BSP leaf.
+//
+typedef struct subsector_s
+{
+    sector_t*	sector;
+    short	numlines;
+    short	firstline;
+    
+} subsector_t;
+
+
+
+//
 // The LineSeg.
 //
 typedef struct seg_s
@@ -217,9 +234,9 @@
     vertex_t*	v1;
     vertex_t*	v2;
 
-    int      side;
-    fixed_t  offset;
-    angle_t  angle;
+    fixed_t	offset;
+    angle_t	angle;
+    int	side;
 
     side_t*	sidedef;
     line_t*	linedef;
@@ -237,38 +254,24 @@
 
 
 //
-// A SubSector.
-// References a Sector.
-// Basically, this is a list of LineSegs,
-//  indicating the visible walls that define
-//  (all or some) sides of a convex BSP leaf.
-//
-typedef struct subsector_s
-{
-    sector_t * sector;
-    seg_t    * segs;
-} subsector_t;
-
-
-
-//
 // BSP node.
 //
-typedef struct node_s
+typedef struct
 {
-    // when non-NULL, this is actually a leaf of the BSP tree
-    subsector_t * sub;
+    // Partition line.
+    fixed_t	x;
+    fixed_t	y;
+    fixed_t	dx;
+    fixed_t	dy;
 
-    // partition line (start coord, delta to end)
-    fixed_t  x, y, dx, dy;
+    // Bounding box for each child.
+    fixed_t	bbox[2][4];
 
-    // bounding box for this node / leaf
-    fixed_t  bbox[4];
-
-    // right and left children
-    struct node_s * right;
-    struct node_s * left;
+    // If NF_SUBSECTOR its a subsector.
+    unsigned short children[2];
+    
 } node_t;
+
 
 
 
--