• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ FindFloatPlane函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中FindFloatPlane函数的典型用法代码示例。如果您正苦于以下问题:C++ FindFloatPlane函数的具体用法?C++ FindFloatPlane怎么用?C++ FindFloatPlane使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了FindFloatPlane函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: AllocBrush

/*
==================
BrushFromBounds

Creates a new axial brush
==================
*/
bspbrush_t	*BrushFromBounds (vec3_t mins, vec3_t maxs)
{
	bspbrush_t	*b;
	int			i;
	vec3_t		normal;
	vec_t		dist;

	b = AllocBrush (6);
	b->numsides = 6;
	for (i=0 ; i<3 ; i++)
	{
		VectorClear (normal);
		normal[i] = 1;
		dist = maxs[i];
		b->sides[i].planenum = FindFloatPlane (normal, dist);

		normal[i] = -1;
		dist = -mins[i];
		b->sides[3+i].planenum = FindFloatPlane (normal, dist);
	}

	CreateBrushWindings (b);

	return b;
}
开发者ID:hypov8,项目名称:quake2_texture_fix,代码行数:32,代码来源:brushbsp.c


示例2: qprintf

//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
tmp_node_t *AAS_SubdivideArea_r( tmp_node_t *tmpnode ) {
	int planenum;
	tmp_area_t *frontarea, *backarea;
	tmp_node_t *tmpnode1, *tmpnode2;
	vec3_t normal;
	float dist;

	if ( AAS_FindBestAreaSplitPlane( tmpnode->tmparea, normal, &dist ) ) {
		qprintf( "\r%6d", ++numgravitationalsubdivisions );
		//
		planenum = FindFloatPlane( normal, dist, 0, NULL );
		//split the area
		AAS_SplitArea( tmpnode->tmparea, planenum, &frontarea, &backarea );
		//
		tmpnode->tmparea = NULL;
		tmpnode->planenum = FindFloatPlane( normal, dist, 0, NULL );
		//
		tmpnode1 = AAS_AllocTmpNode();
		tmpnode1->planenum = 0;
		tmpnode1->tmparea = frontarea;
		//
		tmpnode2 = AAS_AllocTmpNode();
		tmpnode2->planenum = 0;
		tmpnode2->tmparea = backarea;
		//subdivide the areas created by splitting recursively
		tmpnode->children[0] = AAS_SubdivideArea_r( tmpnode1 );
		tmpnode->children[1] = AAS_SubdivideArea_r( tmpnode2 );
	} //end if
	return tmpnode;
} //end of the function AAS_SubdivideArea_r
开发者ID:AdrienJaguenet,项目名称:Enemy-Territory,代码行数:36,代码来源:aas_gsubdiv.c


示例3: AllocNode

/*
============
BlockTree

============
*/
node_t	*BlockTree (int xl, int yl, int xh, int yh)
{
	node_t	*node;
	vec3_t	normal;
	float	dist;
	int		mid;

	if (xl == xh && yl == yh)
	{
		node = block_nodes[xl+5][yl+5];
		if (!node)
		{	// return an empty leaf
			node = AllocNode ();
			node->planenum = PLANENUM_LEAF;
			node->contents = 0; //CONTENTS_SOLID;
			return node;
		}
		return node;
	}

	// create a seperator along the largest axis
	node = AllocNode ();

	if (xh - xl > yh - yl)
	{	// split x axis
		mid = xl + (xh-xl)/2 + 1;
		normal[0] = 1;
		normal[1] = 0;
		normal[2] = 0;
		dist = mid*1024;
		node->planenum = FindFloatPlane (normal, dist);
		node->children[0] = BlockTree ( mid, yl, xh, yh);
		node->children[1] = BlockTree ( xl, yl, mid-1, yh);
	}
	else
	{
		mid = yl + (yh-yl)/2 + 1;
		normal[0] = 0;
		normal[1] = 1;
		normal[2] = 0;
		dist = mid*1024;
		node->planenum = FindFloatPlane (normal, dist);
		node->children[0] = BlockTree ( xl, mid, xh, yh);
		node->children[1] = BlockTree ( xl, yl, xh, mid-1);
	}

	return node;
}
开发者ID:hypov8,项目名称:quake2_texture_fix,代码行数:54,代码来源:qbsp3.c


示例4: AdjustBrushesForOrigin

