/* Frees the brush with all of its faces and display list. Unlinks the brush from whichever chain it is in. Decrements the owner entity's brushcount. Removes owner entity if this was the last brush unless owner is the world. */ void Brush_Free (brush_t *b) { face_t *f, *next; // free faces for (f=b->brush_faces ; f ; f=next) { next = f->next; Face_Free( f ); } /* for ( i = 0; i < b->d_numwindings; i++ ) { if ( b->d_windings[i] ) { FreeWinding( b->d_windings[i] ); b->d_windings[i] = 0; } } */ // unlink from active/selected list if (b->next) Brush_RemoveFromList (b); // unlink from entity list if (b->onext) Entity_UnlinkBrush (b); free (b); }
/* ================ Curve_StripFakePlanes Strips out any fakeplanes ================ */ void Curve_StripFakePlanes( brush_t *b ) { face_t *f; face_t **ptr; //, **next; // remove any CURVE_FAKE faces for ( ptr = &b->brush_faces ; *ptr ; ) { f = *ptr; if ( f->texdef.flags & SURF_CURVE_FAKE ) { *ptr = f->next; Face_Free( f ); } else { ptr = &f->next; } } }
/* Frees any overconstraining faces */ void Brush_RemoveEmptyFaces(brush_t *b) { face_t *f,*next; f = b->brush_faces; b->brush_faces = NULL; for ( ; f ; f=next) { next = f->next; if (!f->face_winding) Face_Free (f); else { f->next = b->brush_faces; b->brush_faces = f; } } }
void WINAPI QERApp_DeleteFace(LPVOID pv, int nFaceIndex) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); int n = 0; brush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle(pv); if (pBrush != NULL) { face_t *pPrev = pBrush->brush_faces; for (face_t *f = pBrush->brush_faces; f; f = f->next) { if (n == nFaceIndex) { pPrev->next = f->next; Face_Free (f); Sys_MarkMapModified(); // PGM return; } n++; pPrev = f; } } }
void WrapFaces( face_t* top, face_t* bottom) { face_t* tempFace; int i; float maxX; float maxY; int pointFlag; tempFace = Face_Alloc(); //wrap the top face points the other way CopyFace(top, tempFace); for ( i = 0; i<top->face_winding->numpoints; i++) { VectorCopy(top->face_winding->points[top->face_winding->numpoints-1-i],tempFace->face_winding->points[i]); } CopyFace(tempFace,top); // top and bottom are now wrapped with normals pointing upward // now grab the point in top with most positive x (and y if there are more than one) maxX = top->face_winding->points[0][0]; maxY = top->face_winding->points[0][1]; pointFlag = 0; for ( i = 1; i<top->face_winding->numpoints; i++) { if ( maxX > top->face_winding->points[i][0] ) { continue; } else { if ( maxX == top->face_winding->points[i][0] ) { if (top->face_winding->points[i][1] > maxY) { maxY = top->face_winding->points[i][1]; pointFlag = i; } } else { maxX = top->face_winding->points[i][0]; maxY = top->face_winding->points[i][1]; pointFlag = i; } } } // now, starting at the point[pointflag] in top, write the sequence starting at [0] in tempFace for ( i = 0; i<top->face_winding->numpoints; i++) { if (pointFlag == top->face_winding->numpoints) { pointFlag = 0; } VectorCopy(top->face_winding->points[pointFlag], tempFace->face_winding->points[i]); pointFlag++; } CopyFace(tempFace,top); //repeat with bottom CopyFace(bottom, tempFace); maxX = bottom->face_winding->points[0][0]; maxY = bottom->face_winding->points[0][1]; pointFlag = 0; for ( i = 1; i<bottom->face_winding->numpoints; i++) { if ( maxX > bottom->face_winding->points[i][0] ) { continue; } else { if ( maxX == bottom->face_winding->points[i][0] ) { if (bottom->face_winding->points[i][1] > maxY) { maxY = bottom->face_winding->points[i][1]; pointFlag = i; } } else { maxX = bottom->face_winding->points[i][0]; maxY = bottom->face_winding->points[i][1]; pointFlag = i; } } } // now, starting at the point[pointflag] in bottom, write the sequence starting at [0] in tempFace for ( i = 0; i<bottom->face_winding->numpoints; i++) { if (pointFlag == bottom->face_winding->numpoints) { pointFlag = 0; } VectorCopy(bottom->face_winding->points[pointFlag], tempFace->face_winding->points[i]); pointFlag++; } CopyFace(tempFace,bottom); Face_Free(tempFace); return; }