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

C++ ChopWindingInPlace函数代码示例

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

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



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

示例1: BaseWindingForPlane

winding_t	*BaseWindingForNode (node_t *node)
{
	winding_t	*w;
	node_t		*n;
	plane_t		*plane;
	Vector		normal;
	vec_t		dist;

	w = BaseWindingForPlane (mapplanes[node->planenum].normal
		, mapplanes[node->planenum].dist);

	// clip by all the parents
	for (n=node->parent ; n && w ; )
	{
		plane = &mapplanes[n->planenum];

		if (n->children[0] == node)
		{	// take front
			ChopWindingInPlace (&w, plane->normal, plane->dist, BASE_WINDING_EPSILON);
		}
		else
		{	// take back
			VectorSubtract (vec3_origin, plane->normal, normal);
			dist = -plane->dist;
			ChopWindingInPlace (&w, normal, dist, BASE_WINDING_EPSILON);
		}
		node = n;
		n = n->parent;
	}

	return w;
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:32,代码来源:portals.cpp


示例2: BaseWindingForPlane

static winding_t *BaseWindingForNode (node_t *node)
{
	node_t *n;
	winding_t *w;

	w = BaseWindingForPlane(mapplanes[node->planenum].normal
		, mapplanes[node->planenum].dist);

	/* clip by all the parents */
	for (n = node->parent; n && w;) {
		const plane_t *plane = &mapplanes[n->planenum];

		if (n->children[0] == node) {	/* take front */
			ChopWindingInPlace(&w, plane->normal, plane->dist, BASE_WINDING_EPSILON);
		} else {	/* take back */
			const vec_t dist = -plane->dist;
			vec3_t normal;
			VectorSubtract(vec3_origin, plane->normal, normal);
			ChopWindingInPlace(&w, normal, dist, BASE_WINDING_EPSILON);
		}
		node = n;
		n = n->parent;
	}

	return w;
}
开发者ID:kevlund,项目名称:ufoai,代码行数:26,代码来源:portals.c


示例3: Q3_FaceOnWinding

//===========================================================================
// returns the amount the face and the winding overlap
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
float Q3_FaceOnWinding(dsurface_t *surface, winding_t *winding)
{
    int i;
    float dist, area;
    dplane_t plane;
    vec_t *v1, *v2;
    vec3_t normal, edgevec;
    winding_t *w;

    //copy the winding before chopping
    w = CopyWinding(winding);
    //retrieve the surface plane
    Q3_SurfacePlane(surface, plane.normal, &plane.dist);
    //chop the winding with the surface edge planes
    for (i = 0; i < surface->numVerts && w; i++)
    {
        v1 = drawVerts[surface->firstVert + ((i) % surface->numVerts)].xyz;
        v2 = drawVerts[surface->firstVert + ((i+1) % surface->numVerts)].xyz;
        //create a plane through the edge from v1 to v2, orthogonal to the
        //surface plane and with the normal vector pointing inward
        VectorSubtract(v2, v1, edgevec);
        CrossProduct(edgevec, plane.normal, normal);
        VectorNormalize(normal);
        dist = DotProduct(normal, v1);
        //
        ChopWindingInPlace(&w, normal, dist, -0.1); //CLIP_EPSILON
    } //end for
    if (w)
    {
        area = WindingArea(w);
        FreeWinding(w);
        return area;
    } //end if
    return 0;
} //end of the function Q3_FaceOnWinding
开发者ID:tkmorris,项目名称:OpenMOHAA,代码行数:42,代码来源:l_bsp_q3.c


示例4: CreateBrushWindings

/*
==================
CreateBrushWindings

==================
*/
void CreateBrushWindings (bspbrush_t *brush)
{
	int			i, j;
	winding_t	*w;
	side_t		*side;
	plane_t		*plane;

	for (i=0 ; i<brush->numsides ; i++)
	{
		side = &brush->sides[i];
		plane = &mapplanes[side->planenum];
		w = BaseWindingForPlane (plane->normal, plane->dist);
		for (j=0 ; j<brush->numsides && w; j++)
		{
			if (i == j)
				continue;
			if (brush->sides[j].bevel)
				continue;
			plane = &mapplanes[brush->sides[j].planenum^1];
			ChopWindingInPlace (&w, plane->normal, plane->dist, 0); //CLIP_EPSILON);
		}

		side->winding = w;
	}

	BoundBrush (brush);
}
开发者ID:hypov8,项目名称:quake2_texture_fix,代码行数:33,代码来源:brushbsp.c


示例5: CreateBrushWindings

/*
==================
CreateBrushWindings

==================
*/
void CreateBrushWindings (bspbrush_t *brush)
{
	int			i, j;
	winding_t	*w;
	side_t		*side;
	plane_t		*plane;

	// translate the CSG problem to improve precision
	Vector insidePoint = PointInsideBrush( brush );
	Vector offset = -insidePoint;

	for (i=0 ; i<brush->numsides ; i++)
	{
		side = &brush->sides[i];
		plane = &g_MainMap->mapplanes[side->planenum];
		w = BaseWindingForPlane (plane->normal, plane->dist + DotProduct(plane->normal, offset));
		for (j=0 ; j<brush->numsides && w; j++)
		{
			if (i == j)
				continue;
			if (brush->sides[j].bevel)
				continue;
			plane = &g_MainMap->mapplanes[brush->sides[j].planenum^1];
			ChopWindingInPlace (&w, plane->normal, plane->dist + DotProduct(plane->normal, offset), 0); //CLIP_EPSILON);
		}

		TranslateWinding( w, -offset );
		side->winding = w;
	}

	BoundBrush (brush);
}
开发者ID:wouterpleizier,项目名称:source-sdk-2013,代码行数:38,代码来源:brushbsp.cpp


示例6: CreateBrushWindings

/**
 * @brief makes basewindigs for sides and mins/maxs for the brush
 * @returns false if the brush doesn't enclose a valid volume
 */
static void CreateBrushWindings (bspbrush_t* brush)
{
	int i;

	for (i = 0; i < brush->numsides; i++) {
		side_t* side = &brush->sides[i];
		const plane_t* plane = &mapplanes[side->planenum];
		int j;

		/* evidence that winding_t represents a hessian normal plane */
		winding_t* w = BaseWindingForPlane(plane->normal, plane->dist);

		for (j = 0; j < brush->numsides && w; j++) {
			if (i == j)
				continue;
			/* back side clipaway */
			if (brush->sides[j].planenum == (side->planenum ^ 1))
				continue;
			if (brush->sides[j].bevel)
				continue;
			plane = &mapplanes[brush->sides[j].planenum ^ 1];
			ChopWindingInPlace(&w, plane->normal, plane->dist, 0); /*CLIP_EPSILON); */

			/* fix broken windings that would generate trifans */
			if (!FixWinding(w))
				Verb_Printf(VERB_EXTRA, "removed degenerated edge(s) from winding\n");
		}

		side->winding = w;
	}

	BoundBrush(brush);
}
开发者ID:Isaacssv552,项目名称:ufoai,代码行数:37,代码来源:bspbrush.cpp


示例7: MakeHeadnodePortals

void MakeHeadnodePortals (tree_t *tree)
{
	Vector		bounds[2];
	int			i, j, n;
	portal_t	*p, *portals[6];
	plane_t		bplanes[6], *pl;
	node_t *node;

	node = tree->headnode;

// pad with some space so there will never be null volume leafs
	for (i=0 ; i<3 ; i++)
	{
		bounds[0][i] = tree->mins[i] - SIDESPACE;
		bounds[1][i] = tree->maxs[i] + SIDESPACE;
	}
	
	tree->outside_node.planenum = PLANENUM_LEAF;
	tree->outside_node.brushlist = NULL;
	tree->outside_node.portals = NULL;
	tree->outside_node.contents = 0;

	for (i=0 ; i<3 ; i++)
		for (j=0 ; j<2 ; j++)
		{
			n = j*3 + i;

			p = AllocPortal ();
			portals[n] = p;
			
			pl = &bplanes[n];
			memset (pl, 0, sizeof(*pl));
			if (j)
			{
				pl->normal[i] = -1;
				pl->dist = -bounds[j][i];
			}
			else
			{
				pl->normal[i] = 1;
				pl->dist = bounds[j][i];
			}
			p->plane = *pl;
			p->winding = BaseWindingForPlane (pl->normal, pl->dist);
			AddPortalToNodes (p, node, &tree->outside_node);
		}
		
// clip the basewindings by all the other planes
	for (i=0 ; i<6 ; i++)
	{
		for (j=0 ; j<6 ; j++)
		{
			if (j == i)
				continue;
			ChopWindingInPlace (&portals[i]->winding, bplanes[j].normal, bplanes[j].dist, ON_EPSILON);
		}
	}
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:58,代码来源:portals.cpp


示例8: CM_ValidateFacet

/*
==================
CM_ValidateFacet

If the facet isn't bounded by its borders, we screwed up.
==================
*/
static qboolean CM_ValidateFacet(facet_t *facet)
{
	float     plane[4];
	int       j;
	winding_t *w;
	vec3_t    bounds[2];

	if (facet->surfacePlane == -1)
	{
		return qfalse;
	}

	Vector4Copy(planes[facet->surfacePlane].plane, plane);
	w = BaseWindingForPlane(plane, plane[3]);
	for (j = 0 ; j < facet->numBorders && w ; j++)
	{
		if (facet->borderPlanes[j] == -1)
		{
			FreeWinding(w);
			return qfalse;
		}
		Vector4Copy(planes[facet->borderPlanes[j]].plane, plane);
		if (!facet->borderInward[j])
		{
			VectorSubtract(vec3_origin, plane, plane);
			plane[3] = -plane[3];
		}
		ChopWindingInPlace(&w, plane, plane[3], 0.1f);
	}

	if (!w)
	{
		return qfalse;      // winding was completely chopped away
	}

	// see if the facet is unreasonably large
	WindingBounds(w, bounds[0], bounds[1]);
	FreeWinding(w);

	for (j = 0 ; j < 3 ; j++)
	{
		if (bounds[1][j] - bounds[0][j] > MAX_MAP_BOUNDS)
		{
			return qfalse;      // we must be missing a plane
		}
		if (bounds[0][j] >= MAX_MAP_BOUNDS)
		{
			return qfalse;
		}
		if (bounds[1][j] <= -MAX_MAP_BOUNDS)
		{
			return qfalse;
		}
	}
	return qtrue;       // winding is fine
}
开发者ID:raedwulf,项目名称:etlegacy,代码行数:63,代码来源:cm_patch.c


示例9: MakeNodePortal

/*
==================
MakeNodePortal

create the new portal by taking the full plane winding for the cutting plane
and clipping it by all of parents of this node
==================
*/
void MakeNodePortal (node_t *node)
{
	portal_t	*new_portal, *p;
	winding_t	*w;
	Vector		normal;
	float		dist = 0.0f;
	int			side = 0;

	w = BaseWindingForNode (node);

	// clip the portal by all the other portals in the node
	for (p = node->portals ; p && w; p = p->next[side])	
	{
		if (p->nodes[0] == node)
		{
			side = 0;
			VectorCopy (p->plane.normal, normal);
			dist = p->plane.dist;
		}
		else if (p->nodes[1] == node)
		{
			side = 1;
			VectorSubtract (vec3_origin, p->plane.normal, normal);
			dist = -p->plane.dist;
		}
		else
		{
			Error ("CutNodePortals_r: mislinked portal");
		}

		ChopWindingInPlace (&w, normal, dist, 0.1);
	}

	if (!w)
	{
		return;
	}

	if (WindingIsTiny (w))
	{
		c_tinyportals++;
		FreeWinding (w);
		return;
	}


	new_portal = AllocPortal ();
	new_portal->plane = mapplanes[node->planenum];
	new_portal->onnode = node;
	new_portal->winding = w;	

	AddPortalToNodes (new_portal, node->children[0], node->children[1]);
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:61,代码来源:portals.cpp


示例10: BaseWindingForPlane

void CPlaneList::AddBrushes( void )
{
	CUtlVector<listplane_t> temp;
	for ( int brushnumber = 0; brushnumber < numbrushes; brushnumber++ )
	{
		if ( IsBrushReferenced(brushnumber) )
		{
			CUtlVector<winding_t *> windings;

			for ( int i = 0; i < dbrushes[brushnumber].numsides; i++ )
			{
				dbrushside_t *pside = dbrushsides + i + dbrushes[brushnumber].firstside;
				if (pside->bevel)
					continue;
				dplane_t *pplane = dplanes + pside->planenum;
				winding_t *w = BaseWindingForPlane( pplane->normal, pplane->dist - m_shrink );
				for ( int j = 0; j < dbrushes[brushnumber].numsides && w; j++ )
				{
					if (i == j)
						continue;
					dbrushside_t *pClipSide = dbrushsides + j + dbrushes[brushnumber].firstside;
					if (pClipSide->bevel)
						continue;
					dplane_t *pClipPlane = dplanes + pClipSide->planenum;
					ChopWindingInPlace (&w, -pClipPlane->normal, -pClipPlane->dist+m_shrink, 0); //CLIP_EPSILON);
				}
				if ( w )
				{
					windings.AddToTail( w );
				}
			}

			CUtlVector<Vector *> vertList;
			for ( int p = 0; p < windings.Count(); p++ )
			{
				for ( int v = 0; v < windings[p]->numpoints; v++ )
				{
					vertList.AddToTail( windings[p]->p + v );
				}
			}
			CPhysConvex *pConvex = physcollision->ConvexFromVerts( vertList.Base(), vertList.Count() );
			if ( pConvex )
			{
				physcollision->SetConvexGameData( pConvex, brushnumber );
				AddConvex( pConvex );
			}
			temp.RemoveAll();
		}
	}
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:50,代码来源:ivp.cpp


示例11: CM_ValidateFacet

/*
==================
CM_ValidateFacet

If the facet isn't bounded by its borders, we screwed up.
==================
*/
static qboolean CM_ValidateFacet( facet_t *facet ) {
	planeDef_t	plane;
	int			j;
	winding_t	*w;
	bvec3_t		bounds[2];

	if ( facet->surfacePlane == -1 ) {
		return qfalse;
	}

	plane=planes[ facet->surfacePlane ].pd;
	w = BaseWindingForPlane( plane.normal,  plane.dist );
	for ( j = 0 ; j < facet->numBorders && w ; j++ ) {
		if ( facet->borderPlanes[j] == -1 ) {
			return qfalse;
		}
		plane=planes[ facet->borderPlanes[j] ].pd;
		if ( !facet->borderInward[j] ) {
			VectorSubtract( avec3_origin, plane.normal, plane.normal );
			plane.dist = -plane.dist;
		}
		ChopWindingInPlace( &w, plane.normal, plane.dist, BFIXED(0,1) );
	}

	if ( !w ) {
		return qfalse;		// winding was completely chopped away
	}

	// see if the facet is unreasonably large
	WindingBounds( w, bounds[0], bounds[1] );
	FreeWinding( w );
	
	for ( j = 0 ; j < 3 ; j++ ) {
		if ( bounds[1][j] - bounds[0][j] > BFIXED(MAX_MAP_BOUNDS,0) ) {
			return qfalse;		// we must be missing a plane
		}
		if ( bounds[0][j] >= BFIXED(MAX_MAP_BOUNDS,0) ) {
			return qfalse;
		}
		if ( bounds[1][j] <= -BFIXED(MAX_MAP_BOUNDS,0) ) {
			return qfalse;
		}
	}
	return qtrue;		// winding is fine
}
开发者ID:Jsoucek,项目名称:q3ce,代码行数:52,代码来源:cm_patch.cpp


示例12: BSPBrushWindings

//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void BSPBrushWindings(bspbrush_t *brush)
{
	int i, j;
	winding_t *w;
	plane_t *plane;

	for (i = 0; i < brush->numsides; i++)
	{
		plane = &mapplanes[brush->sides[i].planenum];
		w = BaseWindingForPlane(plane->normal, plane->dist);
		for (j = 0; j < brush->numsides && w; j++)
		{
			if (i == j) continue;
			plane = &mapplanes[brush->sides[j].planenum^1];
			ChopWindingInPlace(&w, plane->normal, plane->dist, 0); //CLIP_EPSILON);
		} //end for
		brush->sides[i].winding = w;
	} //end for
} //end of the function BSPBrushWindings
开发者ID:Cpasjuste,项目名称:quake3_pandora_gles,代码行数:25,代码来源:csg.c


示例13: Q1_FaceOnWinding

//===========================================================================
// returns the amount the face and the winding overlap
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
float Q1_FaceOnWinding(q1_dface_t *face, winding_t *winding)
{
    int i, edgenum, side;
    float dist, area;
    q1_dplane_t plane;
    vec_t *v1, *v2;
    vec3_t normal, edgevec;
    winding_t *w;

    //
    w = CopyWinding(winding);
    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
    for (i = 0; i < face->numedges && w; 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);
        //
        ChopWindingInPlace(&w, normal, dist, 0.9); //CLIP_EPSILON
    } //end for
    if (w)
    {
        area = WindingArea(w);
        FreeWinding(w);
        return area;
    } //end if
    return 0;
} //end of the function Q1_FaceOnWinding
开发者ID:he110world,项目名称:quake3-ios,代码行数:50,代码来源:map_q1.c


示例14: MakeBrushWindings

/**
 * @brief makes basewindings for sides and mins / maxs for the brush
 */
static bool MakeBrushWindings (mapbrush_t* brush)
{
	int i, j;

	brush->mbBox.setNegativeVolume();

	for (i = 0; i < brush->numsides; i++) {
		const plane_t* plane = &mapplanes[brush->original_sides[i].planenum];
		winding_t* w = BaseWindingForPlane(plane->normal, plane->dist);
		for (j = 0; j < brush->numsides && w; j++) {
			if (i == j)
				continue;
			/* back side clipaway */
			if (brush->original_sides[j].planenum == (brush->original_sides[j].planenum ^ 1))
				continue;
			if (brush->original_sides[j].bevel)
				continue;
			plane = &mapplanes[brush->original_sides[j].planenum ^ 1];
			ChopWindingInPlace(&w, plane->normal, plane->dist, 0); /*CLIP_EPSILON); */
		}

		side_t* side = &brush->original_sides[i];
		side->winding = w;
		if (w) {
			side->visible = true;
			for (j = 0; j < w->numpoints; j++)
				brush->mbBox.add(w->p[j]);
		}
	}

	for (i = 0; i < 3; i++) {
		if (brush->mbBox.mins[i] < -MAX_WORLD_WIDTH || brush->mbBox.maxs[i] > MAX_WORLD_WIDTH)
			Com_Printf("entity %i, brush %i: bounds out of world range (%f:%f)\n",
				brush->entitynum, brush->brushnum, brush->mbBox.mins[i], brush->mbBox.maxs[i]);
		if (brush->mbBox.mins[i] > MAX_WORLD_WIDTH || brush->mbBox.maxs[i] < -MAX_WORLD_WIDTH) {
			Com_Printf("entity %i, brush %i: no visible sides on brush\n", brush->entitynum, brush->brushnum);
			VectorClear(brush->mbBox.mins);
			VectorClear(brush->mbBox.maxs);
		}
	}

	return true;
}
开发者ID:nicogiraldi,项目名称:ufoai,代码行数:46,代码来源:map.cpp


示例15: MakeBrushWindings

/*
 * MakeBrushWindings
 *
 * Makes basewindigs for sides and mins / maxs for the brush
 */
static boolean_t MakeBrushWindings(map_brush_t * ob) {
	int i, j;
	side_t *side;

	ClearBounds(ob->mins, ob->maxs);

	for (i = 0; i < ob->num_sides; i++) {
		const map_plane_t *plane = &map_planes[ob->original_sides[i].plane_num];
		winding_t *w = BaseWindingForPlane(plane->normal, plane->dist);
		for (j = 0; j < ob->num_sides && w; j++) {
			if (i == j)
				continue;
			// back side clipaway
			if (ob->original_sides[j].plane_num
					== (ob->original_sides[j].plane_num ^ 1))
				continue;
			if (ob->original_sides[j].bevel)
				continue;
			plane = &map_planes[ob->original_sides[j].plane_num ^ 1];
			ChopWindingInPlace(&w, plane->normal, plane->dist, 0); //CLIP_EPSILON);
		}

		side = &ob->original_sides[i];
		side->winding = w;
		if (w) {
			side->visible = true;
			for (j = 0; j < w->numpoints; j++)
				AddPointToBounds(w->p[j], ob->mins, ob->maxs);
		}
	}

	for (i = 0; i < 3; i++) {
		if (ob->mins[0] < -MAX_WORLD_WIDTH || ob->maxs[0] > MAX_WORLD_WIDTH)
			Com_Verbose("entity %i, brush %i: bounds out of range\n",
					ob->entity_num, ob->brush_num);
		if (ob->mins[0] > MAX_WORLD_WIDTH || ob->maxs[0] < -MAX_WORLD_WIDTH)
			Com_Verbose("entity %i, brush %i: no visible sides on brush\n",
					ob->entity_num, ob->brush_num);
	}

	return true;
}
开发者ID:darkshade9,项目名称:aq2w,代码行数:47,代码来源:map.c


示例16: BaseWindingForPlane

//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
winding_t *AAS_SplitWinding( tmp_area_t *tmparea, int planenum ) {
	tmp_face_t *face;
	plane_t *plane;
	int side;
	winding_t *splitwinding;

	//
	plane = &mapplanes[planenum];
	//create a split winding, first base winding for plane
	splitwinding = BaseWindingForPlane( plane->normal, plane->dist );
	//chop with all the faces of the area
	for ( face = tmparea->tmpfaces; face && splitwinding; face = face->next[side] )
	{
		//side of the face the original area was on
		side = face->frontarea != tmparea;
		plane = &mapplanes[face->planenum ^ side];
		ChopWindingInPlace( &splitwinding, plane->normal, plane->dist, 0 ); // PLANESIDE_EPSILON);
	} //end for
	return splitwinding;
} //end of the function AAS_SplitWinding
开发者ID:AdrienJaguenet,项目名称:Enemy-Territory,代码行数:26,代码来源:aas_gsubdiv.c


示例17: CreateBrushWindings

/*
==================
CreateBrushWindings

makes basewindigs for sides and mins / maxs for the brush
returns false if the brush doesn't enclose a valid volume
==================
*/
qboolean CreateBrushWindings(bspBrush_t * brush)
{
	int             i, j;
	winding_t      *w;
	side_t         *side;
	plane_t        *plane;

	for(i = 0; i < brush->numsides; i++)
	{
		side = &brush->sides[i];
		// don't create a winding for a bevel
		if(side->bevel)
		{
			continue;
		}
		plane = &mapPlanes[side->planenum];
		w = BaseWindingForPlane(plane->normal, plane->dist);
		for(j = 0; j < brush->numsides && w; j++)
		{
			if(i == j)
				continue;
			if(brush->sides[j].planenum == (brush->sides[i].planenum ^ 1))
				continue;		// back side clipaway
			if(brush->sides[j].bevel)
				continue;
			if(brush->sides[j].backSide)
				continue;
			plane = &mapPlanes[brush->sides[j].planenum ^ 1];
			ChopWindingInPlace(&w, plane->normal, plane->dist, 0);	//CLIP_EPSILON);
		}
		// free any existing winding
		if(side->winding)
		{
			FreeWinding(side->winding);
		}
		side->winding = w;
	}

	return BoundBrush(brush);
}
开发者ID:otty,项目名称:cake3,代码行数:48,代码来源:brush.c


示例18: CM_AddFacetBevels

void CM_AddFacetBevels( facet_t *facet ) {

	int i, j, k, l;
	int axis, dir, order, flipped;
	float plane[4], d, newplane[4];
	winding_t *w, *w2;
	vec3_t mins, maxs, vec, vec2;

#ifndef ADDBEVELS
	return;
#endif

	Vector4Copy( planes[ facet->surfacePlane ].plane, plane );

	w = BaseWindingForPlane( plane,  plane[3] );
	for ( j = 0 ; j < facet->numBorders && w ; j++ ) {
		if ( facet->borderPlanes[j] == facet->surfacePlane ) {
			continue;
		}
		Vector4Copy( planes[ facet->borderPlanes[j] ].plane, plane );

		if ( !facet->borderInward[j] ) {
			VectorSubtract( vec3_origin, plane, plane );
			plane[3] = -plane[3];
		}

		ChopWindingInPlace( &w, plane, plane[3], 0.1f );
	}
	if ( !w ) {
		return;
	}

	WindingBounds( w, mins, maxs );

	// add the axial planes
	order = 0;
	for ( axis = 0 ; axis < 3 ; axis++ )
	{
		for ( dir = -1 ; dir <= 1 ; dir += 2, order++ )
		{
			VectorClear( plane );
			plane[axis] = dir;
			if ( dir == 1 ) {
				plane[3] = maxs[axis];
			} else {
				plane[3] = -mins[axis];
			}
			//if it's the surface plane
			if ( CM_PlaneEqual( &planes[facet->surfacePlane], plane, &flipped ) ) {
				continue;
			}
			// see if the plane is allready present
			for ( i = 0 ; i < facet->numBorders ; i++ ) {
				if ( CM_PlaneEqual( &planes[facet->borderPlanes[i]], plane, &flipped ) ) {
					break;
				}
			}

			if ( i == facet->numBorders ) {
				if ( facet->numBorders > 4 + 6 + 16 ) {
					Com_Printf( "ERROR: too many bevels\n" );
				}
				facet->borderPlanes[facet->numBorders] = CM_FindPlane2( plane, &flipped );
				facet->borderNoAdjust[facet->numBorders] = 0;
				facet->borderInward[facet->numBorders] = flipped;
				facet->numBorders++;
			}
		}
	}
	//
	// add the edge bevels
	//
	// test the non-axial plane edges
	for ( j = 0 ; j < w->numpoints ; j++ )
	{
		k = ( j + 1 ) % w->numpoints;
		VectorSubtract( w->p[j], w->p[k], vec );
		//if it's a degenerate edge
		if ( VectorNormalize( vec ) < 0.5 ) {
			continue;
		}
		CM_SnapVector( vec );
		for ( k = 0; k < 3 ; k++ )
			if ( vec[k] == -1 || vec[k] == 1 ) {
				break;
			}           // axial
		if ( k < 3 ) {
			continue;   // only test non-axial edges

		}
		// try the six possible slanted axials from this edge
		for ( axis = 0 ; axis < 3 ; axis++ )
		{
			for ( dir = -1 ; dir <= 1 ; dir += 2 )
			{
				// construct a plane
				VectorClear( vec2 );
				vec2[axis] = dir;
				CrossProduct( vec, vec2, plane );
				if ( VectorNormalize( plane ) < 0.5 ) {
//.........这里部分代码省略.........
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:101,代码来源:cm_patch.c


示例19: CM_DrawDebugSurface


//.........这里部分代码省略.........
			}

			plane[3] += cv->value;
			//*
			for ( n = 0; n < 3; n++ )
			{
				if ( plane[n] > 0 ) {
					v1[n] = maxs[n];
				} else { v1[n] = mins[n];}
			} //end for
			VectorNegate( plane, v2 );
			plane[3] += fabs( DotProduct( v1, v2 ) );
			//*/

			w = BaseWindingForPlane( plane,  plane[3] );
			for ( j = 0 ; j < facet->numBorders + 1 && w; j++ ) {
				//
				if ( j < facet->numBorders ) {
					curplanenum = facet->borderPlanes[j];
					curinward = facet->borderInward[j];
				} else {
					curplanenum = facet->surfacePlane;
					curinward = qfalse;
					//continue;
				}
				//
				if ( curplanenum == planenum ) {
					continue;
				}

				Vector4Copy( pc->planes[ curplanenum ].plane, plane );
				if ( !curinward ) {
					VectorSubtract( vec3_origin, plane, plane );
					plane[3] = -plane[3];
				}
				//			if ( !facet->borderNoAdjust[j] ) {
				plane[3] -= cv->value;
				//			}
				for ( n = 0; n < 3; n++ )
				{
					if ( plane[n] > 0 ) {
						v1[n] = maxs[n];
					} else { v1[n] = mins[n];}
				} //end for
				VectorNegate( plane, v2 );
				plane[3] -= fabs( DotProduct( v1, v2 ) );

				ChopWindingInPlace( &w, plane, plane[3], 0.1f );
			}
			if ( w ) {
				if ( facet == debugFacet ) {
					drawPoly( 4, w->numpoints, w->p[0] );
					//Com_Printf("blue facet has %d border planes\n", facet->numBorders);
				} else {
					drawPoly( 1, w->numpoints, w->p[0] );
				}
				FreeWinding( w );
			} else {
				Com_Printf( "winding chopped away by border planes\n" );
			}
		}
	}

	// draw the debug block
	{
		vec3_t v[3];

		VectorCopy( debugBlockPoints[0], v[0] );
		VectorCopy( debugBlockPoints[1], v[1] );
		VectorCopy( debugBlockPoints[2], v[2] );
		drawPoly( 2, 3, v[0] );

		VectorCopy( debugBlockPoints[2], v[0] );
		VectorCopy( debugBlockPoints[3], v[1] );
		VectorCopy( debugBlockPoints[0], v[2] );
		drawPoly( 2, 3, v[0] );
	}

#if 0
	vec3_t v[4];

	v[0][0] = pc->bounds[1][0];
	v[0][1] = pc->bounds[1][1];
	v[0][2] = pc->bounds[1][2];

	v[1][0] = pc->bounds[1][0];
	v[1][1] = pc->bounds[0][1];
	v[1][2] = pc->bounds[1][2];

	v[2][0] = pc->bounds[0][0];
	v[2][1] = pc->bounds[0][1];
	v[2][2] = pc->bounds[1][2];

	v[3][0] = pc->bounds[0][0];
	v[3][1] = pc->bounds[1][1];
	v[3][2] = pc->bounds[1][2];

	drawPoly( 4, v[0] );
#endif
}
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:101,代码来源:cm_patch.c


示例20: SplitBrush

void SplitBrush( bspbrush_t *brush, int planenum, bspbrush_t **front, bspbrush_t **back )
{
	bspbrush_t	*b[2];
	int			i, j;
	winding_t	*w, *cw[2], *midwinding;
	plane_t		*plane, *plane2;
	side_t		*s, *cs;
	float		d, d_front, d_back;

	*front = *back = NULL;
	plane = &g_MainMap->mapplanes[planenum];

	// check all points
	d_front = d_back = 0;
	for (i=0 ; i<brush->numsides ; i++)
	{
		w = brush->sides[i].winding;
		if (!w)
			continue;
		for (j=0 ; j<w->numpoints ; j++)
		{
			d = DotProduct (w->p[j], plane->normal) - plane->dist;
			if (d > 0 && d > d_front)
				d_front = d;
			if (d < 0 && d < d_back)
				d_back = d;
		}
	}

	if (d_front < 0.1) // PLANESIDE_EPSILON)
	{	// only on back
		*back = CopyBrush (brush);
		return;
	}
	if (d_back > -0.1) // PLANESIDE_EPSILON)
	{	// only on front
		*front = CopyBrush (brush);
		return;
	}


	// Move the CSG problem so that offset is at the origin
	// This gives us much better floating point precision in the clipping operations
	Vector offset = -0.5f * (brush->mins + brush->maxs);
	// create a new winding from the split plane

	w = BaseWindingForPlane (plane->normal, plane->dist + DotProduct(plane->normal,offset));
	for (i=0 ; i<brush->numsides && w ; i++)
	{
		plane2 = &g_MainMap->mapplanes[brush->sides[i].planenum ^ 1];
		ChopWindingInPlace (&w, plane2->normal, plane2->dist+DotProduct(plane2->normal,offset), 0); // PLANESIDE_EPSILON);
	}

	if (!w || WindingIsTiny (w) )
	{	// the brush isn't really split
		int		side;

		side = BrushMostlyOnSide (brush, plane);
		if (side == PSIDE_FRONT)
			*front = CopyBrush (brush);
		if (side == PSIDE_BACK)
			*back = CopyBrush (brush);
		return;
	}

	if (WindingIsHuge (w))
	{
		qprintf ("WARNING: huge winding\n");
	}

	TranslateWinding( w, -offset );
	midwinding = w;

    //
    //
	// split it for real
    //
    //

    //
    // allocate two new brushes referencing the original
    //
	for( i = 0; i < 2; i++ )
	{
		b[i] = AllocBrush( brush->numsides + 1 );
		b[i]->original = brush->original;
	}

    //
	// split all the current windings
    //
	for( i = 0; i < brush->numsides; i++ )
	{
        // get the current side
		s = &brush->sides[i];

        // get the sides winding
		w = s->winding;
		if( !w )
			continue;
//.........这里部分代码省略.........
开发者ID:wouterpleizier,项目名称:source-sdk-2013,代码行数:101,代码来源:brushbsp.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ ChrPtr函数代码示例发布时间:2022-05-30
下一篇:
C++ ChoosePixelFormat函数代码示例发布时间: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