/*
=================
AdjustBrushesForOrigin
=================
*/
void AdjustBrushesForOrigin( entity_t *ent )
{
	int		i;
	side_t		*s;
	vec_t		newdist;
	brush_t		*b;
	parseMesh_t	*p;
	
	for( b = ent->brushes; b != NULL; b = b->next )
	{
		for( i = 0; i < b->numsides; i++)
		{
			s = &b->sides[i];
			
			newdist = mapplanes[ s->planenum ].dist - DotProduct( mapplanes[ s->planenum ].normal, ent->origin );
			s->planenum = FindFloatPlane( mapplanes[ s->planenum ].normal, newdist, 0, NULL );
		}
		
		// rebuild brush windings (just offsetting the winding above should be fine)
		CreateBrushWindings( b );
	}
	
	for( p = ent->patches; p != NULL; p = p->next )
	{
		for( i = 0; i < (p->mesh.width * p->mesh.height); i++ )
			VectorSubtract( p->mesh.verts[i].xyz, ent->origin, p->mesh.verts[i].xyz );
	}
}
开发者ID:a1batross,项目名称:Xash3D_ancient,代码行数:33,代码来源:map.c


示例5: AdjustEntityForOrigin

static void AdjustEntityForOrigin( uEntity_t *ent ) {
	primitive_t	*prim;
	uBrush_t	*b;
	int			i;
	side_t		*s;

	for ( prim = ent->primitives ; prim ; prim = prim->next ) {
		b = prim->brush;
		if ( !b ) {
			continue;
		}
		for ( i = 0; i < b->numsides; i++ ) {
			idPlane plane;

			s = &b->sides[i];

			plane = dmapGlobals.mapPlanes[s->planenum];
			plane[3] += plane.Normal() * ent->origin;

			s->planenum = FindFloatPlane( plane );

			s->texVec.v[0][3] += DotProduct( ent->origin, s->texVec.v[0] );
			s->texVec.v[1][3] += DotProduct( ent->origin, s->texVec.v[1] );

			// remove any integral shift
			s->texVec.v[0][3] -= floor( s->texVec.v[0][3] );
			s->texVec.v[1][3] -= floor( s->texVec.v[1][3] );
		}
		CreateBrushWindings(b);
	}
}
开发者ID:AndreiBarsan,项目名称:doom3.gpl,代码行数:31,代码来源:map.cpp


示例6: ParseBrush

/*
=================
ParseBrush
=================
*/
static void ParseBrush( const idMapBrush *mapBrush, int primitiveNum ) {
	uBrush_t	*b;
	side_t		*s;
	const idMapBrushSide	*ms;
	int			i;
	bool		fixedDegeneracies = false;
	buildBrush->entitynum = dmapGlobals.num_entities - 1;
	buildBrush->brushnum = entityPrimitive;
	buildBrush->numsides = mapBrush->GetNumSides();
	for( i = 0 ; i < mapBrush->GetNumSides() ; i++ ) {
		s = &buildBrush->sides[i];
		ms = mapBrush->GetSide( i );
		memset( s, 0, sizeof( *s ) );
		s->planenum = FindFloatPlane( ms->GetPlane(), &fixedDegeneracies );
		s->material = declManager->FindMaterial( ms->GetMaterial() );
		ms->GetTextureVectors( s->texVec.v );
		// remove any integral shift, which will help with grouping
		s->texVec.v[0][3] -= floor( s->texVec.v[0][3] );
		s->texVec.v[1][3] -= floor( s->texVec.v[1][3] );
	}
	// if there are mirrored planes, the entire brush is invalid
	if( !RemoveDuplicateBrushPlanes( buildBrush ) ) {
		return;
	}
	// get the content for the entire brush
	SetBrushContents( buildBrush );
	b = FinishBrush();
	if( !b ) {
		return;
	}
	if( fixedDegeneracies && dmapGlobals.verboseentities ) {
		common->Warning( "brush %d has degenerate plane equations", primitiveNum );
	}
}
开发者ID:SL987654,项目名称:The-Darkmod-Experimental,代码行数:39,代码来源:map.cpp


示例7: AAS_ExpandMapBrush

