Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

aas_edgemelting.c

Go to the documentation of this file.
00001 /*
00002 ===========================================================================
00003 Copyright (C) 1999-2005 Id Software, Inc.
00004 
00005 This file is part of Quake III Arena source code.
00006 
00007 Quake III Arena source code is free software; you can redistribute it
00008 and/or modify it under the terms of the GNU General Public License as
00009 published by the Free Software Foundation; either version 2 of the License,
00010 or (at your option) any later version.
00011 
00012 Quake III Arena source code is distributed in the hope that it will be
00013 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Foobar; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 ===========================================================================
00021 */
00022 
00023 #include "qbsp.h"
00024 #include "../botlib/aasfile.h"
00025 #include "aas_create.h"
00026 
00027 //===========================================================================
00028 // try to melt the windings of the two faces
00029 // FIXME: this is buggy
00030 //
00031 // Parameter:               -
00032 // Returns:                 -
00033 // Changes Globals:     -
00034 //===========================================================================
00035 int AAS_MeltFaceWinding(tmp_face_t *face1, tmp_face_t *face2)
00036 {
00037     int i, n;
00038     int splits = 0;
00039     winding_t *w2, *neww;
00040     plane_t *plane1;
00041 
00042 #ifdef DEBUG
00043     if (!face1->winding) Error("face1 %d without winding", face1->num);
00044     if (!face2->winding) Error("face2 %d without winding", face2->num);
00045 #endif //DEBUG
00046     w2 = face2->winding;
00047     plane1 = &mapplanes[face1->planenum];
00048     for (i = 0; i < w2->numpoints; i++)
00049     {
00050         if (PointOnWinding(face1->winding, plane1->normal, plane1->dist, w2->p[i], &n))
00051         {
00052             neww = AddWindingPoint(face1->winding, w2->p[i], n);
00053             FreeWinding(face1->winding);
00054             face1->winding = neww;
00055 
00056             splits++;
00057         } //end if
00058     } //end for
00059     return splits;
00060 } //end of the function AAS_MeltFaceWinding
00061 //===========================================================================
00062 // melt the windings of the area faces
00063 //
00064 // Parameter:               -
00065 // Returns:                 -
00066 // Changes Globals:     -
00067 //===========================================================================
00068 int AAS_MeltFaceWindingsOfArea(tmp_area_t *tmparea)
00069 {
00070     int side1, side2, num_windingsplits = 0;
00071     tmp_face_t *face1, *face2;
00072 
00073     for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1])
00074     {
00075         side1 = face1->frontarea != tmparea;
00076         for (face2 = tmparea->tmpfaces; face2; face2 = face2->next[side2])
00077         {
00078             side2 = face2->frontarea != tmparea;
00079             if (face1 == face2) continue;
00080             num_windingsplits += AAS_MeltFaceWinding(face1, face2);
00081         } //end for
00082     } //end for
00083     return num_windingsplits;
00084 } //end of the function AAS_MeltFaceWindingsOfArea
00085 //===========================================================================
00086 // melt the windings of the faces of all areas
00087 //
00088 // Parameter:               -
00089 // Returns:                 -
00090 // Changes Globals:     -
00091 //===========================================================================
00092 void AAS_MeltAreaFaceWindings(void)
00093 {
00094     tmp_area_t *tmparea;
00095     int num_windingsplits = 0;
00096 
00097     Log_Write("AAS_MeltAreaFaceWindings\r\n");
00098     qprintf("%6d edges melted", num_windingsplits);
00099     //NOTE: first convex area (zero) is a dummy
00100     for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)
00101     {
00102         num_windingsplits += AAS_MeltFaceWindingsOfArea(tmparea);
00103         qprintf("\r%6d", num_windingsplits);
00104     } //end for
00105     qprintf("\n");
00106     Log_Write("%6d edges melted\r\n", num_windingsplits);
00107 } //end of the function AAS_MeltAreaFaceWindings
00108 

Generated on Thu Aug 25 12:37:13 2005 for Quake III Arena by  doxygen 1.3.9.1