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 int c_numprunes; 00028 00029 //=========================================================================== 00030 // 00031 // Parameter: - 00032 // Returns: - 00033 // Changes Globals: - 00034 //=========================================================================== 00035 tmp_node_t *AAS_PruneNodes_r(tmp_node_t *tmpnode) 00036 { 00037 tmp_area_t *tmparea1, *tmparea2; 00038 00039 //if it is a solid leaf 00040 if (!tmpnode) return NULL; 00041 // 00042 if (tmpnode->tmparea) return tmpnode; 00043 //process the children first 00044 tmpnode->children[0] = AAS_PruneNodes_r(tmpnode->children[0]); 00045 tmpnode->children[1] = AAS_PruneNodes_r(tmpnode->children[1]); 00046 //if both children are areas 00047 if (tmpnode->children[0] && tmpnode->children[1] && 00048 tmpnode->children[0]->tmparea && tmpnode->children[1]->tmparea) 00049 { 00050 tmparea1 = tmpnode->children[0]->tmparea; 00051 while(tmparea1->mergedarea) tmparea1 = tmparea1->mergedarea; 00052 00053 tmparea2 = tmpnode->children[1]->tmparea; 00054 while(tmparea2->mergedarea) tmparea2 = tmparea2->mergedarea; 00055 00056 if (tmparea1 == tmparea2) 00057 { 00058 c_numprunes++; 00059 tmpnode->tmparea = tmparea1; 00060 tmpnode->planenum = 0; 00061 AAS_FreeTmpNode(tmpnode->children[0]); 00062 AAS_FreeTmpNode(tmpnode->children[1]); 00063 tmpnode->children[0] = NULL; 00064 tmpnode->children[1] = NULL; 00065 return tmpnode; 00066 } //end if 00067 } //end if 00068 //if both solid leafs 00069 if (!tmpnode->children[0] && !tmpnode->children[1]) 00070 { 00071 c_numprunes++; 00072 AAS_FreeTmpNode(tmpnode); 00073 return NULL; 00074 } //end if 00075 // 00076 return tmpnode; 00077 } //end of the function AAS_PruneNodes_r 00078 //=========================================================================== 00079 // 00080 // Parameter: - 00081 // Returns: - 00082 // Changes Globals: - 00083 //=========================================================================== 00084 void AAS_PruneNodes(void) 00085 { 00086 Log_Write("AAS_PruneNodes\r\n"); 00087 AAS_PruneNodes_r(tmpaasworld.nodes); 00088 Log_Print("%6d nodes pruned\r\n", c_numprunes); 00089 } //end of the function AAS_PruneNodes
1.3.9.1