Exemplo n.º 1
0
/*
   ============
   EmitDrawingNode_r
   ============
 */
int EmitDrawNode_r( node_t *node ){
	dnode_t *n;
	face_t  *f;
	int i;

	if ( node->planenum == PLANENUM_LEAF ) {
		EmitLeaf( node );
		return -numleafs;
	}

	// emit a node
	if ( numnodes == MAX_MAP_NODES ) {
		Error( "MAX_MAP_NODES" );
	}
	n = &dnodes[numnodes];
	numnodes++;

	VectorCopy( (short) node->mins, n->mins );
	VectorCopy( (short) node->maxs, n->maxs );

	planeused[node->planenum]++;
	planeused[node->planenum ^ 1]++;

	if ( node->planenum & 1 ) {
		Error( "WriteDrawNodes_r: odd planenum" );
	}
	n->planenum = node->planenum;
	n->firstface = numfaces;

	if ( !node->faces ) {
		c_nofaces++;
	}
	else{
		c_facenodes++;
	}

	for ( f = node->faces ; f ; f = f->next )
		EmitFace( f );

	n->numfaces = numfaces - n->firstface;


	//
	// recursively output the other nodes
	//
	for ( i = 0 ; i < 2 ; i++ )
	{
		if ( node->children[i]->planenum == PLANENUM_LEAF ) {
			n->children[i] = -( numleafs + 1 );
			EmitLeaf( node->children[i] );
		}
		else
		{
			n->children[i] = numnodes;
			EmitDrawNode_r( node->children[i] );
		}
	}

	return n - dnodes;
}
Exemplo n.º 2
0
/*
============
EmitDrawingNode_r
============
*/
int EmitDrawNode_r (node_t *node)
{
    dnode_t	*n;
    face_t	*f;
    int		i;

    if (node->planenum == PLANENUM_LEAF)
    {
        EmitLeaf (node);
        return -numleafs;
    }

    // emit a node
    if (numnodes == MAX_MAP_NODES)
        Error ("MAX_MAP_NODES");
    node->diskId = numnodes;

    n = &dnodes[numnodes];
    numnodes++;

    VECTOR_COPY (node->mins, n->mins);
    VECTOR_COPY (node->maxs, n->maxs);

    if (node->planenum & 1)
        Error ("WriteDrawNodes_r: odd planenum");
    n->planenum = node->planenum;
    n->firstface = numfaces;
    n->area = node->area;

    if (!node->faces)
        c_nofaces++;
    else
        c_facenodes++;

    for (f=node->faces ; f ; f=f->next)
        EmitFace (f, true);

    n->numfaces = numfaces - n->firstface;


    //
    // recursively output the other nodes
    //
    for (i=0 ; i<2 ; i++)
    {
        if (node->children[i]->planenum == PLANENUM_LEAF)
        {
            n->children[i] = -(numleafs + 1);
            EmitLeaf (node->children[i]);
        }
        else
        {
            n->children[i] = numnodes;
            EmitDrawNode_r (node->children[i]);
        }
    }

    return n - dnodes;
}
Exemplo n.º 3
0
//-----------------------------------------------------------------------------
// Purpose: Emit all of the faces stored at the leaves (faces from detail brushes)
//-----------------------------------------------------------------------------
void EmitLeafFaces( face_t *pLeafFaceList )
{
    face_t *f = pLeafFaceList;
    while ( f )
    {
        EmitFace( f, false );
        f = f->next;
    }
}
Exemplo n.º 4
0
/**
 * @brief Writes the draw nodes
 * @note Called after a drawing hull is completed
 */
static int EmitDrawNode_r (node_t* node)
{
	const char* side[2] = {"front", "back"};
	dBspNode_t* n;
	const face_t* f;
	int i;

	if (node->planenum == PLANENUM_LEAF) {
		Verb_Printf(VERB_DUMP, "EmitDrawNode_r: creating singleton leaf.\n");
		EmitLeaf(node);
		return -curTile->numleafs;
	}

	/* emit a node	 */
	if (curTile->numnodes >= MAX_MAP_NODES)
		Sys_Error("MAX_MAP_NODES (%i)", curTile->numnodes);
	n = &curTile->nodes[curTile->numnodes];
	Verb_Printf(VERB_DUMP, "EmitDrawNode_r: creating bsp node %i\n", curTile->numnodes);
	curTile->numnodes++;

	VectorCopy(node->mins, n->mins);
	VectorCopy(node->maxs, n->maxs);

	if (node->planenum & 1)
		Sys_Error("EmitDrawNode_r: odd planenum: %i", node->planenum);
	n->planenum = node->planenum;
	n->firstface = curTile->numfaces;

	if (!node->faces)
		c_nofaces++;
	else
		c_facenodes++;

	for (f = node->faces; f; f = f->next)
		EmitFace(f);

	n->numfaces = curTile->numfaces - n->firstface;

	/* recursively output the other nodes */
	for (i = 0; i < 2; i++) {
		if (node->children[i]->planenum == PLANENUM_LEAF) {
			Verb_Printf(VERB_DUMP, "EmitDrawNode_r: creating child leaf for %s of bsp node " UFO_SIZE_T ".\n", side[i], n - curTile->nodes);
			n->children[i] = -(curTile->numleafs + 1);
			EmitLeaf(node->children[i]);
		} else {
			Verb_Printf(VERB_DUMP, "EmitDrawNode_r: adding child node for bsp node " UFO_SIZE_T ".\n", n - curTile->nodes);
			n->children[i] = curTile->numnodes;
			EmitDrawNode_r(node->children[i]);
		}
	}

	return n - curTile->nodes;
}
Exemplo n.º 5
0
		void GLVoxelModel::BuildVertices(spades::VoxelModel *model) {
			SPADES_MARK_FUNCTION();

			SPAssert(vertices.empty());
			SPAssert(indices.empty());

			int w = model->GetWidth();
			int h = model->GetHeight();
			int d = model->GetDepth();
			for (int x = 0; x < w; x++) {
				for (int y = 0; y < h; y++) {
					for (int z = 0; z < d; z++) {
						if (!model->IsSolid(x, y, z))
							continue;

						uint32_t color = model->GetColor(x, y, z);
						color |= 0xff000000UL;

						if (!model->IsSolid(x - 1, y, z))
							EmitFace(model, x, y, z, -1, 0, 0, color);
						if (!model->IsSolid(x + 1, y, z))
							EmitFace(model, x, y, z, 1, 0, 0, color);
						if (!model->IsSolid(x, y - 1, z))
							EmitFace(model, x, y, z, 0, -1, 0, color);
						if (!model->IsSolid(x, y + 1, z))
							EmitFace(model, x, y, z, 0, 1, 0, color);
						if (!model->IsSolid(x, y, z - 1))
							EmitFace(model, x, y, z, 0, 0, -1, color);
						if (!model->IsSolid(x, y, z + 1))
							EmitFace(model, x, y, z, 0, 0, 1, color);
					}
				}
			}
		}
Exemplo n.º 6
0
/*
 * @brief
 */
static int32_t EmitDrawNode_r(node_t * node) {
	d_bsp_node_t *n;
	face_t *f;
	int32_t i;

	if (node->plane_num == PLANENUM_LEAF) {
		EmitLeaf(node);
		return -d_bsp.num_leafs;
	}
	// emit a node
	if (d_bsp.num_nodes == MAX_BSP_NODES)
		Com_Error(ERR_FATAL, "MAX_BSP_NODES\n");

	n = &d_bsp.nodes[d_bsp.num_nodes];
	d_bsp.num_nodes++;

	VectorCopy(node->mins, n->mins);
	VectorCopy(node->maxs, n->maxs);

	if (node->plane_num & 1)
		Com_Error(ERR_FATAL, "Odd plane number\n");

	n->plane_num = node->plane_num;
	n->first_face = d_bsp.num_faces;

	if (!node->faces)
		c_nofaces++;
	else
		c_facenodes++;

	for (f = node->faces; f; f = f->next)
		EmitFace(f);

	n->num_faces = d_bsp.num_faces - n->first_face;

	// recursively output the other nodes
	for (i = 0; i < 2; i++) {
		if (node->children[i]->plane_num == PLANENUM_LEAF) {
			n->children[i] = -(d_bsp.num_leafs + 1);
			EmitLeaf(node->children[i]);
		} else {
			n->children[i] = d_bsp.num_nodes;
			EmitDrawNode_r(node->children[i]);
		}
	}

	return n - d_bsp.nodes;
}
Exemplo n.º 7
0
/*
============
WriteBSP
============
*/
void WriteBSP (node_t *headnode, face_t *pLeafFaceList )
{
    int		i;
    int		oldfaces;
    int     oldorigfaces;

    c_nofaces = 0;
    c_facenodes = 0;

    qprintf ("--- WriteBSP ---\n");

    oldfaces = numfaces;
    oldorigfaces = numorigfaces;

    GetEdge2_InitOptimizedList();
    EmitLeafFaces( pLeafFaceList );
    dmodels[nummodels].headnode = EmitDrawNode_r (headnode);

    // Only emit area portals for the main world.
    if( nummodels == 0 )
    {
        EmitAreaPortals (headnode);
    }

    //
    // add all displacement faces for the particular model
    //
    for( i = 0; i < nummapdispinfo; i++ )
    {
        int entityIndex = GetDispInfoEntityNum( &mapdispinfo[i] );
        if( entityIndex == entity_num )
        {
            EmitFaceVertexes( NULL, &mapdispinfo[i].face );
            EmitFace( &mapdispinfo[i].face, FALSE );
        }
    }

    EmitWaterVolumesForBSP( &dmodels[nummodels], headnode );
    qprintf ("%5i nodes with faces\n", c_facenodes);
    qprintf ("%5i nodes without faces\n", c_nofaces);
    qprintf ("%5i faces\n", numfaces-oldfaces);
    qprintf( "%5i original faces\n", numorigfaces-oldorigfaces );
}