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

leakfile.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 
00025 /*
00026 ==============================================================================
00027 
00028 LEAF FILE GENERATION
00029 
00030 Save out name.line for qe3 to read
00031 ==============================================================================
00032 */
00033 
00034 
00035 /*
00036 =============
00037 LeakFile
00038 
00039 Finds the shortest possible chain of portals
00040 that leads from the outside leaf to a specifically
00041 occupied leaf
00042 =============
00043 */
00044 void LeakFile (tree_t *tree)
00045 {
00046     vec3_t  mid;
00047     FILE    *linefile;
00048     char    filename[1024];
00049     node_t  *node;
00050     int     count;
00051 
00052     if (!tree->outside_node.occupied)
00053         return;
00054 
00055     qprintf ("--- LeakFile ---\n");
00056 
00057     //
00058     // write the points to the file
00059     //
00060     sprintf (filename, "%s.lin", source);
00061     qprintf ("%s\n", filename);
00062     linefile = fopen (filename, "w");
00063     if (!linefile)
00064         Error ("Couldn't open %s\n", filename);
00065 
00066     count = 0;
00067     node = &tree->outside_node;
00068     while (node->occupied > 1)
00069     {
00070         int         next;
00071         portal_t    *p, *nextportal;
00072         node_t      *nextnode;
00073         int         s;
00074 
00075         // find the best portal exit
00076         next = node->occupied;
00077         for (p=node->portals ; p ; p = p->next[!s])
00078         {
00079             s = (p->nodes[0] == node);
00080             if (p->nodes[s]->occupied
00081                 && p->nodes[s]->occupied < next)
00082             {
00083                 nextportal = p;
00084                 nextnode = p->nodes[s];
00085                 next = nextnode->occupied;
00086             }
00087         }
00088         node = nextnode;
00089         WindingCenter (nextportal->winding, mid);
00090         fprintf (linefile, "%f %f %f\n", mid[0], mid[1], mid[2]);
00091         count++;
00092     }
00093     // add the occupant center
00094     GetVectorForKey (node->occupant, "origin", mid);
00095 
00096     fprintf (linefile, "%f %f %f\n", mid[0], mid[1], mid[2]);
00097     qprintf ("%5i point linefile\n", count+1);
00098 
00099     fclose (linefile);
00100 }
00101 

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