Creates a an external room and links the specified faces to it Parameters: rp - the room to connect to the new room nfaces - how many faces connect to the new room (this becomes the number of portals) facenums - the list of faces to connect
| 2837 | // nfaces - how many faces connect to the new room (this becomes the number of |
| 2838 | //portals) facenums - the list of faces to connect |
| 2839 | void LinkToExternalRoom(room *rp, int nfaces, int *facenums) { |
| 2840 | int vert_xlate[MAX_VERTS_PER_ROOM]; |
| 2841 | int v, i, nverts = 0; |
| 2842 | |
| 2843 | for (i = 0; i < rp->num_verts; i++) |
| 2844 | vert_xlate[i] = -1; |
| 2845 | |
| 2846 | for (i = 0; i < nfaces; i++) { |
| 2847 | face *fp = &rp->faces[facenums[i]]; |
| 2848 | |
| 2849 | for (v = 0; v < fp->num_verts; v++) { |
| 2850 | int vertnum = fp->face_verts[v]; |
| 2851 | if (vert_xlate[vertnum] == -1) |
| 2852 | vert_xlate[vertnum] = nverts++; |
| 2853 | } |
| 2854 | } |
| 2855 | |
| 2856 | room *newrp = CreateNewRoom(nverts, nfaces); |
| 2857 | |
| 2858 | newrp->flags |= RF_EXTERNAL; |
| 2859 | |
| 2860 | for (i = 0; i < rp->num_verts; i++) { |
| 2861 | if (vert_xlate[i] != -1) |
| 2862 | newrp->verts[vert_xlate[i]] = rp->verts[i]; |
| 2863 | } |
| 2864 | |
| 2865 | for (i = 0; i < nfaces; i++) { |
| 2866 | face *newfp = &newrp->faces[i], *fp = &rp->faces[facenums[i]]; |
| 2867 | |
| 2868 | InitRoomFace(newfp, fp->num_verts); |
| 2869 | |
| 2870 | for (v = 0; v < fp->num_verts; v++) |
| 2871 | newfp->face_verts[v] = vert_xlate[fp->face_verts[fp->num_verts - v - 1]]; |
| 2872 | |
| 2873 | #ifndef NEWEDITOR |
| 2874 | newfp->tmap = fp->tmap; |
| 2875 | #else |
| 2876 | // Apply texture |
| 2877 | HTextureApplyToRoomFace(newrp, i, newfp->tmap); |
| 2878 | #endif |
| 2879 | |
| 2880 | if (!ComputeFaceNormal(newrp, i)) |
| 2881 | Int3(); |
| 2882 | |
| 2883 | LinkRooms(Rooms, ROOMNUM(rp), facenums[i], ROOMNUM(newrp), i); |
| 2884 | } |
| 2885 | |
| 2886 | AssignDefaultUVsToRoom(newrp); |
| 2887 | |
| 2888 | World_changed = 1; |
| 2889 | } |
| 2890 | |
| 2891 | extern bool Disable_editor_rendering; |
| 2892 |
no test coverage detected