//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_ExpandMapBrush(mapbrush_t *brush, vec3_t mins, vec3_t maxs)
{
	int sn;
	float dist;
	side_t *s;
	plane_t *plane;

	for (sn = 0; sn < brush->numsides; sn++)
	{
		s = brush->original_sides + sn;
		plane = &mapplanes[s->planenum];
		dist = plane->dist;
		if (capsule_collision) {
			dist += CapsuleOriginDistanceFromPlane(plane->normal, mins, maxs);
		}
		else {
			dist += BoxOriginDistanceFromPlane(plane->normal, mins, maxs, 0);
		}
		s->planenum = FindFloatPlane(plane->normal, dist);
		//the side isn't a bevel after expanding
		s->flags &= ~SFL_BEVEL;
		//don't skip the surface
		s->surf &= ~SURF_SKIP;
		//make sure the texinfo is not TEXINFO_NODE
		//when player clip contents brushes are read from the bsp tree
		//they have the texinfo field set to TEXINFO_NODE
		//s->texinfo = 0;
	} //end for
} //end of the function AAS_ExpandMapBrush
开发者ID:Cpasjuste,项目名称:quake3_pandora_gles,代码行数:35,代码来源:aas_map.c


示例8: AAS_TestSplitPlane

//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_TestSplitPlane(tmp_area_t *tmparea, vec3_t normal, float dist,
							int *facesplits, int *groundsplits, int *epsilonfaces)
{
	int j, side, front, back, planenum;
	float d, d_front, d_back;
	tmp_face_t *face;
	winding_t *w;

	*facesplits = *groundsplits = *epsilonfaces = 0;

	planenum = FindFloatPlane(normal, dist);

	w = AAS_SplitWinding(tmparea, planenum);
	if (!w) return false;
	FreeWinding(w);
	//
	for (face = tmparea->tmpfaces; face; face = face->next[side])
	{
		//side of the face the area is on
		side = face->frontarea != tmparea;

		if ((face->planenum & ~1) == (planenum & ~1))
		{
			Log_Print("AAS_TestSplitPlane: tried face plane as splitter\n");
			return false;
		} //end if
		w = face->winding;
		//reset distance at front and back side of plane
		d_front = d_back = 0;
		//reset front and back flags
		front = back = 0;
		for (j = 0; j < w->numpoints; j++)
		{
			d = DotProduct(w->p[j], normal) - dist;
			if (d > d_front) d_front = d;
			if (d < d_back) d_back = d;

			if (d > 0.4) // PLANESIDE_EPSILON)
				front = 1;
			if (d < -0.4) // PLANESIDE_EPSILON)
				back = 1;
		} //end for
		//check for an epsilon face
		if ( (d_front > FACECLIP_EPSILON && d_front < FACE_EPSILON)
			|| (d_back < -FACECLIP_EPSILON && d_back > -FACE_EPSILON) )
		{
			(*epsilonfaces)++;
		} //end if
		//if the face has points at both sides of the plane
		if (front && back)
		{
			(*facesplits)++;
			if (face->faceflags & FACE_GROUND)
			{
				(*groundsplits)++;
			} //end if
		} //end if
	} //end for
	return true;
} //end of the function AAS_TestSplitPlane
开发者ID:AHPlankton,项目名称:Quake-III-Arena,代码行数:66,代码来源:aas_gsubdiv.c


示例9: Q3_DPlanes2MapPlanes

//===========================================================================
//
// Parameter:			-
// Returns:				-
// Changes Globals:		-
//===========================================================================
void Q3_DPlanes2MapPlanes( void ) {
	int i;

	for ( i = 0; i < q3_numplanes; i++ )
	{
		dplanes2mapplanes[i] = FindFloatPlane( q3_dplanes[i].normal, q3_dplanes[i].dist );
	} //end for
} //end of the function Q3_DPlanes2MapPlanes
开发者ID:JackalFrost,项目名称:RTCW-WSGF,代码行数:14,代码来源:map_q3.c


示例10: AllocBrush

