Releases memory for a bspnode. This function calls itself recursively
| 740 | |
| 741 | // Releases memory for a bspnode. This function calls itself recursively |
| 742 | void DestroyBSPNode(bspnode *node) { |
| 743 | if (node->type == BSP_NODE) { |
| 744 | if (node->front) |
| 745 | DestroyBSPNode(node->front); |
| 746 | if (node->back) |
| 747 | DestroyBSPNode(node->back); |
| 748 | } |
| 749 | |
| 750 | int np = CountListItems(&node->polylist); |
| 751 | |
| 752 | for (int i = 0; i < np; i++) { |
| 753 | bsppolygon *poly = (bsppolygon *)GetListItem(&node->polylist, i); |
| 754 | FreePolygon(poly); |
| 755 | } |
| 756 | if (np > 0) |
| 757 | DestroyList(&node->polylist); |
| 758 | |
| 759 | mem_free(node); |
| 760 | } |
| 761 | |
| 762 | // Walks the BSP tree and frees up any nodes/polygons that we might be using |
| 763 | void DestroyBSPTree(bsptree *tree) { |
no test coverage detected