Example #1
0
static void
GatherNodeFaces_r(node_t *node, face_t **planefaces)
{
    face_t *f, *next;

    if (node->planenum != PLANENUM_LEAF) {
        // decision node
        for (f = node->faces; f; f = next) {
            next = f->next;
            if (!f->w.numpoints) {      // face was removed outside
                FreeMem(f, FACE, 1);
            } else {
                f->next = planefaces[f->planenum];
                planefaces[f->planenum] = f;
            }
        }
        GatherNodeFaces_r(node->children[0], planefaces);
        GatherNodeFaces_r(node->children[1], planefaces);
    }
    FreeMem(node, NODE, 1);
}
Example #2
0
/*
================
GatherNodeFaces
================
*/
surface_t *
GatherNodeFaces(node_t *headnode)
{
    face_t **planefaces;
    surface_t *surfaces;

    planefaces = AllocMem(OTHER, sizeof(face_t *) * map.maxplanes, true);
    GatherNodeFaces_r(headnode, planefaces);
    surfaces = BuildSurfaces(planefaces);
    FreeMem(planefaces, OTHER, sizeof(face_t *) * map.maxplanes);

    return surfaces;
}
/*
=============================================================================

GatherNodeFaces

Frees the current node tree and returns a new chain of the surfaces that
have inside faces.
=============================================================================
*/
static void GatherNodeFaces_r (node_t *node)
{
	face_t	*f, *next;

	if (node->planenum != PLANENUM_LEAF)
	{
//
// decision node
//
		for (f = node->faces ; f ; f = next)
		{
			next = f->next;
			if (!f->numpoints)
			{	// face was removed outside
				FreeFace (f);
			}
			else
			{
				f->next = validfaces[f->planenum];
				validfaces[f->planenum] = f;
			}
		}

		GatherNodeFaces_r (node->children[0]);
		GatherNodeFaces_r (node->children[1]);

		free (node);
	}
	else
	{
//
// leaf node
//
		free (node);
	}
}
/*
================
GatherNodeFaces

================
*/
surface_t *GatherNodeFaces (node_t *headnode)
{
	memset (validfaces, 0, sizeof(validfaces));
	GatherNodeFaces_r (headnode);
	return BuildSurfaces ();
}