aas_edgemelting.c (3620B)
1 /* 2 =========================================================================== 3 Copyright (C) 1999-2005 Id Software, Inc. 4 5 This file is part of Quake III Arena source code. 6 7 Quake III Arena source code is free software; you can redistribute it 8 and/or modify it under the terms of the GNU General Public License as 9 published by the Free Software Foundation; either version 2 of the License, 10 or (at your option) any later version. 11 12 Quake III Arena source code is distributed in the hope that it will be 13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with Foobar; if not, write to the Free Software 19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 =========================================================================== 21 */ 22 23 #include "qbsp.h" 24 #include "../botlib/aasfile.h" 25 #include "aas_create.h" 26 27 //=========================================================================== 28 // try to melt the windings of the two faces 29 // FIXME: this is buggy 30 // 31 // Parameter: - 32 // Returns: - 33 // Changes Globals: - 34 //=========================================================================== 35 int AAS_MeltFaceWinding(tmp_face_t *face1, tmp_face_t *face2) 36 { 37 int i, n; 38 int splits = 0; 39 winding_t *w2, *neww; 40 plane_t *plane1; 41 42 #ifdef DEBUG 43 if (!face1->winding) Error("face1 %d without winding", face1->num); 44 if (!face2->winding) Error("face2 %d without winding", face2->num); 45 #endif //DEBUG 46 w2 = face2->winding; 47 plane1 = &mapplanes[face1->planenum]; 48 for (i = 0; i < w2->numpoints; i++) 49 { 50 if (PointOnWinding(face1->winding, plane1->normal, plane1->dist, w2->p[i], &n)) 51 { 52 neww = AddWindingPoint(face1->winding, w2->p[i], n); 53 FreeWinding(face1->winding); 54 face1->winding = neww; 55 56 splits++; 57 } //end if 58 } //end for 59 return splits; 60 } //end of the function AAS_MeltFaceWinding 61 //=========================================================================== 62 // melt the windings of the area faces 63 // 64 // Parameter: - 65 // Returns: - 66 // Changes Globals: - 67 //=========================================================================== 68 int AAS_MeltFaceWindingsOfArea(tmp_area_t *tmparea) 69 { 70 int side1, side2, num_windingsplits = 0; 71 tmp_face_t *face1, *face2; 72 73 for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1]) 74 { 75 side1 = face1->frontarea != tmparea; 76 for (face2 = tmparea->tmpfaces; face2; face2 = face2->next[side2]) 77 { 78 side2 = face2->frontarea != tmparea; 79 if (face1 == face2) continue; 80 num_windingsplits += AAS_MeltFaceWinding(face1, face2); 81 } //end for 82 } //end for 83 return num_windingsplits; 84 } //end of the function AAS_MeltFaceWindingsOfArea 85 //=========================================================================== 86 // melt the windings of the faces of all areas 87 // 88 // Parameter: - 89 // Returns: - 90 // Changes Globals: - 91 //=========================================================================== 92 void AAS_MeltAreaFaceWindings(void) 93 { 94 tmp_area_t *tmparea; 95 int num_windingsplits = 0; 96 97 Log_Write("AAS_MeltAreaFaceWindings\r\n"); 98 qprintf("%6d edges melted", num_windingsplits); 99 //NOTE: first convex area (zero) is a dummy 100 for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next) 101 { 102 num_windingsplits += AAS_MeltFaceWindingsOfArea(tmparea); 103 qprintf("\r%6d", num_windingsplits); 104 } //end for 105 qprintf("\n"); 106 Log_Write("%6d edges melted\r\n", num_windingsplits); 107 } //end of the function AAS_MeltAreaFaceWindings 108