void SelectFaceEdge (brush_t* b, face_t *f, int p1, int p2) { winding_t *w; int i, j, k; int pnum[128]; w = Brush_MakeFaceWinding (b, f); 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 SelectFaceEdge (face_t * f, int p1, int p2) #endif { idWinding *w; int i, j, k; int pnum[128]; #ifdef NEWEDGESEL w = Brush_MakeFaceWinding(b, f); #else w = Brush_MakeFaceWinding(selected_brushes.next, f); #endif if (!w) { return; } for (i = 0; i < w->GetNumPoints(); i++) { pnum[i] = FindPoint( (*w)[i].ToVec3() ); } for (i = 0; i < w->GetNumPoints(); i++) { if (pnum[i] == p1 && pnum[(i + 1) % w->GetNumPoints()] == p2) { VectorCopy(g_qeglobals.d_points[pnum[i]], f->planepts[0]); VectorCopy(g_qeglobals.d_points[pnum[(i + 1) % w->GetNumPoints()]], f->planepts[1]); VectorCopy(g_qeglobals.d_points[pnum[(i + 2) % w->GetNumPoints()]], 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->GetNumPoints() ) { Sys_Status("SelectFaceEdge: failed\n"); } delete w; }
void SelectVertex (int p1) { brush_t *b; winding_t *w; int i, j, k; face_t *f; for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next) { for (f=b->brush_faces ; f ; f=f->next) { w = Brush_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); } } }
/* 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; idWinding *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 = Brush_MakeFaceWinding(b, f); if (!w) { continue; } for (i = 0; i < w->GetNumPoints(); i++) { if ( FindPoint( (*w)[i].ToVec3() ) == p1 ) { VectorCopy((*w)[(i + w->GetNumPoints() - 1) % w->GetNumPoints()], f->planepts[0]); VectorCopy((*w)[i], f->planepts[1]); VectorCopy((*w)[(i + 1) % w->GetNumPoints()], 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; } } delete w; } } #else b = selected_brushes.next; for (f = b->brush_faces; f; f = f->next) { w = Brush_MakeFaceWinding(b, f); if (!w) { continue; } for (i = 0; i < w->GetNumPoints(); i++) { if (FindPoint(w[i]) == p1) { VectorCopy(w[(i + w->GetNumPoints() - 1) % w->GetNumPoints()], f->planepts[0]); VectorCopy(w[i], f->planepts[1]); VectorCopy(w[(i + 1) % w->GetNumPoints()], 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; } } delete w; } #endif }