Changeset 1696 for GTP/trunk/Lib/Vis/Preprocessing/src
- Timestamp:
- 10/29/06 18:17:38 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1693 r1696 214 214 BvHierarchy::~BvHierarchy() 215 215 { 216 // delete kdintersectables216 // delete bvh intersectables 217 217 BvhIntersectableMap::iterator it, it_end = mBvhIntersectables.end(); 218 218 … … 222 222 } 223 223 224 // delete the local subdivision candidates 224 225 DEL_PTR(mSubdivisionCandidates); 225 226 227 // delete the presorted objects 226 228 for (int i = 0; i < 3; ++ i) 227 229 { 228 230 DEL_PTR(mSortedObjects[i]); 229 231 } 230 mSubdivisionStats.close(); 232 233 // delete the tree 234 DEL_PTR(mRoot); 231 235 } 232 236 … … 329 333 for (oit = objects.begin(); oit != oit_end; ++ oit) 330 334 { 331 nRays += (int)(*oit)-> mVssRays.size();335 nRays += (int)(*oit)->GetOrCreateRays()->size(); 332 336 } 333 337 … … 1336 1340 if (ray->mTerminationObject) 1337 1341 { 1338 ray->mTerminationObject-> mVssRays.push_back(ray);1342 ray->mTerminationObject->GetOrCreateRays()->push_back(ray); 1339 1343 if (!ray->Mailed()) 1340 1344 { … … 1346 1350 if (ray->mOriginObject) 1347 1351 { 1348 ray->mOriginObject-> mVssRays.push_back(ray);1352 ray->mOriginObject->GetOrCreateRays()->push_back(ray); 1349 1353 1350 1354 if (!ray->Mailed()) … … 1385 1389 { 1386 1390 Intersectable *obj = *oit; 1387 VssRayContainer::const_iterator rit, rit_end = obj-> mVssRays.end();1388 1389 for (rit = obj-> mVssRays.begin(); rit < rit_end; ++ rit)1391 VssRayContainer::const_iterator rit, rit_end = obj->GetOrCreateRays()->end(); 1392 1393 for (rit = obj->GetOrCreateRays()->begin(); rit < rit_end; ++ rit) 1390 1394 { 1391 1395 VssRay *ray = (*rit); … … 1514 1518 const bool setCounter) const 1515 1519 { 1516 VssRayContainer::const_iterator rit, rit_end = obj-> mVssRays.end();1517 1518 for (rit = obj-> mVssRays.begin(); rit < rit_end; ++ rit)1520 VssRayContainer::const_iterator rit, rit_end = obj->GetOrCreateRays()->end(); 1521 1522 for (rit = obj->GetOrCreateRays()->begin(); rit < rit_end; ++ rit) 1519 1523 { 1520 1524 VssRay *ray = (*rit); … … 1557 1561 int result = 0; 1558 1562 1559 VssRayContainer::const_iterator rit, rit_end = obj-> mVssRays.end();1560 1561 for (rit = obj-> mVssRays.begin(); rit < rit_end; ++ rit)1563 VssRayContainer::const_iterator rit, rit_end = obj->GetOrCreateRays()->end(); 1564 1565 for (rit = obj->GetOrCreateRays()->begin(); rit < rit_end; ++ rit) 1562 1566 { 1563 1567 VssRay *ray = (*rit); -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r1595 r1696 96 96 { 97 97 VssRay *nray = new VssRay(*vssRay); 98 (*vit)-> mVssRays.push_back(nray);98 (*vit)->GetOrCreateRays()->push_back(nray); 99 99 } 100 100 } … … 480 480 for (vit = mViewCellsManager->GetViewCells().begin(); vit != vit_end; ++ vit) 481 481 { 482 CLEAR_CONTAINER((*vit)->mVssRays);482 (*vit)->DelRayRefs(); 483 483 } 484 484 485 CLEAR_CONTAINER(mVssRays);485 //CLEAR_CONTAINER(mVssRays); 486 486 // ComputeRenderError(); 487 487 ++ mPass; -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1692 r1696 389 389 SplitQueue viewSpaceQueue; 390 390 391 int vspSteps , ospSteps;391 int vspSteps = 0, ospSteps = 0; 392 392 393 393 // use sah for evaluating osp tree construction … … 451 451 // then optimizate view space partition for the current osp 452 452 // and vice versa until iteration depth is reached. 453 453 454 bool lastSplitWasOsp = true; 454 455 … … 948 949 SubdivisionCandidate *sc = NextSubdivisionCandidate(splitQueue); 949 950 950 float rc = (float)sc->GetRenderCostDecrease() / (mInitialRenderCost - mHierarchyStats.mTotalCost + 1.0f); 951 float mc = (float)sc->GetPvsEntriesIncr() / (float)mHierarchyStats.mPvsEntries; 952 951 const float priority = sc->GetPriority(); 952 953 //float rc = (float)sc->GetRenderCostDecrease() / (mInitialRenderCost - mHierarchyStats.mTotalCost + 1.0f); 954 //float mc = (float)sc->GetPvsEntriesIncr() / (float)mHierarchyStats.mPvsEntries; 953 955 //cout << "dRc: " << sc->GetRenderCostDecrease() << " dMem: " << sc->GetPvsEntriesIncr() << " ratio1 " << rc << " ratio2 " << mc << " const: " << 1.0f - GetMemoryConst() << endl; 954 955 // minimum slope reached956 if ((steps > maxSteps) ||957 ((sc->GetPriority() < threshold) && !(steps < minSteps)))958 {959 cout << "\n**************** breaking on " << sc->GetPriority() << " smaller than " << threshold << endl;960 break;961 }962 956 963 957 //////// … … 969 963 if (success) 970 964 { 971 sc->CollectDirtyCandidates(dirtyCandidates, true);965 //sc->CollectDirtyCandidates(dirtyCandidates, true); 972 966 ++ steps; 973 967 } 968 969 DEL_PTR(sc); 970 971 // minimum slope reached 972 if ((steps >= maxSteps) || 973 ((priority < threshold) && !(steps < minSteps))) 974 { 975 cout << "\n**************** breaking on " << priority << " smaller than " << threshold << endl; 976 break; 977 } 978 974 979 } 975 980 … … 1156 1161 AxisAlignedBox3 *forcedViewSpace) 1157 1162 { 1158 // assume object space subdivision constructed1159 //mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType;1160 1161 1163 const long startTime = GetTime(); 1162 1164 const int limit = mNumMultiLevels; … … 1538 1540 for (oit = objects.begin(); oit != oit_end; ++ oit) 1539 1541 { 1540 (*oit)-> mVssRays.clear();1542 (*oit)->DelRayRefs(); 1541 1543 } 1542 1544 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h
r1687 r1696 48 48 BvhLeaf *mBvhLeaf; 49 49 //BvhNode *mBvhLeaf; 50 /// some rays piercing this intersectable 51 VssRayContainer mVssRays; 52 50 53 51 /// # of references to this instance 54 52 int mReferences; 55 53 56 54 ////////////////// 57 // note matt: delete these, they are only taking memory +55 // note matt: delete these, they are only taking memory 58 56 59 57 … … 77 75 }; 78 76 79 Intersectable(): mMailbox(0), mReferences(0), mBvhLeaf(0) {}77 Intersectable(): mMailbox(0), mReferences(0), mBvhLeaf(0), mVssRays(NULL) {} 80 78 81 79 virtual Intersectable::~Intersectable() {}; … … 114 112 115 113 virtual int GetRandomVisibleSurfacePoint(Vector3 &point, 116 Vector3 &normal,117 const Vector3 &viewpoint,118 114 Vector3 &normal, 115 const Vector3 &viewpoint, 116 const int maxTries) = 0; 119 117 120 118 virtual ostream &Describe(ostream &s) = 0; … … 160 158 } 161 159 162 /** returns normal from the face with the specified index.163 PROBLEM: Does not fit to all intersectable types (e.g., spheres)160 /** Returns normal from the face with the specified index. 161 PROBLEM: Does not fit to all intersectable types (e.g., spheres) 164 162 */ 165 163 virtual Vector3 GetNormal(const int idx) const { return Vector3(0, 0, 0); } 164 165 VssRayContainer *GetOrCreateRays() 166 { 167 if (!mVssRays) 168 mVssRays = new VssRayContainer(); 169 return mVssRays; 170 } 171 172 void DelRayRefs() 173 { 174 DEL_PTR(mVssRays); 175 } 176 177 protected: 178 179 /// some rays piercing this intersectable 180 VssRayContainer *mVssRays; 166 181 }; 167 182 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1695 r1696 772 772 Environment::GetSingleton()->GetStringValue("Hierarchy.type", buf); 773 773 774 HierarchyManager *mHierarchyManager = CreateHierarchyManager(buf);774 mHierarchyManager = CreateHierarchyManager(buf); 775 775 mViewCellsManager = new VspOspViewCellsManager(vcTree, mHierarchyManager); 776 776 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj
r1633 r1696 428 428 <File 429 429 RelativePath="..\src\MutualVisibility.h"> 430 </File> 431 <File 432 RelativePath=".\ObjExporter.cpp"> 433 </File> 434 <File 435 RelativePath=".\ObjExporter.h"> 430 436 </File> 431 437 <File -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1695 r1696 244 244 { 245 245 CLEAR_CONTAINER(mViewCells); 246 } 247 else 248 { 249 DEL_PTR(mViewCellsTree); 246 250 } 247 251 } … … 3041 3045 { 3042 3046 // prepare some rays for output 3043 VssRayContainer::const_iterator rit, rit_end = (*vit)-> mVssRays.end();3044 for (rit = (*vit)-> mVssRays.begin(); rit != rit_end; ++ rit)3047 VssRayContainer::const_iterator rit, rit_end = (*vit)->GetOrCreateRays()->end(); 3048 for (rit = (*vit)->GetOrCreateRays()->begin(); rit != rit_end; ++ rit) 3045 3049 { 3046 3050 collectRays.push_back(*rit); … … 4968 4972 4969 4973 4970 // should maybe be done here to allow merge working with area or volume4971 // and to correct the rendering statistics4972 if (0) FinalizeViewCells(false);4973 4974 4974 // compute tree by merging the nodes of the spatial hierarchy 4975 4975 ViewCell *root = ConstructSpatialMergeTree(mHierarchyManager->GetVspTree()->GetRoot()); 4976 4976 mViewCellsTree->SetRoot(root); 4977 4977 4978 4979 4978 ////////////////////////// 4980 //-- update pvs in the whole hierarchy 4979 //-- update pvs up to the root of the hierarchy 4980 4981 4981 ObjectPvs pvs; 4982 4982 UpdatePvsForEvaluation(root, pvs); … … 5010 5010 //-- some tasks still to do on the view cells: 5011 5011 //-- Compute meshes from view cell geometry, evaluate volume and / or area 5012 5012 5013 if (1) FinalizeViewCells(true); 5013 5014 5014 5015 // write out view cells (this moved to preprocessor) 5015 if ( 1 &&mExportViewCells)5016 if (mExportViewCells) 5016 5017 { 5017 5018 char filename[100]; -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1692 r1696 345 345 346 346 VspLeaf::VspLeaf(): 347 mViewCell(NULL), mPvs(NULL), mSubdivisionCandidate(NULL) 347 mViewCell(NULL), mSubdivisionCandidate(NULL) 348 //, mPvs(NULL) 348 349 { 349 350 } … … 352 353 VspLeaf::~VspLeaf() 353 354 { 354 DEL_PTR(mPvs);355 356 355 VssRayContainer::const_iterator vit, vit_end = mVssRays.end(); 357 356 for (vit = mVssRays.begin(); vit != vit_end; ++ vit) … … 380 379 381 380 VspLeaf::VspLeaf(VspInterior *parent): 382 VspNode(parent), mViewCell(NULL), mPvs(NULL) 381 VspNode(parent), mViewCell(NULL) 382 //, mPvs(NULL) 383 383 {} 384 384 385 385 386 386 VspLeaf::VspLeaf(VspInterior *parent, ViewCellLeaf *viewCell): 387 VspNode(parent), mViewCell(viewCell), mPvs(NULL) 387 VspNode(parent), mViewCell(viewCell) 388 //, mPvs(NULL) 388 389 { 389 390 } … … 963 964 backData.mNode = backLeaf; 964 965 965 // explicitely create front and back view cell966 // create front and back view cell for the new leaves 966 967 CreateViewCell(frontData, false); 967 968 CreateViewCell(backData, false); … … 2846 2847 // set view cell values 2847 2848 viewCell->mLeaves.push_back(leaf); 2848 2849 2849 viewCell->SetVolume(mBoundingBox.GetVolume()); 2850 leaf->mProbability = mBoundingBox.GetVolume(); 2850 2851 leaf->mProbability = mBoundingBox.GetVolume(); 2851 2852 } 2852 2853 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r1695 r1696 334 334 335 335 /// leaf pvs 336 ObjectPvs *mPvs;336 //ObjectPvs *mPvs; 337 337 338 338 /// Probability that the view point lies in this leaf -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1695 r1696 160 160 //be ignored. Use it as you will! 161 161 //note: from GDNet Direct [3.8.04 - 3.14.04] void detectMemoryLeaks() { 162 #if 0162 #if 1 163 163 _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF|_CRTDBG_ALLOC_MEM_DF); 164 164 _CrtSetReportMode(_CRT_ASSERT,_CRTDBG_MODE_FILE); … … 325 325 preprocessor->mUseGlDebugger = false; 326 326 } 327 327 328 328 if (!(preprocessor->mUseGlRenderer || preprocessor->mUseGlDebugger)) { 329 330 331 } 332 329 // just call the mail method -> will be executed in the main thread 330 pt->Main(); 331 } 332 333 333 // release memory 334 334 Cleanup();
Note: See TracChangeset
for help on using the changeset viewer.