Example #1
0
qboolean PlaceOccupant( node_t *headnode, vec3_t origin, entity_t *occupant, qboolean skybox )
{
    vec_t	d;
    node_t	*node;
    plane_t	*plane;


    // find the leaf to start in
    node = headnode;
    while( node->planenum != PLANENUM_LEAF )
    {
        plane = &mapplanes[ node->planenum ];
        d = DotProduct( origin, plane->normal ) - plane->dist;
        if( d >= 0 )
            node = node->children[ 0 ];
        else
            node = node->children[ 1 ];
    }

    if( node->opaque )
        return qfalse;
    node->occupant = occupant;
    node->skybox = skybox;

    FloodPortals_r( node, 1, skybox );

    return qtrue;
}
Example #2
0
//-----------------------------------------------------------------------------
// Purpose: For the given entity at the given origin, finds the leaf node in the
//			BSP tree that the entity occupies.
//
//			We then flood outward from that leaf to see if the entity leaks.
// Input  : headnode - 
//			origin - 
//			occupant - 
// Output : Returns false if the entity is in solid, true if it is not.
//-----------------------------------------------------------------------------
qboolean PlaceOccupant (node_t *headnode, Vector& origin, entity_t *occupant)
{
	node_t	*node;
	vec_t	d;
	plane_t	*plane;

	// find the leaf to start in
	node = headnode;
	while (node->planenum != PLANENUM_LEAF)
	{
		plane = &mapplanes[node->planenum];
		d = DotProduct (origin, plane->normal) - plane->dist;
		if (d >= 0)
			node = node->children[0];
		else
			node = node->children[1];
	}

	if (node->contents == CONTENTS_SOLID)
		return false;

	node->occupant = occupant;

	// Flood outward from here to see if this entity leaks.
	FloodPortals_r (node, 1);

	return true;
}
Example #3
0
/*
=============
PlaceOccupant
=============
*/
bool PlaceOccupant( node_t *headnode, idVec3 origin, uEntity_t *occupant )
{
	node_t	*node;
	float	d;
	idPlane	*plane;
	
	// find the leaf to start in
	node = headnode;
	
	while( node->planenum != PLANENUM_LEAF )
	{
		plane = &dmapGlobals.mapPlanes[node->planenum];
		d = plane->Distance( origin );
		
		if( d >= 0.0f )
		{
			node = node->children[0];
		}
		else
		{
			node = node->children[1];
		}
	}
	
	if( node->opaque )
	{
		return false;
	}
	
	node->occupant = occupant;
	
	FloodPortals_r( node, 1 );
	
	return true;
}
Example #4
0
void FloodPortals_r( node_t *node, int dist ) {
	portal_t *p;
	int s;
//	int i;

	Log_Print( "\r%6d", ++numrec );

	if ( node->occupied ) {
		Error( "FloodPortals_r: node already occupied\n" );
	}
	if ( !node ) {
		Error( "FloodPortals_r: NULL node\n" );
	} //end if*/
	node->occupied = dist;

	for ( p = node->portals; p; p = p->next[s] )
	{
		s = ( p->nodes[1] == node );
		//if the node at the other side of the portal is occupied already
		if ( p->nodes[!s]->occupied ) {
			continue;
		}
		//if it isn't possible to flood through this portal
		if ( !Portal_EntityFlood( p, s ) ) {
			continue;
		}
		//flood recursively through the current portal
		FloodPortals_r( p->nodes[!s], dist + 1 );
	} //end for
	Log_Print( "\r%6d", --numrec );
} //end of the function FloodPortals_r
/*
=============
FloodPortals_r
=============
*/
void FloodPortals_r( node_t *node, int dist ) {
	uPortal_t	*p;
	int			s;
	if( node->occupied ) {
		return;
	}
	if( node->opaque ) {
		return;
	}
	c_floodedleafs++;
	node->occupied = dist;
	for( p = node->portals ; p ; p = p->next[s] ) {
		s = ( p->nodes[1] == node );
		FloodPortals_r( p->nodes[!s], dist + 1 );
	}
}
Example #6
0
/*
 * @brief
 */
static void FloodPortals_r(node_t * node, int32_t dist) {
    portal_t *p;
    int32_t s;

    node->occupied = dist;

    for (p = node->portals; p; p = p->next[s]) {
        s = (p->nodes[1] == node);

        if (p->nodes[!s]->occupied)
            continue;

        if (!Portal_EntityFlood(p))
            continue;

        FloodPortals_r(p->nodes[!s], dist + 1);
    }
}
Example #7
0
void FloodPortals_r( node_t *node, int dist, qboolean skybox )
{
    int			s;
    portal_t	*p;


    if( skybox )
        node->skybox = skybox;

    if( node->occupied || node->opaque )
        return;

    c_floodedleafs++;
    node->occupied = dist;

    for( p = node->portals; p; p = p->next[ s ] )
    {
        s = (p->nodes[ 1 ] == node);
        FloodPortals_r( p->nodes[ !s ], dist + 1, skybox );
    }
}
Example #8
0
//-----------------------------------------------------------------------------
// Purpose: Floods outward from the given node, marking visited nodes with
//			the number of hops from a node with an entity. If we ever mark
//			the outside_node for this tree, we've leaked.
// Input  : node - 
//			dist - 
//-----------------------------------------------------------------------------
void FloodPortals_r (node_t *node, int dist)
{
	portal_t	*p;
	int			s;

	node->occupied = dist;

	for (p=node->portals ; p ; p = p->next[s])
	{
		s = (p->nodes[1] == node);

		// Skip nodes that have already been marked.
		if (p->nodes[!s]->occupied)
			continue;

		// Skip portals that lead to or from nodes with solid contents.
		if (!Portal_EntityFlood (p, s))
			continue;

		FloodPortals_r (p->nodes[!s], dist+1);
	}
}
Example #9
0
/*
 * @brief
 */
static _Bool PlaceOccupant(node_t * head_node, vec3_t origin, entity_t * occupant) {
    node_t *node;

    // find the leaf to start in
    node = head_node;
    while (node->plane_num != PLANENUM_LEAF) {
        const map_plane_t *plane = &map_planes[node->plane_num];
        const vec_t d = DotProduct(origin, plane->normal) - plane->dist;
        if (d >= 0)
            node = node->children[0];
        else
            node = node->children[1];
    }

    if (node->contents == CONTENTS_SOLID)
        return false;
    node->occupant = occupant;

    FloodPortals_r(node, 1);

    return true;
}