- Timestamp:
- 09/03/06 03:13:29 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1313 r1314 619 619 float volBack = volLeft; 620 620 float volFront = volRight; 621 622 621 float newRenderCost = nTotalObjects * totalVol; 623 622 623 #ifdef _DEBUG 624 const int leaves = mBvhStats.Leaves(); 625 const bool printStats = ((axis == 0) && (leaves > 0) && (leaves < 90)); 626 627 ofstream sumStats; 628 ofstream vollStats; 629 ofstream volrStats; 630 631 if (printStats) 632 { 633 char str[64]; 634 sprintf(str, "tmp/bvh_heur_sum-%04d.log", leaves); 635 sumStats.open(str); 636 sprintf(str, "tmp/bvh_heur_voll-%04d.log", leaves); 637 vollStats.open(str); 638 sprintf(str, "tmp/bvh_heur_volr-%04d.log", leaves); 639 volrStats.open(str); 640 } 641 #endif 624 642 625 643 ///////////////////////////// … … 647 665 volRight * (float)nObjectsRight; 648 666 667 #ifdef _DEBUG 668 669 if (printStats) 670 { 671 sumStats 672 << "#Position\n" << nObjectsRight << endl 673 << "#Sum\n" << sum / viewSpaceVol << endl 674 << "#Vol\n" << (volLeft + volRight) / viewSpaceVol << endl; 675 676 vollStats 677 << "#Position\n" << nObjectsRight << endl 678 << "#Vol\n" << volLeft / viewSpaceVol << endl; 679 680 volrStats 681 << "#Position\n" << nObjectsRight << endl 682 << "#Vol\n" << volRight / viewSpaceVol << endl; 683 } 684 #endif 685 649 686 if (sum < newRenderCost) 650 687 { … … 675 712 const float ratio = newRenderCost / oldRenderCost; 676 713 714 #ifdef _DEBUG 677 715 Debug << "\n§§§§ eval local cost §§§§" << endl 678 716 << "back pvs: " << (int)objectsBack.size() << " front pvs: " << (int)objectsFront.size() << " total pvs: " << nTotalObjects << endl … … 680 718 << "old rc: " << oldRenderCost / viewSpaceVol << " new rc: " << newRenderCost / viewSpaceVol << endl 681 719 << "render cost decrease: " << oldRenderCost / viewSpaceVol - newRenderCost / viewSpaceVol << endl; 720 #endif 682 721 683 722 return ratio; -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1311 r1314 2426 2426 "0"); 2427 2427 2428 2429 2428 RegisterOption("Hierarchy.Construction.minDepthForOsp", 2430 2429 optInt, … … 2432 2431 "-1"); 2433 2432 2433 RegisterOption("Hierarchy.Construction.repairQueue", 2434 optBool, 2435 "hierarchy_construction_repair_queue=", 2436 "true"); 2434 2437 2435 2438 ////////////////////////////////////////////////////////////////////////////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1313 r1314 105 105 "Hierarchy.Construction.minDepthForOsp", mMinDepthForObjectSpaceSubdivion); 106 106 107 Environment::GetSingleton()->GetBoolValue( 108 "Hierarchy.Construction.repairQueue", mRepairQueue); 109 107 110 Debug << "******** Hierachy Manager Parameters ***********" << endl; 108 111 Debug << "max leaves: " << mTermMaxLeaves << endl; 109 112 Debug << "min global cost ratio: " << mTermMinGlobalCostRatio << endl; 110 113 Debug << "global cost miss tolerance: " << mTermGlobalCostMissTolerance << endl; 114 Debug << "construction type: " << mConstructionType << endl; 115 Debug << "min depth for object space subdivision: " << mMinDepthForObjectSpaceSubdivion << endl; 116 Debug << "repair queue: " << mRepairQueue << endl; 111 117 } 112 118 … … 343 349 PrepareViewSpaceSubdivision(sampleRays, objects, forcedViewSpace); 344 350 345 //const bool repairQueue = false;346 const bool repairQueue = true;347 cout << "here55 " << mVspTree->mVspStats.maxDepth << " (" << mMinDepthForObjectSpaceSubdivion << ") " << endl;348 351 // start object space subdivision immediately? 349 352 if (StartObjectSpaceSubdivision()) … … 379 382 // reevaluate candidates affected by the split for view space splits, 380 383 // this would be object space splits and other way round 381 if ( repairQueue) RepairQueue();384 if (mRepairQueue) RepairQueue(); 382 385 } 383 386 … … 386 389 if (StartObjectSpaceSubdivision()) 387 390 { 391 mObjectSpaceSubdivisionType = savedObjectSpaceSubdivisionType; 392 393 cout << "starting object space subdivision at maximal view space subdivison depth " << mVspTree->mVspStats.maxDepth << " (" << mMinDepthForObjectSpaceSubdivion << ") " << endl; 394 PrepareObjectSpaceSubdivision(sampleRays, objects); 395 388 396 cout << "reseting queue ... "; 389 397 ResetQueue(); 390 398 cout << "finished" << endl; 391 392 cout << "starting object space subdivision at maximal view space subdivison depth " << mVspTree->mVspStats.maxDepth << " (" << mMinDepthForObjectSpaceSubdivion << ") " << endl;393 394 mObjectSpaceSubdivisionType = savedObjectSpaceSubdivisionType;395 PrepareObjectSpaceSubdivision(sampleRays, objects);396 399 } 397 400 -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1313 r1314 292 292 int mTermMaxLeaves; 293 293 ofstream mSubdivisionStats; 294 295 bool mRepairQueue; 294 296 }; 295 297 -
GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h
r1293 r1314 63 63 OGRE_MESH_INSTANCE, 64 64 KD_INTERSECTABLE, 65 BVH_INTERSECTABLE 65 BVH_INTERSECTABLE, 66 FACE_INTERSECTABLE 66 67 }; 67 68 -
GTP/trunk/Lib/Vis/Preprocessing/src/KdIntersectable.h
r1233 r1314 11 11 class KdNode; 12 12 class BvhNode; 13 struct Face; 14 13 15 14 16 /** … … 57 59 T *mItem; 58 60 }; 61 59 62 60 63 template<typename T> … … 161 164 }; 162 165 166 class FaceIntersectable: public IntersectableWrapper<Face> 167 { 168 public: 169 FaceIntersectable(Face *item): 170 IntersectableWrapper<Face>(item) {} 171 172 int Type() const 173 { 174 return Intersectable::FACE_INTERSECTABLE; 175 } 176 }; 177 178 163 179 } 164 180 -
GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.cpp
r1292 r1314 13 13 #include "Environment.h" 14 14 #include "ResourceManager.h" 15 15 #include "KdIntersectable.h" 16 16 17 17 … … 93 93 94 94 // correct face index (nust be relative to start of verices) 95 (*vit) = distance(hashTable.begin(), hit);95 (*vit) = (int)distance(hashTable.begin(), hit); 96 96 //Debug << "new idx: " << (*vit) << endl; 97 97 } … … 185 185 Face *face = LoadFace(str, vertices, hashTable); 186 186 if (!face) break; 187 187 #if 1 188 188 faces.push_back(face); 189 190 189 if (faces.size() >= nMaxFaces) 191 190 { … … 197 196 198 197 if (parents) 199 {200 198 AssociateFacesWithInstance(mi, *parents); 201 } 202 199 203 200 // reset tables 204 201 hashTable.clear(); 205 202 faces.clear(); 206 203 } 204 #else 205 root->mGeometry.push_back(new FaceIntersectable(face)); 206 hashTable.clear(); 207 #endif 207 208 break; 208 } 209 } // end face 209 210 default: 210 211 break; 211 212 } 212 213 213 } 214 214 215 215 // there could be faces remaining 216 if ( 1 &&!faces.empty())216 if (!faces.empty()) 217 217 { 218 218 Mesh *mesh = CreateMesh(faces, hashTable); … … 222 222 223 223 if (parents) 224 {225 224 AssociateFacesWithInstance(mi, *parents); 226 } 227 225 228 226 root->mGeometry.push_back(mi); 229 227 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1313 r1314 973 973 mLocalSubdivisionCandidates->clear(); 974 974 975 int requestedSize = 2 * (int)(rays.size());975 const int requestedSize = 2 * (int)(rays.size()); 976 976 977 977 // creates a sorted split candidates array … … 992 992 { 993 993 const bool positive = (*rit).mRay->HasPosDir(axis); 994 994 const bool delayMinEvent = false; 995 996 // origin point 995 997 pos = (*rit).ExtrapOrigin(axis); 996 997 mLocalSubdivisionCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMin : SortableEntry::ERayMax, 998 pos, (*rit).mRay)); 999 998 const int oType = positive ? SortableEntry::ERayMin : SortableEntry::ERayMax; 999 1000 if (delayMinEvent && oType == SortableEntry::ERayMin) 1001 pos += mEpsilon; // for walls 1002 1003 mLocalSubdivisionCandidates->push_back(SortableEntry(oType, pos, (*rit).mRay)); 1004 1005 // termination point 1000 1006 pos = (*rit).ExtrapTermination(axis); 1001 1002 mLocalSubdivisionCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMax : SortableEntry::ERayMin, 1003 pos, (*rit).mRay)); 1007 const int tType = positive ? SortableEntry::ERayMax : SortableEntry::ERayMin; 1008 1009 if (delayMinEvent && tType == SortableEntry::ERayMin) 1010 pos += mEpsilon; // for walls 1011 1012 mLocalSubdivisionCandidates->push_back(SortableEntry(tType, pos, (*rit).mRay)); 1004 1013 } 1005 1014 … … 1206 1215 vector<SortableEntry>::const_iterator ci, ci_end = mLocalSubdivisionCandidates->end(); 1207 1216 1217 #ifdef _DEBUG 1218 const float volRatio = tData.mBoundingBox.GetVolume() / (sizeBox * mBoundingBox.GetVolume()); 1219 const int leaves = mVspStats.Leaves(); 1220 const bool printStats = ((axis == 0) && (leaves > 0) && (leaves < 90)); 1221 1222 ofstream sumStats; 1223 ofstream pvslStats; 1224 ofstream pvsrStats; 1225 1226 if (printStats) 1227 { 1228 char str[64]; 1229 1230 sprintf(str, "tmp/vsp_heur_sum-%04d.log", leaves); 1231 sumStats.open(str); 1232 sprintf(str, "tmp/vsp_heur_pvsl-%04d.log", leaves); 1233 pvslStats.open(str); 1234 sprintf(str, "tmp/vsp_heur_pvsr-%04d.log", leaves); 1235 pvsrStats.open(str); 1236 } 1237 1238 #endif 1208 1239 for (ci = mLocalSubdivisionCandidates->begin(); ci != ci_end; ++ ci) 1209 1240 { … … 1224 1255 sum = pvsl * ((*ci).value - minBox) + pvsr * (maxBox - (*ci).value); 1225 1256 1257 #ifdef _DEBUG 1258 if (printStats) 1259 { 1260 sumStats 1261 << "#Position\n" << currentPos << endl 1262 << "#Sum\n" << sum * volRatio << endl 1263 << "#Pvs\n" << pvsl + pvsr << endl; 1264 1265 pvslStats 1266 << "#Position\n" << currentPos << endl 1267 << "#Pvsl\n" << pvsl << endl; 1268 1269 pvsrStats 1270 << "#Position\n" << currentPos << endl 1271 << "#Pvsr\n" << pvsr << endl; 1272 } 1273 #endif 1226 1274 1227 1275 if (sum < minSum) … … 1260 1308 } 1261 1309 1262 const float volRatio = tData.mBoundingBox.GetVolume() / (sizeBox * mBoundingBox.GetVolume()); 1263 1310 #ifdef _DEBUG 1264 1311 Debug << "\n§§§§ eval local cost §§§§" << endl 1265 1312 << "back pvs: " << penaltyBack << " front pvs: " << penaltyFront << " total pvs: " << penaltyOld << endl … … 1267 1314 << "old rc: " << oldRenderCost * volRatio << " new rc: " << newRenderCost * volRatio << endl 1268 1315 << "render cost decrease: " << oldRenderCost * volRatio - newRenderCost * volRatio << endl; 1269 1316 #endif 1270 1317 return ratio; 1271 1318 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r1305 r1314 657 657 } 658 658 659 friend bool operator<(const SortableEntry &a, const SortableEntry &b) 660 { 661 return a.value < b.value; 659 friend inline bool operator<(const SortableEntry &a, const SortableEntry &b) 660 { // prefer max event 661 //if (EpsilonEqual(a.value, b.value, 0.0001f)) 662 // return (a.type == ERayMax); 663 664 return (a.value < b.value); 662 665 } 663 666 };
Note: See TracChangeset
for help on using the changeset viewer.