/*
==================
BrushFromBounds

Creates a new axial brush
==================
*/
brush_t	*BrushFromBounds (float minx, float miny, float minz, float maxx, float maxy, float maxz, shaderInfo_t *si)
{
    brush_t	*b;
    vec3_t mins, maxs;
    vec3_t normal;
    vec_t dist;
    int	i;

    b = AllocBrush (6);
    b->entityNum = mapEntityNum;
    b->original = b;
    b->contentShader = si;
    b->compileFlags = si->compileFlags;
    b->contentFlags = si->contentFlags;
    b->opaque = qtrue;
    b->detail = qfalse;
    b->numsides = 6;
    VectorSet(mins, minx, miny, minz);
    VectorSet(maxs, maxx, maxy, maxz);
    for (i=0 ; i<3 ; i++)
    {
        VectorClear (normal);
        normal[i] = 1;
        dist = maxs[i];
        b->sides[i].planenum = FindFloatPlane (normal, dist, 1, (vec3_t*) &maxs );
        b->sides[i].shaderInfo = si;
        b->sides[i].surfaceFlags = si->surfaceFlags;
        b->sides[i].contentFlags = si->contentFlags;
        b->sides[i].compileFlags = si->compileFlags;
        b->sides[i].value = si->value;

        normal[i] = -1;
        dist = -mins[i];
        b->sides[3+i].planenum = FindFloatPlane (normal, dist, 1, (vec3_t*) &mins );
        b->sides[3+i].shaderInfo = si;
        b->sides[3+i].surfaceFlags = si->surfaceFlags;
        b->sides[3+i].contentFlags = si->contentFlags;
        b->sides[3+i].compileFlags = si->compileFlags;
        b->sides[3+i].value = si->value;
    }

    CreateBrushWindings (b);

    return b;
}
开发者ID:paulvortex,项目名称:BloodMap,代码行数:52,代码来源:brush.c


示例11: DPlanes2MapPlanes

//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void DPlanes2MapPlanes(void)
{
	int i;

	for (i = 0; i < numplanes; i++)
	{
		dplanes2mapplanes[i] = FindFloatPlane(dplanes[i].normal, dplanes[i].dist, 0, NULL);
	} //end for
} //end of the function DPlanes2MapPlanes
开发者ID:morsik,项目名称:war-territory,代码行数:15,代码来源:map_q2.c


示例12: AAS_TransformPlane

//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_TransformPlane(int planenum, vec3_t origin, vec3_t angles)
{
	float newdist, matrix[3][3];
	vec3_t normal;

	//rotate the node plane
	VectorCopy(mapplanes[planenum].normal, normal);
	CreateRotationMatrix(angles, matrix);
	RotatePoint(normal, matrix);
	newdist = mapplanes[planenum].dist + DotProduct(normal, origin);
	return FindFloatPlane(normal, newdist);
} //end of the function AAS_TransformPlane
开发者ID:Cpasjuste,项目名称:quake3_pandora_gles,代码行数:18,代码来源:aas_map.c


示例13: MapPlaneFromPoints

/*
=================
MapPlaneFromPoints

takes 3 points and finds the plane they lie in
=================
*/
int MapPlaneFromPoints( vec3_t *p )
{
	vec3_t	t1, t2, normal;
	vec_t	dist;
	
	VectorSubtract( p[0], p[1], t1 );
	VectorSubtract( p[2], p[1], t2 );
	CrossProduct( t1, t2, normal );
	VectorNormalize( normal );
	dist = DotProduct( p[0], normal );
	
	return FindFloatPlane( normal, dist, 3, p );
}
开发者ID:a1batross,项目名称:Xash3D_ancient,代码行数:20,代码来源:map.c


示例14: PlaneFromPoints

/*
 * PlaneFromPoints
 */
static int PlaneFromPoints(const vec3_t p0, const vec3_t p1, const vec3_t p2) {
	vec3_t t1, t2, normal;
	vec_t dist;

	VectorSubtract(p0, p1, t1);
	VectorSubtract(p2, p1, t2);
	CrossProduct(t1, t2, normal);
	VectorNormalize(normal);

	dist = DotProduct(p0, normal);

	return FindFloatPlane(normal, dist);
}
开发者ID:darkshade9,项目名称:aq2w,代码行数:16,代码来源:map.c


示例15: AllocBrush

