Ejemplo n.º 1
0
/*
===================
R_SplitEntityOnNode
===================
*/
void
R_SplitEntityOnNode(mnode_t *node)
{
    efrag_t *ef;
    mplane_t *splitplane;
    mleaf_t *leaf;
    int sides;

    if (node->contents == CONTENTS_SOLID) {
	return;
    }
// add an efrag if the node is a leaf

    if (node->contents < 0) {
	if (!r_pefragtopnode)
	    r_pefragtopnode = node;

	leaf = (mleaf_t *)node;

// grab an efrag off the free list
	ef = cl.free_efrags;
	if (!ef) {
	    Con_Printf("Too many efrags!\n");
	    return;		// no free fragments...
	}
	cl.free_efrags = cl.free_efrags->entnext;

	ef->entity = r_addent;

// add the entity link
	*lastlink = ef;
	lastlink = &ef->entnext;
	ef->entnext = NULL;

// set the leaf links
	ef->leaf = leaf;
	ef->leafnext = leaf->efrags;
	leaf->efrags = ef;

	return;
    }
// NODE_MIXED

    splitplane = node->plane;
    sides = BOX_ON_PLANE_SIDE(r_emins, r_emaxs, splitplane);

    if (sides == 3) {
	// split on this plane
	// if this is the first splitter of this bmodel, remember it
	if (!r_pefragtopnode)
	    r_pefragtopnode = node;
    }
// recurse down the contacted sides
    if (sides & 1)
	R_SplitEntityOnNode(node->children[0]);

    if (sides & 2)
	R_SplitEntityOnNode(node->children[1]);
}
Ejemplo n.º 2
0
/*
===========
R_AddEfrags
===========
*/
void R_AddEfrags(entity_t *ent)
{
	model_t		*entmodel;
	int			i;

	if (!ent->model)
	{
		return;
	}

	if (ent == cl_entities)
	{
		return;    // never add the world
	}

	r_addent = ent;

	lastlink = &ent->efrag;
	r_pefragtopnode = NULL;

	entmodel = ent->model;

	for (i=0 ; i<3 ; i++)
	{
		r_emins[i] = ent->origin[i] + entmodel->mins[i];
		r_emaxs[i] = ent->origin[i] + entmodel->maxs[i];
	}

	R_SplitEntityOnNode(cl.worldmodel->nodes);

	ent->topnode = r_pefragtopnode;
}
Ejemplo n.º 3
0
void R_AddEfrags (entity_t *ent)
{
	model_t		*entmodel;
	int			i;

	if (!ent->model)
		return;

	r_addent = ent;

	lastlink = &ent->efrag;
	r_pefragtopnode = NULL;

	entmodel = ent->model;

	for (i=0 ; i<3 ; i++)
	{
		r_emins[i] = ent->origin[i] + entmodel->mins[i];
		r_emaxs[i] = ent->origin[i] + entmodel->maxs[i];
	}

	R_SplitEntityOnNode (cl.worldmodel->nodes);

	ent->topnode = r_pefragtopnode;

	R_CheckEfrags (); //johnfitz
}
Ejemplo n.º 4
0
/*
===========
R_AddEfrags
===========
*/
void
R_AddEfrags(entity_t *ent)
{
    if (!ent->model)
	return;

    r_addent = ent;
    lastlink = &ent->efrag;
    r_pefragtopnode = NULL;

    VectorAdd(ent->origin, ent->model->mins, r_emins);
    VectorAdd(ent->origin, ent->model->maxs, r_emaxs);

    R_SplitEntityOnNode(cl.worldmodel->nodes);
    ent->topnode = r_pefragtopnode;
}
Ejemplo n.º 5
0
/*
===========
R_AddEfrags
===========
*/
void R_AddEfrags( cl_entity_t *ent )
{
	int	i;
		
	if( !ent->model )
		return;

	r_addent = ent;
	lastlink = &ent->efrag;
	r_pefragtopnode = NULL;

	// NOTE: can't copy these bounds directly into model->mins\model->maxs
	// because all other code don't expected this
	if( ent->model->type == mod_studio )
	{
		studiohdr_t *phdr = (studiohdr_t *)Mod_Extradata( ent->model );
		mstudioseqdesc_t *pseqdesc;

		if( !phdr ) return;
		pseqdesc = (mstudioseqdesc_t *)((byte *)phdr + phdr->seqindex);

		for( i = 0; i < 3; i++ )
		{
			r_emins[i] = ent->origin[i] + pseqdesc[0].bbmin[i];
			r_emaxs[i] = ent->origin[i] + pseqdesc[0].bbmax[i];
		}
	}
	else
	{
		for( i = 0; i < 3; i++ )
		{
			r_emins[i] = ent->origin[i] + ent->model->mins[i];
			r_emaxs[i] = ent->origin[i] + ent->model->maxs[i];
		}
	}

	R_SplitEntityOnNode( cl.worldmodel->nodes );
	ent->topnode = r_pefragtopnode;
}
Ejemplo n.º 6
0
void R_SplitEntityOnNode (mnode_t *node)
{
	efrag_t		*ef;
	mplane_t	*splitplane;
	mleaf_t		*leaf;
	int			sides;

	if(node->contents == BSP_CONTENTS_SOLID)
		return;

// add an efrag if the node is a leaf

	if ( node->contents < 0)
	{
		if (!r_pefragtopnode)
			r_pefragtopnode = node;

		leaf = (mleaf_t *)node;

// grab an efrag off the free list
		ef = cl.free_efrags;
		if (!ef)
		{
			//johnfitz -- less spammy overflow message
			if (!dev_overflows.efrags || dev_overflows.efrags + CONSOLE_RESPAM_TIME < realtime )
			{
				Con_Printf ("Too many efrags!\n");
				dev_overflows.efrags = realtime;
			}
			//johnfitz
			return;		// no free fragments...
		}
		cl.free_efrags = cl.free_efrags->entnext;

		ef->entity = r_addent;

// add the entity link
		*lastlink = ef;
		lastlink = &ef->entnext;
		ef->entnext = NULL;

// set the leaf links
		ef->leaf = leaf;
		ef->leafnext = leaf->efrags;
		leaf->efrags = ef;

		return;
	}

// NODE_MIXED

	splitplane = node->plane;
	sides = World_BoxOnPlaneSide(r_emins, r_emaxs, splitplane);

	if (sides == 3)
	{
	// split on this plane
	// if this is the first splitter of this bmodel, remember it
		if (!r_pefragtopnode)
			r_pefragtopnode = node;
	}

// recurse down the contacted sides
	if (sides & 1)
		R_SplitEntityOnNode (node->children[0]);

	if (sides & 2)
		R_SplitEntityOnNode (node->children[1]);
}