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

Function MoveRoomFace

editor/roomkeypaddialog.cpp:812–862  ·  view source on GitHub ↗

moves a face of a room by a delta amount

Source from the content-addressed store, hash-verified

810
811// moves a face of a room by a delta amount
812void MoveRoomFace(room *rp, int facenum, float dx, float dy, float dz) {
813 matrix facematrix;
814 vector norm = -rp->faces[facenum].normal;
815
816 int face_list[MAX_FACES_PER_ROOM];
817 int portal_list[MAX_VERTS_PER_ROOM];
818 int i, t, ok_to_scale, k, touches_portal = 0;
819 int num_portal_verts;
820 int facecount = 0;
821 face *fp = &rp->faces[facenum];
822
823 ASSERT(rp->used > 0);
824 ASSERT(facenum >= 0 && facenum < rp->num_faces);
825
826 num_portal_verts = BuildListOfPortalVerts(rp, portal_list);
827
828 vm_VectorToMatrix(&facematrix, &norm, NULL, NULL);
829
830 for (i = 0; i < fp->num_verts; i++) {
831 for (ok_to_scale = 1, t = 0; t < num_portal_verts; t++) {
832 if (portal_list[t] == fp->face_verts[i]) {
833 ok_to_scale = 0;
834 touches_portal = 1;
835 }
836 }
837
838 if (ok_to_scale) {
839 rp->verts[fp->face_verts[i]] += (facematrix.rvec * dx);
840 rp->verts[fp->face_verts[i]] += (facematrix.uvec * dy);
841 rp->verts[fp->face_verts[i]] += (facematrix.fvec * dz);
842 }
843 }
844
845 // Build a list of faces that share vertices with this edge
846 for (i = 0; i < rp->num_faces; i++) {
847 if (i == facenum && touches_portal == 0)
848 continue;
849
850 for (t = 0; t < rp->faces[i].num_verts; t++) {
851 for (k = 0; k < fp->num_verts; k++) {
852 if (fp->face_verts[k] == rp->faces[i].face_verts[t]) {
853 face_list[facecount] = i;
854 facecount++;
855 }
856 }
857 }
858 }
859
860 // Now fixup any concave/nonplanar faces
861 FixConcaveFaces(rp, face_list, facecount);
862}
863
864void CRoomKeypadDialog::OnMarkRoom() { SetMarkedRoom(); }
865

Callers 6

OnRoompadMoveForwardMethod · 0.85
OnRoompadMoveBackwardMethod · 0.85
OnRoompadMoveRightMethod · 0.85
OnRoompadMoveLeftMethod · 0.85
OnRoompadMoveUpMethod · 0.85
OnRoompadMoveDownMethod · 0.85

Calls 3

BuildListOfPortalVertsFunction · 0.85
FixConcaveFacesFunction · 0.85
vm_VectorToMatrixFunction · 0.50

Tested by

no test coverage detected