/*
==================
BrushFromBounds

Creates a new axial brush
==================
*/
uBrush_t	*BrushFromBounds( const idBounds &bounds ) {
	uBrush_t	*b;
	int			i;
	idPlane		plane;

	b = AllocBrush (6);
	b->numsides = 6;
	for (i=0 ; i<3 ; i++) {
		plane[0] = plane[1] = plane[2] = 0;
		plane[i] = 1;
		plane[3] = -bounds[1][i];
		b->sides[i].planenum = FindFloatPlane( plane );

		plane[i] = -1;
		plane[3] = bounds[0][i];
		b->sides[3+i].planenum = FindFloatPlane( plane );
	}

	CreateBrushWindings (b);

	return b;
}
开发者ID:RobertBeckebans,项目名称:d3dmap,代码行数:29,代码来源:ubrush.cpp


示例16: AddMapTriToAreas

/*
==================
AddMapTriToAreas

Used for curves and inlined models
==================
*/
void AddMapTriToAreas( mapTri_t* tri, uEntity_t* e )
{
	int				area;
	idWinding*		w;
	
	// skip degenerate triangles from pinched curves
	if( MapTriArea( tri ) <= 0 )
	{
		return;
	}
	
	if( dmapGlobals.fullCarve )
	{
		// always fragment into areas
		w = WindingForTri( tri );
		ClipTriIntoTree_r( w, tri, e, e->tree->headnode );
		return;
	}
	
	w = WindingForTri( tri );
	area = CheckWindingInAreas_r( w, e->tree->headnode );
	delete w;
	if( area == -1 )
	{
		return;
	}
	if( area >= 0 )
	{
		mapTri_t*	newTri;
		idPlane		plane;
		int			planeNum;
		textureVectors_t	texVec;
		
		// put in single area
		newTri = CopyMapTri( tri );
		newTri->next = NULL;
		
		PlaneForTri( tri, plane );
		planeNum = FindFloatPlane( plane );
		
		TexVecForTri( &texVec, newTri );
		
		AddTriListToArea( e, newTri, planeNum, area, &texVec );
	}
	else
	{
		// fragment into areas
		w = WindingForTri( tri );
		ClipTriIntoTree_r( w, tri, e, e->tree->headnode );
	}
}
开发者ID:Erdk,项目名称:RBDOOM-3-BFG,代码行数:58,代码来源:usurface.cpp


示例17: ClipTriIntoTree_r

/*
====================
ClipTriIntoTree_r

This is used for adding curve triangles
The winding will be freed before it returns
====================
*/
void ClipTriIntoTree_r( idWinding* w, mapTri_t* originalTri, uEntity_t* e, node_t* node )
{
	idWinding*		front, *back;
	
	if( !w )
	{
		return;
	}
	
	if( node->planenum != PLANENUM_LEAF )
	{
		//common->Printf( "ClipTriIntoTree_r: splitting triangle with splitplane %i\n", node->nodeNumber );
		
		w->Split( dmapGlobals.mapPlanes[ node->planenum ], ON_EPSILON, &front, &back );
		delete w;
		
		ClipTriIntoTree_r( front, originalTri, e, node->children[0] );
		ClipTriIntoTree_r( back, originalTri, e, node->children[1] );
		
		return;
	}
	
	//common->Printf( "ClipTriIntoTree_r: leaf area = %i, opaque = %i, occupied = %i\n", node->area, node->occupied );
	
	// if opaque leaf, don't add
	if( !node->opaque && node->area >= 0 )
	{
		mapTri_t*	list;
		int			planeNum;
		idPlane		plane;
		textureVectors_t	texVec;
		
		list = WindingToTriList( w, originalTri );
		
		PlaneForTri( originalTri, plane );
		planeNum = FindFloatPlane( plane );
		
		TexVecForTri( &texVec, originalTri );
		
		AddTriListToArea( e, list, planeNum, node->area, &texVec );
	}
	
	delete w;
	return;
}
开发者ID:Erdk,项目名称:RBDOOM-3-BFG,代码行数:53,代码来源:usurface.cpp


示例18: AAS_CreateCurveBrushes

