Changeset 48 for cafu/trunk/CaBSP/BspTreeBuilder/LeakDetection.cpp
- Timestamp:
- 04/13/10 17:06:34 (2 years ago)
- Files:
-
- 1 modified
-
cafu/trunk/CaBSP/BspTreeBuilder/LeakDetection.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cafu/trunk/CaBSP/BspTreeBuilder/LeakDetection.cpp
r36 r48 137 137 Console->Print("\n### LEAK DETECTED! ###\n\n"); 138 138 Console->Print("A leak is a hole in the world, where the inside of it is exposed to the\n"); 139 Console->Print("(unwanted) outside region. Thus, I generated a leak pointfile.\n");140 Console->Print("Load this file into your world editor, and find the beginning of the line.\n");139 Console->Print("(unwanted) outside region. Thus, a leak pointfile has been generated.\n"); 140 Console->Print("Load this file into the world editor CaWE, and find the beginning of the line.\n"); 141 141 Console->Print("Hint: The beginning is always near one of the \"info_player_start\" entities.\n"); 142 142 Console->Print("Then find and fix the leak by tracing the line until you reach the outside.\n"); 143 Console->Print("( I always takethe shortest path, so this should be easy.)\n");143 Console->Print("(The line always takes the shortest path, so this should be easy.)\n"); 144 144 Console->Print("\nNotes:\n"); 145 145 Console->Print("- Leaks can be *very* small. Use a close-up view, if necessary.\n"); 146 146 Console->Print("- Use the grid. The grid is useful to fix leaks + to avoid them from the start.\n"); 147 147 Console->Print("- Make sure that *all* \"info_player_start\" entities are inside the world!\n"); 148 Console->Print("- The pointfile assumes that WcMap2Ca.exe scaled the world by factor 25.4.\n");149 148 Console->Print("- Be aware that both the clip hull and the draw hull must be sealed.\n"); 150 149 Console->Print("- Please refer to the documentation for additional information.\n"); … … 154 153 ComputeLeakPathByBFS(InfoPlayerStartOrigin); 155 154 156 FILE* PointFile=fopen(PointFileName.c_str(), "w"); 155 std::ofstream PointFile(PointFileName.c_str()); 156 unsigned long PointCount=0; 157 157 158 if (!PointFile) Error("Could not open pointfile \"%s\" for writing!", PointFileName.c_str()); 158 159 159 // The following is also possible in a single big for-loop that does not require the 'Points' array. 160 // However, it would then be much more complicated to consider all the special cases when something goes wrong (see below). 161 // Thus, for clarity, I keep it simple, even at the cost of sub-optimal efficiency. 162 ArrayT<VectorT> Points; 160 PointFile << "Points=\n"; 161 PointFile << "{\n"; 163 162 164 163 // Let "S" be the start leaf that contains the 'InfoPlayerStartOrigin'. 165 // The following loop puts all the path points into the 'Points' array, including the 'InfoPlayerStartOrigin' of leaf "S".166 // Three cases are possible, and all of them are gracefully handled (that is much harder with a big loop!):164 // The following loop writes all the path points, including the 'InfoPlayerStartOrigin' of leaf "S". 165 // Three cases are possible, and all of them are gracefully handled: 167 166 // a) If "S" is NOT reachable from LeafNr, something is wrong (this is a bug!). 168 167 // The predecessor of LeafNr is -1, and therefore only a single point (0, 0, 0) gets written. … … 171 170 // c) In the normal case, as least two points are written into the 'Points' array. 172 171 for (unsigned long CurrentLeaf=LeafNr; CurrentLeaf!=(unsigned long)-1; CurrentLeaf=BFS_Tree[CurrentLeaf]) 173 Points.PushBack(scale(BFS_TreePoints[CurrentLeaf], 1.0/25.4)); 174 175 for (unsigned long PointNr=0; PointNr+1<Points.Size(); PointNr++) 176 { 177 VectorT V1=Points[PointNr ]; 178 VectorT d =Points[PointNr+1]-V1; 179 double l =length(d); 180 181 // Console->Print(cf::va("%5u %5u %f %f %f - %f %f %f\n", CurrentLeaf, NextLeaf, V1.x, V1.y, V1.z, V2.x, V2.y, V2.z)); 182 if (l<1.0) continue; 183 d=scale(normalize(d, 0.0), 2.0); 184 185 while (l>=0.0) 186 { 187 fprintf(PointFile, "%f %f %f\n", V1.x, V1.y, V1.z); 188 V1=V1+d; 189 l-=2.0; 190 } 191 } 192 193 fclose(PointFile); 194 195 if (Points.Size()<2) 172 { 173 const Vector3dT Point=BFS_TreePoints[CurrentLeaf]/25.4; 174 175 PointFile << " { "; 176 PointFile << PointCount << "; " << " "; // Time 177 PointFile << Point.x << ", "; 178 PointFile << Point.y << ", "; 179 PointFile << Point.z << "; " << " "; 180 PointFile << 0 << "; "; // Heading 181 PointFile << "\"leaf " << int(CurrentLeaf) << "\" },\n"; // Comment 182 183 PointCount++; 184 } 185 186 PointFile << "}\n"; 187 188 if (PointCount<2) 196 189 { 197 190 Console->Print("\nSorry, I have ANOTHER WARNING:\n"); … … 199 192 Console->Print(">> Did you really place all your \"info_player_start\" entities INSIDE the world?\n"); 200 193 Console->Print("If you did, and you still see this message, please send an email to\n"); 201 Console->Print(" CarstenFuchs@T-Online.de\n");202 Console->Print("Tell him about this message (best is to use copy & paste, or a screen-shot),\n");194 Console->Print("info@cafu.de\n"); 195 Console->Print("Tell them about this message (best is to use copy & paste, or a screen-shot),\n"); 203 196 Console->Print("and ideally, include this map as an attachment.\n"); 204 197 }
