- Timestamp:
- 08/02/06 17:01:35 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r1168 r1178 251 251 float &contribution) 252 252 { 253 Debug << "here9 "<< endl; 254 Debug << "here2 " << mVolume << endl; 253 255 const bool result = mPvs.AddSample(sample, pdf, contribution); 254 256 Debug << "here4" << endl; 255 257 // update pvs size scalar 256 258 //mPvsSize = mPvs.GetSize(); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1176 r1178 31 31 32 32 33 34 33 template <typename T> class myless 35 34 { … … 921 920 cout << "finished" << endl; 922 921 } 923 924 922 cout << "finished" << endl; 925 923 926 cout << "Evaluating view cell partition" << endl;924 cout << "Evaluating view cell partition ... " << endl; 927 925 928 926 while (castSamples < numSamples) … … 978 976 cout << "finished in " << timeDiff * 1e-3 << " secs" << endl; 979 977 Debug << "finished in " << timeDiff * 1e-3 << " secs" << endl; 980 981 978 982 979 disposeRays(evaluationSamples, NULL); … … 2534 2531 2535 2532 2536 #else 2537 2538 // really merge cells: slow put sumpdf is correct 2533 #else // really merge cells: slow put sumPdf is correct 2539 2534 viewCellInterior->GetPvs().Merge(backVc->GetPvs()); 2540 2535 viewCellInterior->GetPvs().Merge(frontVc->GetPvs()); 2541 2536 #endif 2542 2537 } 2543 2544 2538 2545 2539 … … 4885 4879 4886 4880 long startTime; 4887 4881 Debug << "here601" << endl; 4888 4882 //mHierarchyManager->Construct(constructionRays, objects, &mViewSpaceBox); 4889 4883 mHierarchyManager->Construct2(constructionRays, objects, &mViewSpaceBox); 4890 4884 4885 VssRayContainer::const_iterator vit, vit_end = constructionRays.end(); 4886 for (vit = constructionRays.begin(); vit != vit_end; ++ vit) 4887 { 4888 storedRays.push_back(new VssRay(*(*vit))); 4889 } 4891 4890 4892 4891 // print subdivision statistics … … 4902 4901 4903 4902 cout << "Computing remaining ray contributions ... "; 4903 4904 4904 4905 4905 // recast rest of rays … … 5278 5278 int raysOut = 0; 5279 5279 5280 5280 5281 //-- some rays for output 5282 5281 5283 for (int i = 0; i < limit; ++ i) 5282 5284 { … … 5725 5727 5726 5728 5729 void VspOspViewCellsManager::EvalViewCellPartition() 5730 { 5731 Debug << "here23" << endl; 5732 int samplesPerPass; 5733 int numSamples; 5734 int castSamples = 0; 5735 5736 char s[64]; 5737 5738 Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.samplesPerPass", samplesPerPass); 5739 Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.samples", numSamples); 5740 5741 char statsPrefix[100]; 5742 Environment::GetSingleton()->GetStringValue("ViewCells.Evaluation.statsPrefix", statsPrefix); 5743 5744 Debug << "view cell evaluation samples per pass: " << samplesPerPass << endl; 5745 Debug << "view cell evaluation samples: " << numSamples << endl; 5746 Debug << "view cell stats prefix: " << statsPrefix << endl; 5747 5748 // should directional sampling be used? 5749 bool dirSamples = (mEvaluationSamplingType == Preprocessor::DIRECTION_BASED_DISTRIBUTION); 5750 5751 cout << "reseting pvs ... "; 5752 5753 const bool startFromZero = true; 5754 5755 // reset pvs and start over from zero 5756 if (startFromZero) 5757 { 5758 mViewCellsTree->ResetPvs(); 5759 } 5760 else // start from current sampless 5761 { 5762 // statistics before casting more samples 5763 cout << "compute new statistics ... "; 5764 sprintf(s, "-%09d-eval.log", castSamples); 5765 string fName = string(statsPrefix) + string(s); 5766 5767 mViewCellsTree->ExportStats(fName); 5768 cout << "finished" << endl; 5769 } 5770 cout << "finished" << endl; 5771 5772 cout << "Evaluating view cell partition ... " << endl; 5773 5774 VssRayContainer evaluationSamples = storedRays; 5775 const int samplingType = mEvaluationSamplingType; 5776 5777 cout << "computing sample contributions of " << (int)evaluationSamples.size() << " samples ... "; 5778 5779 ComputeSampleContributions(evaluationSamples, true, false); 5780 5781 cout << "finished" << endl; 5782 5783 cout << "compute new statistics ... "; 5784 Debug << "compute new statistics ... "; 5785 5786 //-- propagate pvs or pvs size information 5787 ObjectPvs pvs; 5788 UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), pvs); 5789 5790 //-- output stats 5791 5792 sprintf(s, "-%09d-eval.log", castSamples); 5793 string fileName = string(statsPrefix) + string(s); 5794 5795 mViewCellsTree->ExportStats(fileName); 5796 5797 cout << "finished" << endl; 5798 5799 disposeRays(evaluationSamples, NULL); 5800 } 5801 5727 5802 ////////////////////////////////// 5728 5803 /*ViewCellsManager *ViewCellsManagerFactory::Create(const string mName) -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r1168 r1178 383 383 /** Evaluates render cost statistics of current view cell hierarchy. 384 384 */ 385 v oid EvalViewCellPartition();385 virtual void EvalViewCellPartition(); 386 386 387 387 /** Sets maximal size of a view cell filter. … … 413 413 */ 414 414 void UpdateScalarPvsSize(ViewCell *vc, const int pvsSize, const int entriesInPvs) const; 415 416 415 417 416 /** Returns bounding box of a view cell. … … 674 673 675 674 bool mStoreKdPvs; 675 676 VssRayContainer storedRays; 676 677 }; 677 678 … … 1011 1012 protected: 1012 1013 1014 virtual void EvalViewCellPartition(); 1015 1013 1016 /** Exports view cell geometry. 1014 1017 */ -
GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp
r1176 r1178 30 30 OspTree *OspTree::OspSplitCandidate::sOspTree = NULL; 31 31 32 // variable for debugging volume contribution for heuristics 33 static float debugVol; 34 32 35 // pvs penalty can be different from pvs size 33 36 inline static float EvalPvsPenalty(const int pvs, … … 460 463 Debug << "pvs heuristics: per kd node" << endl; 461 464 462 m SplitCandidates = new vector<SortableEntry>;465 mLocalSplitCandidates = new vector<SortableEntry>; 463 466 464 467 Debug << endl; … … 494 497 { 495 498 DEL_PTR(mRoot); 496 DEL_PTR(m SplitCandidates);499 DEL_PTR(mLocalSplitCandidates); 497 500 } 498 501 … … 703 706 if (newNode->IsLeaf()) // subdivision terminated 704 707 { 705 //CreateViewCell(tData); // create new view cell 708 // view cell is created during subdivision 709 //CreateViewCell(tData); 706 710 707 711 VspLeaf *leaf = dynamic_cast<VspLeaf *>(newNode); … … 980 984 981 985 ViewCellLeaf *vc = leaf->GetViewCell(); 982 986 983 987 // add contributions from samples to the PVS 984 988 for (it = rays.begin(); it != it_end; ++ it) … … 1016 1020 { 1017 1021 // potentially visible kd cells 1018 if (!m UseKdPvsForHeuristics) // matt TODo: remove storekdpvs!!1022 if (!mStoreKdPvs) // matt Todo: remove storekdpvs!! 1019 1023 { 1020 1024 if (vc->AddPvsSample(obj, ray->mPdf, contribution)) … … 1050 1054 float maxBand) 1051 1055 { 1052 m SplitCandidates->clear();1056 mLocalSplitCandidates->clear(); 1053 1057 1054 1058 int requestedSize = 2 * (int)(rays.size()); 1055 1059 1056 1060 // creates a sorted split candidates array 1057 if (mSplitCandidates->capacity() > 500000 && 1058 requestedSize < (int)(mSplitCandidates->capacity() / 10) ) 1059 { 1060 delete mSplitCandidates; 1061 mSplitCandidates = new vector<SortableEntry>; 1062 } 1063 1064 mSplitCandidates->reserve(requestedSize); 1061 if (mLocalSplitCandidates->capacity() > 500000 && 1062 requestedSize < (int)(mLocalSplitCandidates->capacity() / 10) ) 1063 { 1064 delete mLocalSplitCandidates; 1065 mLocalSplitCandidates = new vector<SortableEntry>; 1066 } 1067 1068 mLocalSplitCandidates->reserve(requestedSize); 1069 1065 1070 1066 1071 float pos; … … 1075 1080 pos = (*rit).ExtrapOrigin(axis); 1076 1081 1077 m SplitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMin : SortableEntry::ERayMax,1082 mLocalSplitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMin : SortableEntry::ERayMax, 1078 1083 pos, (*rit).mRay)); 1079 1084 1080 1085 pos = (*rit).ExtrapTermination(axis); 1081 1086 1082 m SplitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMax : SortableEntry::ERayMin,1087 mLocalSplitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMax : SortableEntry::ERayMin, 1083 1088 pos, (*rit).mRay)); 1084 1089 } 1085 1090 1086 stable_sort(m SplitCandidates->begin(), mSplitCandidates->end());1091 stable_sort(mLocalSplitCandidates->begin(), mLocalSplitCandidates->end()); 1087 1092 } 1088 1093 … … 1411 1416 1412 1417 1413 vector<SortableEntry>::const_iterator ci, ci_end = mSplitCandidates->end();1414 1415 1418 //-- traverse through visibility events 1416 1419 1417 for (ci = mSplitCandidates->begin(); ci != ci_end; ++ ci) 1420 vector<SortableEntry>::const_iterator ci, ci_end = mLocalSplitCandidates->end(); 1421 1422 for (ci = mLocalSplitCandidates->begin(); ci != ci_end; ++ ci) 1418 1423 { 1419 1424 EvalPvsIncr(*ci, pvsl, pvsr); … … 1469 1474 } 1470 1475 1471 //if (axis != 1) 1476 const float volRatio = tData.mBoundingBox.GetVolume() / (sizeBox * mBoundingBox.GetVolume()); 1477 1478 /* 1479 //if (axis != 1) 1472 1480 //Debug << "axis=" << axis << " costRatio=" << ratio << " pos=" << position << " t=" << (position - minBox) / (maxBox - minBox) 1473 1481 // <<"\t pb=(" << pvsBack << ")\t pf=(" << pvsFront << ")" << endl; 1474 1482 1475 const float volRatio = tData.mBoundingBox.GetVolume() / (sizeBox * mBoundingBox.GetVolume()); 1476 1477 Debug << "\n§§§§ eval local cost §§§§" << endl 1483 Debug << "\n§§§§ eval local cost §§§§" << endl 1478 1484 << "back pvs: " << penaltyBack << " front pvs: " << penaltyFront << " total pvs: " << penaltyOld << endl 1479 1485 << "back p: " << pBack * volRatio << " front p " << pFront * volRatio << " p: " << pOverall * volRatio << endl 1480 1486 << "old rc: " << oldRenderCost * volRatio << " new rc: " << newRenderCost * volRatio << endl 1481 1487 << "render cost decrease: " << oldRenderCost * volRatio - newRenderCost * volRatio << endl; 1482 1488 */ 1483 1489 return ratio; 1484 1490 } … … 1648 1654 normalizedOldRenderCost = oldRenderCost / viewSpaceVol; 1649 1655 1650 //Debug << "decrease: " << oldRenderCost - newRenderCost << endl;1651 1656 const float renderCostDecrease = (oldRenderCost - newRenderCost) / viewSpaceVol; 1652 1657 /* 1653 1658 Debug << "\n==== eval render cost decrease ===" << endl 1654 1659 << "back pvs: " << pvsBack << " front pvs " << pvsFront << " total pvs: " << totalPvs << endl … … 1656 1661 << "old rc: " << normalizedOldRenderCost << " new rc: " << newRenderCost / viewSpaceVol << endl 1657 1662 << "render cost decrease: " << renderCostDecrease << endl; 1658 1663 */ 1659 1664 return renderCostDecrease; 1660 1665 } … … 1690 1695 } 1691 1696 1692 //-- cost heuristics 1697 //-- evaluate cost heuristics 1698 1693 1699 float pOverall; 1694 1700 … … 1986 1992 { 1987 1993 vector<VspLeaf *> leaves; 1994 CollectLeaves(leaves); 1988 1995 1989 1996 vector<VspLeaf *>::const_iterator lit, lit_end = leaves.end(); … … 2933 2940 mBoundingBox = kdTree.GetBox(); 2934 2941 mRoot = kdTree.GetRoot(); 2942 mSplitCandidates = new vector<SortableEntry>; 2935 2943 } 2936 2944 … … 2949 2957 DEL_PTR(mRoot); 2950 2958 2959 DEL_PTR(mSplitCandidates); 2951 2960 mSubdivisionStats.close(); 2952 2961 } … … 3230 3239 float frontProb; 3231 3240 float backProb; 3232 3241 3233 3242 // compute locally best split plane 3234 3243 const bool success = … … 3337 3346 RayInfoContainer usedRays; 3338 3347 int mMaxTests = 5000; // HACK 3339 if (mMaxTests < (int)tData.mRays->size())3340 {3341 GetRayInfoSets(*tData.mRays, mMaxTests, usedRays);3342 }3343 else3344 {3348 // if (mMaxTests < (int)tData.mRays->size()) 3349 // { 3350 // GetRayInfoSets(*tData.mRays, mMaxTests, usedRays); 3351 // } 3352 // else 3353 // { 3345 3354 usedRays = *tData.mRays; 3346 }3355 // } 3347 3356 3348 3357 // go through the lists, count the number of objects left and right … … 3396 3405 float minSum = 1e20f; 3397 3406 3407 debugVol = 0; 3408 const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume(); 3409 3398 3410 ///////////////////////////// 3411 // the sweep heuristics 3412 3399 3413 3400 3414 Intersectable::NewMail(); 3401 3415 ViewCell::NewMail(); 3402 3416 3417 3403 3418 //-- traverse through events and find best split plane 3419 3404 3420 vector<SortableEntry>::const_iterator ci, ci_end = mSplitCandidates->end(); 3405 3421 … … 3431 3447 currentPos = (*ci).mPos; 3432 3448 3433 // note matt: can happen that volr is less than zero: bug or numerical error? 3434 //if (volr < 0) Debug << "warning!"; 3435 3436 /*Debug << "pos: " << (*ci).mPos 3449 if ((totalVol - voll - volr - debugVol) / viewSpaceVol > 0.0001) 3450 Debug << "front and back volume: " << (totalVol - voll - volr) / viewSpaceVol << " error: " << (totalVol - voll - volr - debugVol) / viewSpaceVol << endl; 3451 /* Debug << "pos: " << currentPos 3437 3452 << "\t (pvsl: " << pvsl << ", pvsr: " << pvsr << ")" 3438 3453 << "\t (voll: " << voll << ", volr: " << volr << ")" 3439 3454 << "\t (vcl: " << vcl << ", vcr: " << vcr << ", nvc: " << numViewCells << ")" 3440 << "\t sum: " << sum << endl;*/ 3455 << "\t sum: " << sum << endl; 3456 */ 3441 3457 3442 3458 if (sum < minSum) … … 3471 3487 ratio = newRenderCost / oldRenderCost; 3472 3488 } 3473 3489 3474 3490 //Debug << "axis=" << axis << " costRatio=" << ratio << " pos=" 3475 3491 // << position << " t=" << (position - minBox) / (maxBox - minBox) 3476 3492 // << "\t pb=(" << volBack << ")\t pf=(" << volFront << ")" << endl; 3477 3478 const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume();3479 3493 3480 3494 Debug << "\n§§§§ eval local cost §§§§" << endl … … 3543 3557 ); 3544 3558 } 3545 3546 3547 3548 3559 3549 3560 if (ray->mTerminationObject && (GetLeaf(ray->mTermination, ray->mTerminationNode) == leaf)) … … 3741 3752 // => remove ref to right child node 3742 3753 volRight -= vol; 3754 3755 debugVol += vol; 3743 3756 } 3744 3757 … … 3756 3769 // contributes only to left node now 3757 3770 volLeft += vol; 3771 debugVol -= vol; 3758 3772 } 3759 3773 } … … 3793 3807 sAxis = box.Size().DrivingAxis(); 3794 3808 } 3809 3795 3810 3796 3811 // -- evaluate split cost for all three axis … … 4011 4026 } 4012 4027 4028 ViewCellContainer::const_iterator vit, vit_end = collectedViewCells.end(); 4029 4030 // evaluate view cells volume contribution with respect to mail box 4031 for (vit = collectedViewCells.begin(); vit != vit_end; ++ vit) 4032 { 4033 AddViewCellVolumeContri(*vit, pFront, pBack, pFrontAndBack); 4034 } 4035 4013 4036 // these are non-overlapping sets 4014 4037 pOverall = pFront + pBack + pFrontAndBack; 4015 4016 ViewCellContainer::const_iterator vit, vit_end = collectedViewCells.end();4017 4018 // evaluate view cells volume contribution with respect to mail box4019 for (vit = collectedViewCells.begin(); vit != vit_end; ++ vit)4020 {4021 AddViewCellVolumeContri(*vit, pFront, pBack, pFrontAndBack);4022 }4023 4024 4038 4025 4039 //-- pvs rendering heuristics … … 4288 4302 { 4289 4303 VssRay *ray = *rit; 4304 4290 4305 float minT, maxT; 4291 4306 static Ray hray; … … 4498 4513 { 4499 4514 SplitCandidate *splitCandidate = mTQueue.Top(); 4500 4501 cout << "next candidate: " << splitCandidate->Type()4502 << ", priority: " << splitCandidate->GetPriority() << endl;4503 4504 4515 mTQueue.Pop(); 4505 4516 … … 4547 4558 mVspTree.mBoundingBox); 4548 4559 4549 #if WORK_WITH_VIEWCELL_PVS4550 4551 4560 // create first view cell 4552 4561 mVspTree.CreateViewCell(vData, false); 4553 4562 4563 #if WORK_WITH_VIEWCELL_PVS 4564 4554 4565 // add first view cell to all the objects view cell pvs 4555 4566 ObjectPvsMap::const_iterator oit, … … 4736 4747 ++ mGlobalCostMisses; 4737 4748 4738 /* cout << "nodes: " << ++ numNodes << endl; 4749 /* 4750 cout << "nodes: " << ++ numNodes << endl; 4739 4751 Debug << "\n**********" << endl 4740 4752 << "total cost: " << mTotalCost << " render cost decr: " … … 4743 4755 */ 4744 4756 //-- subdivide leaf node 4757 4745 4758 if (SubdivideSplitCandidate(splitCandidate)) 4746 4759 { 4760 // subdivision successful 4747 4761 EvalSubdivisionStats(*splitCandidate); 4748 4762 … … 4752 4766 if (repair) 4753 4767 RepairQueue(); 4768 4769 cout << "candidate: " << splitCandidate->Type() << ", priority: " << splitCandidate->GetPriority() << endl; 4754 4770 } 4755 4771 … … 4763 4779 AxisAlignedBox3 *forcedViewSpace) 4764 4780 { 4781 // rays clipped in view space and in object space 4765 4782 RayInfoContainer *viewSpaceRays = new RayInfoContainer(); 4766 4783 RayInfoContainer *objectSpaceRays = new RayInfoContainer(); -
GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h
r1176 r1178 451 451 452 452 SplitCandidate *GetSplitCandidate() const 453 { return mSplitCandidate; } 453 { 454 return mSplitCandidate; 455 } 454 456 455 457 public: … … 1050 1052 and must be reevaluated. 1051 1053 */ 1052 void CollectDirtyCandidates(VspSplitCandidate *sc, 1053 vector<SplitCandidate *> &dirtyList); 1054 void CollectDirtyCandidates(VspSplitCandidate *sc, vector<SplitCandidate *> &dirtyList); 1054 1055 1055 1056 /** Rays will be clipped to the bounding box. … … 1071 1072 ViewCellsManager *mViewCellsManager; 1072 1073 1073 vector<SortableEntry> *m SplitCandidates;1074 vector<SortableEntry> *mLocalSplitCandidates; 1074 1075 1075 1076 /// Pointer to the root of the tree -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.cpp
r1168 r1178 114 114 stream<<"key='0.0 "; 115 115 int i; 116 int size = rays.size() + 2;116 int size = (int)rays.size() + 2; 117 117 for (i=1; i < size; i++) { 118 118 stream<<i/(float)(size-1)<<" "; -
GTP/trunk/Lib/Vis/QtRenderer/QtRenderer.vcproj
r1166 r1178 24 24 MinimalRebuild="TRUE" 25 25 BasicRuntimeChecks="3" 26 RuntimeLibrary=" 1"26 RuntimeLibrary="3" 27 27 UsePrecompiledHeader="0" 28 28 WarningLevel="3" … … 33 33 <Tool 34 34 Name="VCLinkerTool" 35 AdditionalDependencies="Preprocessor.lib qtmain.lib QtGui4 d.lib Qt3Support4d.lib QAxContainerd.lib QtCore4d.lib QtOpenGL4.lib xerces-c_2.lib glew32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib"35 AdditionalDependencies="Preprocessor.lib qtmain.lib QtGui4.lib Qt3Support4.lib QAxContainerd.lib QtCore4.lib QtOpenGL4.lib xerces-c_2.lib glew32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib" 36 36 OutputFile="$(OutDir)/QtRenderer.dll" 37 37 LinkIncremental="2"
Note: See TracChangeset
for help on using the changeset viewer.