Loads a bsp node from an open file and recurses with its children
| 212 | |
| 213 | // Loads a bsp node from an open file and recurses with its children |
| 214 | void LoadBSPNode(CFILE *infile, bspnode **node) { |
| 215 | // Get the node type |
| 216 | uint8_t type = cf_ReadByte(infile); |
| 217 | |
| 218 | // Allocate the node and set its type |
| 219 | *node = NewBSPNode(); |
| 220 | ASSERT(*node); |
| 221 | bspnode *localnode = *node; |
| 222 | |
| 223 | localnode->type = type; |
| 224 | |
| 225 | if (type == BSP_EMPTY_LEAF || type == BSP_SOLID_LEAF) |
| 226 | return; |
| 227 | |
| 228 | // Load the nodes plane |
| 229 | localnode->plane.a = cf_ReadFloat(infile); |
| 230 | localnode->plane.b = cf_ReadFloat(infile); |
| 231 | localnode->plane.c = cf_ReadFloat(infile); |
| 232 | localnode->plane.d = cf_ReadFloat(infile); |
| 233 | localnode->node_roomnum = cf_ReadShort(infile); |
| 234 | localnode->node_facenum = cf_ReadShort(infile); |
| 235 | localnode->node_subnum = cf_ReadByte(infile); |
| 236 | |
| 237 | // Recurse to get the children |
| 238 | LoadBSPNode(infile, &localnode->front); |
| 239 | LoadBSPNode(infile, &localnode->back); |
| 240 | } |
| 241 | |
| 242 | // Frees up a polygon and all the vertices associated with it |
| 243 | void FreePolygon(bsppolygon *poly) { |
no test coverage detected