Example #1
0
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_StoreTree_r( tmp_node_t *tmpnode ) {
	int aasnodenum;
	plane_t *plane;
	aas_node_t *aasnode;

	//if it is a solid leaf
	if ( !tmpnode ) {
		return 0;
	}
	//negative so it's an area
	if ( tmpnode->tmparea ) {
		return AAS_StoreArea( tmpnode->tmparea );
	}
	//it's another node
	//the first node is a dummy
	if ( ( *aasworld ).numnodes == 0 ) {
		( *aasworld ).numnodes = 1;
	}
	if ( ( *aasworld ).numnodes >= max_aas.max_nodes ) {
		Error( "AAS_MAX_NODES = %d", max_aas.max_nodes );
	} //end if
	aasnodenum = ( *aasworld ).numnodes;
	aasnode = &( *aasworld ).nodes[( *aasworld ).numnodes++];
	plane = &mapplanes[tmpnode->planenum];
	AAS_GetPlane( plane->normal, plane->dist, &aasnode->planenum );
	aasnode->children[0] = AAS_StoreTree_r( tmpnode->children[0] );
	aasnode->children[1] = AAS_StoreTree_r( tmpnode->children[1] );
	return aasnodenum;
} //end of the function AAS_StoreTree_r
Example #2
0
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
qboolean AAS_GetFace(winding_t *w, plane_t *p, int side, int *facenum)
{
    int        edgenum, i, j;
    aas_face_t *face;

    //face zero is a dummy, because of the face index with negative numbers
    if ((*aasworld).numfaces == 0)
    {
        (*aasworld).numfaces = 1;
    }

    if ((*aasworld).numfaces >= max_aas.max_faces)
    {
        Error("AAS_MAX_FACES = %d", max_aas.max_faces);
    } //end if
    face = &(*aasworld).faces[(*aasworld).numfaces];
    AAS_GetPlane(p->normal, p->dist, &face->planenum);
    face->faceflags = 0;
    face->firstedge = (*aasworld).edgeindexsize;
    face->frontarea = 0;
    face->backarea  = 0;
    face->numedges  = 0;
    for (i = 0; i < w->numpoints; i++)
    {
        if ((*aasworld).edgeindexsize >= max_aas.max_edgeindexsize)
        {
            Error("AAS_MAX_EDGEINDEXSIZE = %d", max_aas.max_edgeindexsize);
        } //end if
        j = (i + 1) % w->numpoints;
        AAS_GetEdge(w->p[i], w->p[j], &edgenum);
        //if the edge wasn't degenerate
        if (edgenum)
        {
            (*aasworld).edgeindex[(*aasworld).edgeindexsize++] = edgenum;
            face->numedges++;
        } //end if
        else if (verbose)
        {
            Log_Write("AAS_GetFace: face %d had degenerate edge %d-%d\r\n",
                      (*aasworld).numfaces, i, j);
        } //end else
    } //end for
    if (face->numedges < 1
#ifdef NOTHREEVERTEXFACES
            || face->numedges < 3
#endif //NOTHREEVERTEXFACES
       )
    {
        memset(&(*aasworld).faces[(*aasworld).numfaces], 0, sizeof(aas_face_t));
        Log_Write("AAS_GetFace: face %d was tiny\r\n", (*aasworld).numfaces);
        return false;
    } //end if
    *facenum = (*aasworld).numfaces;
    (*aasworld).numfaces++;
    return true;
} //end of the function AAS_GetFace