void AAS_CreateCurveBrushes(void)
{
	int i, j, n, planenum, numcurvebrushes = 0;
	q3_dsurface_t *surface;
	q3_drawVert_t *dv_p;
	vec3_t points[MAX_PATCH_VERTS];
	int width, height, c;
	patchCollide_t *pc;
	facet_t *facet;
	mapbrush_t *brush;
	side_t *side;
	entity_t *mapent;
	winding_t *winding;

	qprintf("nummapbrushsides = %d\n", nummapbrushsides);
	mapent = &entities[0];

	for(i = 0; i < q3_numDrawSurfaces; i++)
	{
		surface = &q3_drawSurfaces[i];

		if(!surface->patchWidth)
		{
			continue;
		}

		//if the curve is not solid
		if(!(q3_dshaders[surface->shaderNum].contentFlags & (CONTENTS_SOLID | CONTENTS_PLAYERCLIP)))
		{
			//Log_Print("skipped non-solid curve\n");
			continue;
		} //end if

		//
		width = surface->patchWidth;
		height = surface->patchHeight;
		c = width * height;

		if(c > MAX_PATCH_VERTS)
		{
			Error("ParseMesh: MAX_PATCH_VERTS");
		} //end if

		dv_p = q3_drawVerts + surface->firstVert;

		for(j = 0 ; j < c ; j++, dv_p++)
		{
			points[j][0] = dv_p->xyz[0];
			points[j][1] = dv_p->xyz[1];
			points[j][2] = dv_p->xyz[2];
		} //end for

		// create the internal facet structure
		pc = CM_GeneratePatchCollide(width, height, points);

		//
		for(j = 0; j < pc->numFacets; j++)
		{
			facet = &pc->facets[j];
			//
			brush = &mapbrushes[nummapbrushes];
			brush->original_sides = &brushsides[nummapbrushsides];
			brush->entitynum = 0;
			brush->brushnum = nummapbrushes - mapent->firstbrush;
			//
			brush->numsides = facet->numBorders + 2;
			nummapbrushsides += brush->numsides;
			brush->contents = CONTENTS_SOLID;
			//
			//qprintf("\r%6d curve brushes", nummapbrushsides);//++numcurvebrushes);
			qprintf("\r%6d curve brushes", ++numcurvebrushes);
			//
			planenum = FindFloatPlane(pc->planes[facet->surfacePlane].plane, pc->planes[facet->surfacePlane].plane[3]);
			//
			side = &brush->original_sides[0];
			side->planenum = planenum;
			side->contents = CONTENTS_SOLID;
			side->flags |= SFL_TEXTURED | SFL_VISIBLE | SFL_CURVE;
			side->surf = 0;
			//
			side = &brush->original_sides[1];

			if(create_aas)
			{
				//the plane is expanded later so it's not a problem that
				//these first two opposite sides are coplanar
				side->planenum = planenum ^ 1;
			} //end if
			else
			{
				side->planenum = FindFloatPlane(mapplanes[planenum ^ 1].normal, mapplanes[planenum ^ 1].dist + 1);
				side->flags |= SFL_TEXTURED | SFL_VISIBLE;
			} //end else

			side->contents = CONTENTS_SOLID;
			side->flags |= SFL_CURVE;
			side->surf = 0;
			//
			winding = BaseWindingForPlane(mapplanes[side->planenum].normal, mapplanes[side->planenum].dist);

//.........这里部分代码省略.........
开发者ID:Diskutant,项目名称:RTCW-SP,代码行数:101,代码来源:map_q3.c


示例19: SelectSplitPlaneNum

int SelectSplitPlaneNum( node_t *node, bspface_t *list ) {
	bspface_t	*split;
	bspface_t	*check;
	bspface_t	*bestSplit;
	int			splits, facing, front, back;
	int			side;
	idPlane		*mapPlane;
	int			value, bestValue;
	idPlane		plane;
	int			planenum;
	bool	havePortals;
	float		dist;
	idVec3		halfSize;

	// if it is crossing a 1k block boundary, force a split
	// this prevents epsilon problems from extending an
	// arbitrary distance across the map

	halfSize = ( node->bounds[1] - node->bounds[0] ) * 0.5f;
	for ( int axis = 0; axis < 3; axis++ ) {
		if ( halfSize[axis] > BLOCK_SIZE ) {
			dist = BLOCK_SIZE * ( floor( ( node->bounds[0][axis] + halfSize[axis] ) / BLOCK_SIZE ) + 1.0f );
		} else {
			dist = BLOCK_SIZE * ( floor( node->bounds[0][axis] / BLOCK_SIZE ) + 1.0f );
		}
		if ( dist > node->bounds[0][axis] + 1.0f && dist < node->bounds[1][axis] - 1.0f ) {
			plane[0] = plane[1] = plane[2] = 0.0f;
			plane[axis] = 1.0f;
			plane[3] = -dist;
			planenum = FindFloatPlane( plane );
			return planenum;
		}
	}

	// pick one of the face planes
	// if we have any portal faces at all, only
	// select from them, otherwise select from
	// all faces
	bestValue = -999999;
	bestSplit = list;

	havePortals = false;
	for ( split = list ; split ; split = split->next ) {
		split->checked = false;
		if ( split->portal ) {
			havePortals = true;
		}
	}

	for ( split = list ; split ; split = split->next ) {
		if ( split->checked ) {
			continue;
		}
		if ( havePortals != split->portal ) {
			continue;
		}
		mapPlane = &dmapGlobals.mapPlanes[ split->planenum ];
		splits = 0;
		facing = 0;
		front = 0;
		back = 0;
		for ( check = list ; check ; check = check->next ) {
			if ( check->planenum == split->planenum ) {
				facing++;
				check->checked = true;	// won't need to test this plane again
				continue;
			}
			side = check->w->PlaneSide( *mapPlane );
			if ( side == SIDE_CROSS ) {
				splits++;
			} else if ( side == SIDE_FRONT ) {
				front++;
			} else if ( side == SIDE_BACK ) {
				back++;
			}
		}
		value =  5*facing - 5*splits; // - abs(front-back);
		if ( mapPlane->Type() < PLANETYPE_TRUEAXIAL ) {
			value+=5;		// axial is better
		}

		if ( value > bestValue ) {
			bestValue = value;
			bestSplit = split;
		}
	}

	if ( bestValue == -999999 ) {
		return -1;
	}

	return bestSplit->planenum;
}
开发者ID:ProfessorKaos64,项目名称:tdm,代码行数:93,代码来源:facebsp.cpp


示例20: memcpy

//===========================================================================
// returns a list with brushes created by splitting the given brush with
// planes that go through the face edges and are orthogonal to the face plane
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
bspbrush_t *Q1_SplitBrushWithFace(bspbrush_t *brush, q1_dface_t *face)
{
    int i, edgenum, side, planenum, splits;
    float dist;
    q1_dplane_t plane;
    vec_t *v1, *v2;
    vec3_t normal, edgevec;
    bspbrush_t *front, *back, *brushlist;

    memcpy(&plane, &q1_dplanes[face->planenum], sizeof(q1_dplane_t));
    //check on which side of the plane the face is
    if (face->side)
    {
        VectorNegate(plane.normal, plane.normal);
        plane.dist = -plane.dist;
    } //end if
    splits = 0;
    brushlist = NULL;
    for (i = 0; i < face->numedges; i++)
    {
        //get the first and second vertex of the edge
        edgenum = q1_dsurfedges[face->firstedge + i];
        side = edgenum > 0;
        //if the face plane is flipped
        v1 = q1_dvertexes[q1_dedges[abs(edgenum)].v[side]].point;
        v2 = q1_dvertexes[q1_dedges[abs(edgenum)].v[!side]].point;
        //create a plane through the edge vector, orthogonal to the face plane
        //and with the normal vector pointing out of the face
        VectorSubtract(v1, v2, edgevec);
        CrossProduct(edgevec, plane.normal, normal);
        VectorNormalize(normal);
        dist = DotProduct(normal, v1);
        //
        planenum = FindFloatPlane(normal, dist);
        //split the current brush
        SplitBrush(brush, planenum, &front, &back);
        //if there is a back brush just put it in the list
        if (back)
        {
            //copy the brush contents
            back->side = brush->side;
            //
            back->next = brushlist;
            brushlist = back;
            splits++;
        } //end if
        if (!front)
        {
            Log_Print("Q1_SplitBrushWithFace: no new brush\n");
            FreeBrushList(brushlist);
            return NULL;
        } //end if
        //copy the brush contents
        front->side = brush->side;
        //continue splitting the front brush
        brush = front;
    } //end for
    if (!splits)
    {
        FreeBrush(front);
        return NULL;
    } //end if
    front->next = brushlist;
    brushlist = front;
    return brushlist;
} //end of the function Q1_SplitBrushWithFace
开发者ID:he110world,项目名称:quake3-ios,代码行数:74,代码来源:map_q1.c



注:本文中的FindFloatPlane函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ FindFocus函数代码示例发布时间:2022-05-30
下一篇:
C++ FindFirstFile函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap