Exemplo n.º 1
0
/*
==================
MakeTreePortals_r
==================
*/
void MakeTreePortals_r (node_t *node)
{
    int		i;

    CalcNodeBounds (node);
    if (node->mins[0] >= node->maxs[0])
    {
        Sys_Printf ("WARNING: node without a volume\n");
        Sys_Printf("node has %d tiny portals\n", node->tinyportals);
        Sys_Printf("node reference point %1.2f %1.2f %1.2f\n", node->referencepoint[0],
                   node->referencepoint[1],
                   node->referencepoint[2]);
    }

    for (i=0 ; i<3 ; i++)
    {
        if (node->mins[i] < MIN_WORLD_COORD || node->maxs[i] > MAX_WORLD_COORD)
        {
            if(node->portals && node->portals->winding)
                xml_Winding("WARNING: Node With Unbounded Volume", node->portals->winding->p, node->portals->winding->numpoints, qfalse);

            break;
        }
    }
    if (node->planenum == PLANENUM_LEAF)
        return;

    MakeNodePortal (node);
    SplitNodePortals (node);

    MakeTreePortals_r (node->children[0]);
    MakeTreePortals_r (node->children[1]);
}
Exemplo n.º 2
0
/*
==================
MakeTreePortals_r
==================
*/
void MakeTreePortals_r( node_t *node )
{
	int		i;
	
	CalcNodeBounds( node );
	
	if( node->bounds[0][0] >= node->bounds[1][0] )
	{
		common->DWarning( "node without a volume" );
	}
	
	for( i = 0; i < 3; i++ )
	{
		if( node->bounds[0][i] < MIN_WORLD_COORD || node->bounds[1][i] > MAX_WORLD_COORD )
		{
			common->DWarning( "node with unbounded volume" );
			break;
		}
	}
	
	if( node->planenum == PLANENUM_LEAF )
	{
		return;
	}
	
	MakeNodePortal( node );
	SplitNodePortals( node );
	
	MakeTreePortals_r( node->children[0] );
	MakeTreePortals_r( node->children[1] );
}
Exemplo n.º 3
0
void MakeTreePortals_r( node_t *node ) {
	int i;

#ifdef ME
	qprintf( "\r%6d", ++c_numportalizednodes );
	if ( cancelconversion ) {
		return;
	}
#endif //ME

	CalcNodeBounds( node );
	if ( node->mins[0] >= node->maxs[0] ) {
		Log_Print( "WARNING: node without a volume\n" );
	}

	for ( i = 0 ; i < 3 ; i++ )
	{
		if ( node->mins[i] < -MAX_MAP_BOUNDS || node->maxs[i] > MAX_MAP_BOUNDS ) {
			Log_Print( "WARNING: node with unbounded volume\n" );
			break;
		}
	}
	if ( node->planenum == PLANENUM_LEAF ) {
		return;
	}

	MakeNodePortal( node );
	SplitNodePortals( node );

	MakeTreePortals_r( node->children[0] );
	MakeTreePortals_r( node->children[1] );
} //end of the function MakeTreePortals_r
Exemplo n.º 4
0
/*
==================
MakeTreePortals_r
==================
*/
void MakeTreePortals_r (node_t *node)
{
	int		i;

	CalcNodeBounds (node);
	if (node->mins[0] >= node->maxs[0])
	{
		printf ("WARNING: node without a volume\n");
	}

	for (i=0 ; i<3 ; i++)
	{
		if (node->mins[i] < -8000 || node->maxs[i] > 8000)
		{
			printf ("WARNING: node with unbounded volume\n");
			break;
		}
	}
	if (node->planenum == PLANENUM_LEAF)
		return;

	MakeNodePortal (node);
	SplitNodePortals (node);

	MakeTreePortals_r (node->children[0]);
	MakeTreePortals_r (node->children[1]);
}
Exemplo n.º 5
0
/*
==================
BuildBspTree_r
==================
*/
void BuildBspTree_r (node_t *node)
{
	surface_t		*split;
	qboolean		midsplit;
	surface_t		*allsurfs;

	midsplit = CalcNodeBounds (node);

	DrawSurfaces (node->surfaces);

	split = SelectPartition (node->surfaces, node, midsplit);
	if (!split)
	{	// this is a leaf node
		node->planenum = PLANENUM_LEAF;
		LinkLeafFaces (node->surfaces, node);
		return;
	}

	//
	// these are final polygons
	//
	split->onnode = node;	// can't use again
	allsurfs = node->surfaces;
	node->planenum = split->planenum;
	node->faces = NULL;
	CopyFacesToNode (node, split);
	c_splitnodes++;

	node->children[0] = AllocNode ();
	node->children[1] = AllocNode ();

	//
	// split all the polysurfaces into front and back lists
	//
	SplitNodeSurfaces (allsurfs, node);

	//
	// create the portal that seperates the two children
	//
	MakeNodePortal (node);
	
	//
	// carve the portals on the boundaries of the node
	//
	SplitNodePortals (node);

	//
	// recursively do the children
	//
	BuildBspTree_r (node->children[0]);
	BuildBspTree_r (node->children[1]);
}
Exemplo n.º 6
0
/*
==================
MakeTreePortals_r
==================
*/
void MakeTreePortals_r (node_t *node)
{
	int		i;

	CalcNodeBounds (node);
	if (node->mins[0] >= node->maxs[0])
	{
		Warning("WARNING: node without a volume\n");
	}

	for (i=0 ; i<3 ; i++)
	{
		if (node->mins[i] < (MIN_COORD_INTEGER-SIDESPACE) || node->maxs[i] > (MAX_COORD_INTEGER+SIDESPACE))
		{
			const char *pMatName = "<NO BRUSH>";
			// split by brush side
			if ( node->side )
			{
				texinfo_t *pTexInfo = &texinfo[node->side->texinfo];
				dtexdata_t *pTexData = GetTexData( pTexInfo->texdata );
				pMatName = TexDataStringTable_GetString( pTexData->nameStringTableID );
			}
			Vector point = node->portals->winding->p[0];
			Warning("WARNING: BSP node with unbounded volume (material: %s, near %s)\n", pMatName, VecToString(point) );
			break;
		}
	}
	if (node->planenum == PLANENUM_LEAF)
		return;

	MakeNodePortal (node);
	SplitNodePortals (node);

	MakeTreePortals_r (node->children[0]);
	MakeTreePortals_r (node->children[1]);
}
Exemplo n.º 7
0
static void MakeTreePortals_r (node_t *node)
{
	int i;

	CalcNodeBounds(node);
	if (node->mins[0] >= node->maxs[0]) {
		Com_Printf("WARNING: node without a volume\n");
	}

	for (i = 0; i < 3; i++) {
		if (node->mins[i] < -MAX_WORLD_WIDTH || node->maxs[i] > MAX_WORLD_WIDTH) {
			Com_Printf("WARNING: node with unbounded volume %i\n", (int)node->mins[i]);
			break;
		}
	}
	if (node->planenum == PLANENUM_LEAF)
		return;

	MakeNodePortal(node);
	SplitNodePortals(node);

	MakeTreePortals_r(node->children[0]);
	MakeTreePortals_r(node->children[1]);
}
Exemplo n.º 8
0
/*
================
CutNodePortals_r
================
*/
static void CutNodePortals_r (node_t *node)
{
	plane_t 	*plane, clipplane;
	node_t		*f, *b, *other_node;
	portal_t	*p, *new_portal, *next_portal;
	winding_t	*w, *frontwinding, *backwinding;
	int			side;

	// Vic: properly calculate the bounding box
	CalcNodeBounds (node);

	//
	// separate the portals on node into it's children
	//
	if (node->contents)
		return;			// at a leaf, no more dividing

	plane = &mapplanes[node->planenum];

	f = node->children[0];
	b = node->children[1];

	//
	// create the new portal by taking the full plane winding for the cutting plane
	// and clipping it by all of the planes from the other portals
	//
	w = BaseWindingForPlane (&mapplanes[node->planenum]);
	side = 0;	// shut up compiler warning
	for (p = node->portals ; p ; p = p->next[side])
	{
		clipplane = mapplanes[p->planenum];
		if (p->nodes[0] == node)
			side = 0;
		else if (p->nodes[1] == node)
		{
			clipplane.dist = -clipplane.dist;
			VectorNegate (clipplane.normal, clipplane.normal);
			side = 1;
		}
		else
			Error ("CutNodePortals_r: mislinked portal");

		w = ClipWinding (w, &clipplane, true);
		if (!w)
		{
			printf ("WARNING: CutNodePortals_r:new portal was clipped away\n");
			break;
		}
	}

	if (w)
	{
		// if the plane was not clipped on all sides, there was an error
		new_portal = AllocPortal ();
		new_portal->planenum = node->planenum;
		new_portal->winding = w;
		AddPortalToNodes (new_portal, f, b);
	}

	// partition the portals
	for (p = node->portals ; p ; p = next_portal)
	{
		if (p->nodes[0] == node)
			side = 0;
		else if (p->nodes[1] == node)
			side = 1;
		else
			Error ("CutNodePortals_r: mislinked portal");
		next_portal = p->next[side];

		other_node = p->nodes[!side];
		RemovePortalFromNode (p, p->nodes[0]);
		RemovePortalFromNode (p, p->nodes[1]);

		// cut the portal into two portals, one on each side of the cut plane
		DivideWindingEpsilon( p->winding, plane, &frontwinding, &backwinding, ON_EPSILON );

		if (!frontwinding)
		{
			if (side == 0)
				AddPortalToNodes (p, b, other_node);
			else
				AddPortalToNodes (p, other_node, b);
			continue;
		}
		if (!backwinding)
		{
			if (side == 0)
				AddPortalToNodes (p, f, other_node);
			else
				AddPortalToNodes (p, other_node, f);
			continue;
		}

		// the winding is split
		new_portal = AllocPortal ();
		*new_portal = *p;
		new_portal->winding = backwinding;
		FreeWinding (p->winding);
		p->winding = frontwinding;

		if (side == 0)
		{
			AddPortalToNodes (p, f, other_node);
			AddPortalToNodes (new_portal, b, other_node);
		}
		else
		{
			AddPortalToNodes (p, other_node, f);
			AddPortalToNodes (new_portal, other_node, b);
		}
	}

	CutNodePortals_r (f);
	CutNodePortals_r (b);
}