Splits a face into two pieces Parameters: rp,facenum - the face to split v0,v1 - the two verts that will form the new edge
| 2894 | // Parameters: rp,facenum - the face to split |
| 2895 | // v0,v1 - the two verts that will form the new edge |
| 2896 | void SplitFace(room *rp, int facenum, int v0, int v1) { |
| 2897 | face *fp = &rp->faces[facenum], *nfp; |
| 2898 | int first_new_face, i; |
| 2899 | |
| 2900 | if (v0 == v1) { |
| 2901 | OutrageMessageBox("You cannot split a face using the same point twice."); |
| 2902 | return; |
| 2903 | } |
| 2904 | |
| 2905 | if (v1 < v0) { |
| 2906 | int t = v1; |
| 2907 | v1 = v0; |
| 2908 | v0 = t; |
| 2909 | } |
| 2910 | |
| 2911 | if (v1 == (v0 + 1) % fp->num_verts) { |
| 2912 | OutrageMessageBox("You cannot split a face using two adjacent points."); |
| 2913 | return; |
| 2914 | } |
| 2915 | |
| 2916 | if (fp->num_verts == 3) { |
| 2917 | OutrageMessageBox("Face %d has three verts and cannot be split.", facenum); |
| 2918 | return; |
| 2919 | } |
| 2920 | |
| 2921 | if (fp->portal_num != -1) { |
| 2922 | OutrageMessageBox("You cannot split a face that's part of a portal."); |
| 2923 | return; |
| 2924 | } |
| 2925 | |
| 2926 | if (fp->flags & (FF_HAS_TRIGGER + FF_FLOATING_TRIG)) { |
| 2927 | OutrageMessageBox("You cannot split a face that has a trigger."); |
| 2928 | return; |
| 2929 | } |
| 2930 | |
| 2931 | Disable_editor_rendering = 1; |
| 2932 | |
| 2933 | // Add new faces |
| 2934 | first_new_face = RoomAddFaces(rp, 2); |
| 2935 | |
| 2936 | // Reset pointer to our old face |
| 2937 | fp = &rp->faces[facenum]; |
| 2938 | |
| 2939 | // Set up each face |
| 2940 | bool ok[2]; |
| 2941 | for (i = 0, nfp = &rp->faces[first_new_face]; i < 2; i++, nfp++) { |
| 2942 | int nv, startv; |
| 2943 | |
| 2944 | if (i == 0) { |
| 2945 | nv = v1 - v0 + 1; |
| 2946 | startv = v0; |
| 2947 | } else { |
| 2948 | nv = fp->num_verts - (v1 - v0) + 1; |
| 2949 | startv = v1; |
| 2950 | } |
| 2951 | |
| 2952 | InitRoomFace(nfp, nv); |
| 2953 |
no test coverage detected