MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DeleteVert

Function DeleteVert

editor/HRoom.cpp:3018–3055  ·  view source on GitHub ↗

Deletes a vertex from an face Only deletes if the two adjacent edges are colinear, and there isn't a T-joint at this point

Source from the content-addressed store, hash-verified

3016// Deletes a vertex from an face
3017// Only deletes if the two adjacent edges are colinear, and there isn't a T-joint at this point
3018void DeleteVert(room *rp, int facenum, int vertnum) {
3019 face *fp = &rp->faces[facenum];
3020 vector normal;
3021 float mag;
3022 int f0, f1;
3023 int prev_vertnum = (vertnum + fp->num_verts - 1) % fp->num_verts;
3024
3025 mag = vm_GetNormal(&normal, &rp->verts[fp->face_verts[prev_vertnum]], &rp->verts[fp->face_verts[vertnum]],
3026 &rp->verts[fp->face_verts[(vertnum + 1) % fp->num_verts]]);
3027
3028 if (mag >= MIN_NORMAL_MAG) {
3029 OutrageMessageBox("Can't remove point: edges aren't colinear.");
3030 return;
3031 }
3032
3033 // Make sure there isn't a t-joint at this face
3034 f0 = FindConnectedFace(rp, facenum, prev_vertnum, 0);
3035 f1 = FindConnectedFace(rp, facenum, vertnum, 0);
3036 if ((f0 != -1) && (f1 != -1) && (f0 != f1)) {
3037 OutrageMessageBox("Can't delete vertex: apparent T-joint with faces %d & %d\n", f0, f1);
3038 return;
3039 }
3040
3041 // Delete the point on our passed face
3042 DeletePointFromFace(rp, facenum, vertnum);
3043
3044 // Delete the point on the connected face
3045 face *fp2 = &rp->faces[f0];
3046 for (int v2 = 0; v2 < fp2->num_verts; v2++)
3047 if (fp2->face_verts[v2] == fp->face_verts[vertnum])
3048 break;
3049 ASSERT(v2 < fp2->num_verts);
3050 DeletePointFromFace(rp, f0, v2);
3051
3052#ifndef NEWEDITOR
3053 World_changed = 1;
3054#endif
3055}
3056
3057// Moves a vertex along its two adjacent edges
3058// Only moves if the two adjacent edges are colinear

Callers 1

Calls 4

OutrageMessageBoxFunction · 0.85
FindConnectedFaceFunction · 0.85
DeletePointFromFaceFunction · 0.85
vm_GetNormalFunction · 0.50

Tested by

no test coverage detected