示例#1
0
void EmitMarkFace (dleaf_t *leaf_p, face_t *f)
{
    int			i;
    int			facenum;

    while (f->merged)
        f = f->merged;

    if (f->split[0])
    {
        EmitMarkFace (leaf_p, f->split[0]);
        EmitMarkFace (leaf_p, f->split[1]);
        return;
    }

    facenum = f->outputnumber;
    if (facenum == -1)
        return;	// degenerate face

    if (facenum < 0 || facenum >= numfaces)
        Error ("Bad leafface");
    for (i=leaf_p->firstleafface ; i<numleaffaces ; i++)
        if (dleaffaces[i] == facenum)
            break;		// merged out face
    if (i == numleaffaces)
    {
        if (numleaffaces >= MAX_MAP_LEAFFACES)
            Error ("Too many detail brush faces, max = %d\n", MAX_MAP_LEAFFACES);

        dleaffaces[numleaffaces] =  facenum;
        numleaffaces++;
    }

}
示例#2
0
void EmitMarkFace( dleaf_t *leaf_p, face_t *f ){
	int i;
	int facenum;

	while ( f->merged )
		f = f->merged;

	if ( f->split[0] ) {
		EmitMarkFace( leaf_p, f->split[0] );
		EmitMarkFace( leaf_p, f->split[1] );
		return;
	}

	facenum = f->outputnumber;
	if ( facenum == -1 ) {
		return; // degenerate face

	}
	if ( facenum < 0 || facenum >= numfaces ) {
		Error( "Bad leafface" );
	}
	for ( i = leaf_p->firstleafface ; i < numleaffaces ; i++ )
		if ( dleaffaces[i] == facenum ) {
			break;
		}               // merged out face
	if ( i == numleaffaces ) {
		if ( numleaffaces >= MAX_MAP_LEAFFACES ) {
			Error( "MAX_MAP_LEAFFACES" );
		}

		dleaffaces[numleaffaces] =  facenum;
		numleaffaces++;
	}

}
示例#3
0
/*
==================
EmitLeaf
==================
*/
void EmitLeaf (node_t *node)
{
    dleaf_t		*leaf_p;
    portal_t	*p;
    int			s;
    face_t		*f;
    bspbrush_t	*b;
    int			i;
    int			brushnum;
    leafface_t	*pList;

    // emit a leaf
    if (numleafs >= MAX_MAP_LEAFS)
        Error ("Too many BSP leaves, max = %d", MAX_MAP_LEAFS);

    node->diskId = numleafs;
    leaf_p = &dleafs[numleafs];
    numleafs++;

    if( nummodels == 0 )
    {
        leaf_p->cluster = node->cluster;
    }
    else
    {
        // Submodels don't have clusters. If this isn't set to -1 here, then there
        // will be multiple leaves (albeit from different models) that reference
        // the same cluster and parts of the code like ivp.cpp's ConvertWaterModelToPhysCollide
        // won't work.
        leaf_p->cluster = -1;
    }

    leaf_p->contents = node->contents;
    leaf_p->area = node->area;

    // By default, assume the leaf can see the skybox.
    // VRAD will do the actual computation to see if it really can see the skybox
    leaf_p->flags = LEAF_FLAGS_SKY;

    //
    // write bounding box info
    //
    VECTOR_COPY (node->mins, leaf_p->mins);
    VECTOR_COPY (node->maxs, leaf_p->maxs);

    //
    // write the leafbrushes
    //
    leaf_p->firstleafbrush = numleafbrushes;
    for (b=node->brushlist ; b ; b=b->next)
    {
        if (numleafbrushes >= MAX_MAP_LEAFBRUSHES)
            Error ("Too many brushes in one leaf, max = %d", MAX_MAP_LEAFBRUSHES);

        brushnum = b->original - g_MainMap->mapbrushes;
        for (i=leaf_p->firstleafbrush ; i<numleafbrushes ; i++)
        {
            if (dleafbrushes[i] == brushnum)
                break;
        }

        if (i == numleafbrushes)
        {
            dleafbrushes[numleafbrushes] = brushnum;
            numleafbrushes++;
        }
    }
    leaf_p->numleafbrushes = numleafbrushes - leaf_p->firstleafbrush;

    //
    // write the leaffaces
    //
    if (leaf_p->contents & CONTENTS_SOLID)
        return;		// no leaffaces in solids

    leaf_p->firstleafface = numleaffaces;

    for (p = node->portals ; p ; p = p->next[s])
    {
        s = (p->nodes[1] == node);
        f = p->face[s];
        if (!f)
            continue;	// not a visible portal

        EmitMarkFace (leaf_p, f);
    }

    // emit the detail faces
    for ( pList = node->leaffacelist; pList; pList = pList->pNext )
    {
        EmitMarkFace( leaf_p, pList->pFace );
    }


    leaf_p->numleaffaces = numleaffaces - leaf_p->firstleafface;
}
示例#4
0
/*
==================
EmitLeaf
==================
*/
void EmitLeaf (node_t *node)
{
	dleaf_t		*leaf_p;
	portal_t	*p;
	int			s;
	face_t		*f;
	bspbrush_t	*b;
	int			i;
	int			brushnum;

	// emit a leaf
	if (numleafs >= MAX_MAP_LEAFS)
		Error ("MAX_MAP_LEAFS");

	leaf_p = &dleafs[numleafs];
	numleafs++;

	leaf_p->contents = node->contents;
	leaf_p->cluster = node->cluster;
	leaf_p->area = node->area;

	//
	// write bounding box info
	//	
	VectorCopy (node->mins, leaf_p->mins);
	VectorCopy (node->maxs, leaf_p->maxs);
	
	//
	// write the leafbrushes
	//
	leaf_p->firstleafbrush = numleafbrushes;
	for (b=node->brushlist ; b ; b=b->next)
	{
		if (numleafbrushes >= MAX_MAP_LEAFBRUSHES)
			Error ("MAX_MAP_LEAFBRUSHES");

		brushnum = b->original - mapbrushes;
		for (i=leaf_p->firstleafbrush ; i<numleafbrushes ; i++)
			if (dleafbrushes[i] == brushnum)
				break;
		if (i == numleafbrushes)
		{
			dleafbrushes[numleafbrushes] = brushnum;
			numleafbrushes++;
		}
	}
	leaf_p->numleafbrushes = numleafbrushes - leaf_p->firstleafbrush;

	//
	// write the leaffaces
	//
	if (leaf_p->contents & CONTENTS_SOLID)
		return;		// no leaffaces in solids

	leaf_p->firstleafface = numleaffaces;

	for (p = node->portals ; p ; p = p->next[s])	
	{
		s = (p->nodes[1] == node);
		f = p->face[s];
		if (!f)
			continue;	// not a visible portal

		EmitMarkFace (leaf_p, f);
	}
	
	leaf_p->numleaffaces = numleaffaces - leaf_p->firstleafface;
}