void MakeFace (face_t *f) #endif { winding_t *w; int i; int pnum[128]; #ifdef NEWEDGESEL w = MakeFaceWinding (b, f); #else w = MakeFaceWinding (selected_brushes.next, f); #endif if (!w) return; for (i=0 ; i<w->numpoints ; i++) pnum[i] = FindPoint (w->points[i]); for (i=0 ; i<w->numpoints ; i++) FindEdge (pnum[i], pnum[(i+1)%w->numpoints], f); free (w); }
void SelectFaceEdge (face_t *f, int p1, int p2) #endif { winding_t *w; int i, j, k; int pnum[128]; #ifdef NEWEDGESEL w = MakeFaceWinding (b, f); #else w = MakeFaceWinding (selected_brushes.next, f); #endif if (!w) return; for (i=0 ; i<w->numpoints ; i++) pnum[i] = FindPoint (w->points[i]); for (i=0 ; i<w->numpoints ; i++) if (pnum[i] == p1 && pnum[(i+1)%w->numpoints] == p2) { VectorCopy (g_qeglobals.d_points[pnum[i]], f->planepts[0]); VectorCopy (g_qeglobals.d_points[pnum[(i+1)%w->numpoints]], f->planepts[1]); VectorCopy (g_qeglobals.d_points[pnum[(i+2)%w->numpoints]], f->planepts[2]); for (j=0 ; j<3 ; j++) { for (k=0 ; k<3 ; k++) { f->planepts[j][k] = floor(f->planepts[j][k]/g_qeglobals.d_gridsize+0.5)*g_qeglobals.d_gridsize; } } AddPlanept (f->planepts[0]); AddPlanept (f->planepts[1]); break; } if (i == w->numpoints) Sys_Printf ("SelectFaceEdge: failed\n"); free (w); }
void Brush_BuildWindings( brush_t *b ) { winding_t *w; face_t *face; vec_t v; Brush_SnapPlanepts( b ); // clear the mins/maxs bounds b->mins[0] = b->mins[1] = b->mins[2] = 99999; b->maxs[0] = b->maxs[1] = b->maxs[2] = -99999; Brush_MakeFacePlanes (b); face = b->brush_faces; for ( ; face ; face=face->next) { int i, j; w = face->face_winding = MakeFaceWinding (b, face); face->d_texture = Texture_ForName( face->texdef.name ); if (!w) { continue; } for (i=0 ; i<w->numpoints ; i++) { // add to bounding box for (j=0 ; j<3 ; j++) { v = w->points[i][j]; if (v > b->maxs[j]) b->maxs[j] = v; if (v < b->mins[j]) b->mins[j] = v; } } // setup s and t vectors, and set color BeginTexturingFace( b, face, face->d_texture); for(i = 0; i < w->numpoints; i++) EmitTextureCoordinates(w->points[i],face->d_texture,face); } }
/* Adds the faces planepts to move_points, and rotates and adds the planepts of adjacent face if shear is set */ void Brush_SelectFaceForDragging (brush_t *b, face_t *f, bool shear) { int i; face_t *f2; winding_t *w; float d; brush_t *b2; int c; if(b->owner->eclass->fixedsize) return; c = 0; for (i=0 ; i<3 ; i++) c += AddPlanept (f->planepts[i]); if (c == 0) return; // allready completely added // select all points on this plane in all brushes the selection for(b2 = selected_brushes.next; b2 != &selected_brushes; b2 = b2->next) { if (b2 == b) continue; for (f2=b2->brush_faces ; f2 ; f2=f2->next) { for (i=0 ; i<3 ; i++) if(fabs(Math_DotProduct(f2->planepts[i],f->plane.normal) -f->plane.dist) > ON_EPSILON) break; if(i == 3) { // move this face as well Brush_SelectFaceForDragging(b2, f2, shear); break; } } } // if shearing, take all the planes adjacent to // selected faces and rotate their points so the // edge clipped by a selcted face has two of the points if(!shear) return; for (f2=b->brush_faces ; f2 ; f2=f2->next) { if (f2 == f) continue; w = MakeFaceWinding (b, f2); if (!w) continue; // any points on f will become new control points for (i=0 ; i<w->numpoints ; i++) { d = Math_DotProduct(w->points[i],f->plane.normal)-f->plane.dist; if (d > -ON_EPSILON && d < ON_EPSILON) break; } // // if none of the points were on the plane, // leave it alone // if (i != w->numpoints) { if (i == 0) { // see if the first clockwise point was the // last point on the winding d = Math_DotProduct(w->points[w->numpoints-1],f->plane.normal)-f->plane.dist; if (d > -ON_EPSILON && d < ON_EPSILON) i = w->numpoints - 1; } AddPlanept (f2->planepts[0]); Math_VectorCopy(w->points[i],f2->planepts[0]); if (++i == w->numpoints) i = 0; // see if the next point is also on the plane d = Math_DotProduct(w->points[i] , f->plane.normal) - f->plane.dist; if (d > -ON_EPSILON && d < ON_EPSILON) AddPlanept (f2->planepts[1]); Math_VectorCopy(w->points[i],f2->planepts[1]); if (++i == w->numpoints) i = 0; // the third point is never on the plane Math_VectorCopy(w->points[i],f2->planepts[2]); } free(w); } }
void SelectVertex (int p1) { brush_t *b; winding_t *w; int i, j, k; face_t *f; #ifdef NEWEDGESEL for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next) { for (f=b->brush_faces ; f ; f=f->next) { w = MakeFaceWinding (b, f); if (!w) continue; for (i=0 ; i<w->numpoints ; i++) { if (FindPoint (w->points[i]) == p1) { VectorCopy (w->points[(i+w->numpoints-1)%w->numpoints], f->planepts[0]); VectorCopy (w->points[i], f->planepts[1]); VectorCopy (w->points[(i+1)%w->numpoints], f->planepts[2]); for (j=0 ; j<3 ; j++) { for (k=0 ; k<3 ; k++) { ;//f->planepts[j][k] = floor(f->planepts[j][k]/g_qeglobals.d_gridsize+0.5)*g_qeglobals.d_gridsize; } } AddPlanept (f->planepts[1]); //MessageBeep(-1); break; } } free (w); } } #else b = selected_brushes.next; for (f=b->brush_faces ; f ; f=f->next) { w = MakeFaceWinding (b, f); if (!w) continue; for (i=0 ; i<w->numpoints ; i++) { if (FindPoint (w->points[i]) == p1) { VectorCopy (w->points[(i+w->numpoints-1)%w->numpoints], f->planepts[0]); VectorCopy (w->points[i], f->planepts[1]); VectorCopy (w->points[(i+1)%w->numpoints], f->planepts[2]); for (j=0 ; j<3 ; j++) { for (k=0 ; k<3 ; k++) { ;//f->planepts[j][k] = floor(f->planepts[j][k]/g_qeglobals.d_gridsize+0.5)*g_qeglobals.d_gridsize; } } AddPlanept (f->planepts[1]); //MessageBeep(-1); break; } } free (w); } #endif }