本文整理匯總了C++中ChopWindingInPlace函數的典型用法代碼示例。如果您正苦於以下問題:C++ ChopWindingInPlace函數的具體用法?C++ ChopWindingInPlace怎麽用?C++ ChopWindingInPlace使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ChopWindingInPlace函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
示例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;
}
示例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
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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
}
示例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]);
}
示例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();
}
}
}
示例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
}
示例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
示例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
示例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;
}
示例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;
}