Changeset 1379 for GTP/trunk/Lib/Vis
- Timestamp:
- 09/15/06 17:33:22 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1370 r1379 290 290 BvhTraversalData &backData) 291 291 { 292 mBvhStats.nodes += 2; // we have two new leaves293 294 292 const BvhTraversalData &tData = sc.mParentData; 295 293 BvhLeaf *leaf = tData.mNode; 296 294 AxisAlignedBox3 parentBox = leaf->GetBoundingBox(); 295 296 // update stats 297 mBvhStats.nodes += 2; // we have two new leaves 298 299 if (tData.mDepth > mBvhStats.maxDepth) 300 { 301 mBvhStats.maxDepth = tData.mDepth; 302 } 297 303 298 304 // add the new nodes to the tree … … 471 477 splitCandidate.mParentData.mMaxCostMisses; 472 478 473 const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume();474 479 const float oldProp = EvalViewCellsVolume(leaf->mObjects); 475 476 const float oldRenderCost = oldProp * (float)leaf->mObjects.size() / viewSpaceVol; 477 480 const float oldRenderCost = EvalRenderCost(leaf->mObjects); 481 478 482 // compute global decrease in render cost 479 float newRenderCost = EvalRenderCost(splitCandidate.mParentData, 480 splitCandidate.mFrontObjects, 481 splitCandidate.mBackObjects); 482 483 newRenderCost /= viewSpaceVol; 483 const float newRenderCost = 484 EvalRenderCost(splitCandidate.mFrontObjects) + 485 EvalRenderCost(splitCandidate.mBackObjects); 486 484 487 const float renderCostDecr = oldRenderCost - newRenderCost; 485 488 486 //Debug << "\nbvh render cost decr: " << renderCostDecr << endl; 489 #ifdef _DEBUG 490 Debug << "old render cost: " << oldRenderCost << endl; 491 Debug << "new render cost: " << newRenderCost << endl; 492 Debug << "render cost decrease: " << renderCostDecr << endl; 493 #endif 487 494 splitCandidate.SetRenderCostDecrease(renderCostDecr); 488 495 489 #if 0 490 const float priority = (float)-splitCandidate.mParentData.mDepth; 491 #else 496 #if 1 492 497 // take render cost of node into account 493 498 // otherwise danger of being stuck in a local minimum!! 494 499 const float factor = mRenderCostDecreaseWeight; 495 500 const float priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 501 #else 502 const float priority = (float)-splitCandidate.mParentData.mDepth; 496 503 #endif 497 504 … … 540 547 // depth related stuff 541 548 542 if (data.mDepth > mBvhStats.maxDepth)543 {544 mBvhStats.maxDepth = data.mDepth;545 }546 547 549 if (data.mDepth < mBvhStats.minDepth) 548 550 { … … 640 642 } 641 643 642 const float oldProp = EvalViewCellsVolume(tData.mNode->mObjects); 643 //const float oldProp = tData.mProbability; 644 645 const float oldRenderCost = oldProb * (float)tData.mNode->mObjects.size(); 644 const float oldRenderCost = EvalRenderCost(tData.mNode->mObjects); 646 645 const float newRenderCost = 647 EvalRenderCost( tData, objectsFront,objectsBack);646 EvalRenderCost(objectsFront) * EvalRenderCost(objectsBack); 648 647 649 648 const float ratio = newRenderCost / oldRenderCost; … … 672 671 // object mailed => belongs to back objects 673 672 if (i < border) 673 { 674 674 objectsBack.push_back(obj); 675 } 675 676 else 677 { 676 678 objectsFront.push_back(obj); 677 } 678 679 const float oldProp = EvalViewCellsVolume(tData.mNode->mObjects); 680 //const float oldProp = tData.mProbability; 681 682 const float oldRenderCost = oldProp * (float)tData.mNode->mObjects.size(); 683 const float newRenderCost = EvalRenderCost(tData, objectsFront, objectsBack); 679 } 680 } 681 682 const float oldRenderCost = EvalRenderCost(tData.mNode->mObjects); 683 const float newRenderCost = EvalRenderCost(objectsFront) + EvalRenderCost(objectsBack); 684 684 685 685 const float ratio = newRenderCost / oldRenderCost; … … 694 694 ObjectContainer &objectsBack) 695 695 { 696 PrepareLocalSubdivisionCandidates(tData, axis);697 698 696 // go through the lists, count the number of objects left and right 699 697 // and evaluate the following cost funcion: 700 698 // C = ct_div_ci + (ol + or)/queries 699 PrepareLocalSubdivisionCandidates(tData, axis); 700 701 701 int objectsLeft = 0, objectsRight = (int)tData.mNode->mObjects.size(); 702 702 … … 709 709 float minSum = 1e20f; 710 710 711 float minBorder = maxBox; 712 float maxBorder = minBox; 713 float areaLeft = 0, areaRight = 0; 714 715 SortableEntryContainer::const_iterator currentPos = 716 mSubdivisionCandidates->begin(); 717 718 719 // we keep track of both borders of the bounding boxes => 720 // store the events in descending order 711 721 vector<float> bordersRight; 712 722 bordersRight.resize(mSubdivisionCandidates->size()); 713 723 714 float minBorder = maxBox;715 float maxBorder = minBox;716 717 SortableEntryContainer::const_iterator currentPos =718 mSubdivisionCandidates->begin();719 720 724 SortableEntryContainer::reverse_iterator rcit = 721 725 mSubdivisionCandidates->rbegin(), rcit_end = mSubdivisionCandidates->rend(); 722 726 723 727 vector<float>::reverse_iterator rbit = bordersRight.rbegin(); 724 728 … … 728 732 const AxisAlignedBox3 box = obj->GetBox(); 729 733 730 if (box.Min() < minBorder) 734 if (box.Min(axis) < minBorder) 735 { 731 736 minBorder = box.Min(axis); 732 737 } 738 733 739 (*rbit) = minBorder; 734 740 } 735 741 736 742 vector<float>::const_iterator bit = bordersRight.begin(); 737 cout << "here42" << endl;738 743 SortableEntryContainer::const_iterator cit, cit_end = mSubdivisionCandidates->end(); 744 739 745 for (cit = mSubdivisionCandidates->begin(); cit != cit_end; ++ cit, ++ bit) 740 746 { … … 749 755 const AxisAlignedBox3 obox = obj->GetBox(); 750 756 757 // the borders of the bounding boxes have changed 751 758 if (obox.Max(axis) > maxBorder) 759 { 752 760 maxBorder = obox.Max(axis); 753 761 } 762 763 minBorder = (*bit); 764 754 765 lbox.SetMax(axis, maxBorder); 755 rbox.SetMin(axis, *bit); 756 757 const float sum = objectsLeft * lbox.SurfaceArea() + objectsRight * rbox.SurfaceArea(); 766 rbox.SetMin(axis, minBorder); 767 768 const float al = lbox.SurfaceArea(); 769 const float ar = rbox.SurfaceArea(); 770 771 const float sum = objectsLeft * al + objectsRight * ar; 758 772 759 cout << "pos=" << (*cit).mPos << "\t q=(" << objectsLeft << "," << objectsRight <<")\t r=("773 /*cout << "pos=" << (*cit).mPos << "\t q=(" << objectsLeft << "," << objectsRight <<")\t r=(" 760 774 << lbox.SurfaceArea() << "," << rbox.SurfaceArea() << ")" << endl; 775 cout << "minborder: " << minBorder << " maxborder: " << maxBorder << endl; 761 776 cout << "cost= " << sum << endl; 762 777 */ 763 778 if (sum < minSum) 764 779 { 765 minSum = sum; 780 minSum = sum; 781 areaLeft = al; 782 areaRight = ar; 766 783 // objects belong to left side now 767 784 for (; currentPos != (cit + 1); ++ currentPos); 768 785 } 769 786 } 787 770 788 771 789 //////////////////////////////////////////// … … 784 802 float ratio = newCost / oldCost; 785 803 786 #if 0787 cout<<"===================="<<endl; 788 cout<<"costRatio="<<ratio<<" pos="<<position<<" t="<<(position - minBox)/(maxBox - minBox) 789 <<"\t o=("<<objectsBack<<","<<objectsFront<<")"<<endl;804 #ifdef _DEBUG 805 cout << "\n\nobjects=(" << objectsBack.size() << "," << objectsFront.size() << " of " << tData.mNode->mObjects.size() << ")\t area=(" 806 << areaLeft << "," << areaRight << ")" << endl; 807 cout << "cost= " << minSum << endl; 790 808 #endif 791 809 return ratio; … … 855 873 int nObjectsLeft = 0; 856 874 const int nTotalObjects = (int)tData.mNode->mObjects.size(); 857 const float viewSpaceVol = m VspTree->GetBoundingBox().GetVolume();875 const float viewSpaceVol = mHierarchyManager->GetViewSpaceBox().GetVolume(); 858 876 859 877 SortableEntryContainer::const_iterator backObjectsStart = mSubdivisionCandidates->begin(); … … 1128 1146 //-- use surface area heuristic because view cells not constructed yet 1129 1147 nCostRatio[axis] = 1130 Eval LocalCostHeuristics(1131 1132 1133 1134 1148 EvalSah( 1149 tData, 1150 axis, 1151 nFrontObjects[axis], 1152 nBackObjects[axis]); 1135 1153 } 1136 1154 } … … 1138 1156 { 1139 1157 //-- split objects using some simple criteria 1140 1141 1158 nCostRatio[axis] = 1142 1159 EvalLocalObjectPartition( … … 1245 1262 1246 1263 1247 float BvHierarchy::EvalRenderCost(const BvhTraversalData &tData, 1248 const ObjectContainer &objectsFront, 1249 const ObjectContainer &objectsBack) const 1250 { 1251 // probability that view point lies in a view cell which sees this node 1252 const float pFront = EvalViewCellsVolume(objectsFront); 1253 const float pBack = EvalViewCellsVolume(objectsBack); 1254 1255 //-- pvs rendering heuristics 1256 const float newRenderCost = (int)objectsFront.size() * pFront + (int)objectsBack.size() * pBack; 1257 1258 #ifdef _DEBUG 1259 const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume(); 1260 Debug << "\nbvh render cost\n" 1261 << "back p: " << pBack / viewSpaceVol << " front p " << pFront / viewSpaceVol << endl 1262 << "new rc: " << newRenderCost / viewSpaceVol << endl; 1263 #endif 1264 return newRenderCost; 1264 float BvHierarchy::EvalRenderCost(const ObjectContainer &objects) const 1265 { 1266 if (mHierarchyManager->GetViewSpaceSubdivisionType() == HierarchyManager::NO_VIEWSPACE_SUBDIV) 1267 { 1268 if (objects.empty()) 1269 return 0.0f; 1270 1271 ///////////////////////////// 1272 //-- surface area heuristics 1273 1274 const AxisAlignedBox3 box = ComputeBoundingBox(objects); 1275 const float area = box.SurfaceArea(); 1276 1277 return (float)objects.size() * area; 1278 } 1279 else 1280 { ///////////////////////////// 1281 //-- render cost heuristics 1282 1283 const float viewSpaceVol = mHierarchyManager->GetViewSpaceBox().GetVolume(); 1284 // probability that view point lies in a view cell which sees this node 1285 const float p = EvalViewCellsVolume(objects) / viewSpaceVol; 1286 1287 return (float)objects.size() * p; 1288 } 1265 1289 } 1266 1290 1267 1291 1268 1292 AxisAlignedBox3 BvHierarchy::ComputeBoundingBox(const ObjectContainer &objects, 1269 const AxisAlignedBox3 *parentBox) 1293 const AxisAlignedBox3 *parentBox) const 1270 1294 { 1271 1295 if (parentBox && objects.empty()) … … 1325 1349 const bool setCounter) const 1326 1350 { 1351 // no view cells yet 1352 if (mHierarchyManager->GetViewSpaceSubdivisionType() == 1353 HierarchyManager::NO_VIEWSPACE_SUBDIV) 1354 return; 1355 1327 1356 ViewCell::NewMail(); 1328 1357 ObjectContainer::const_iterator oit, oit_end = objects.end(); … … 1348 1377 ViewCellContainer tmpViewCells; 1349 1378 1350 m VspTree->GetViewCells(*ray, tmpViewCells);1379 mHierarchyManager->mVspTree->GetViewCells(*ray, tmpViewCells); 1351 1380 1352 1381 ViewCellContainer::const_iterator vit, vit_end = tmpViewCells.end(); … … 1645 1674 bvhleaf->SetSubdivisionCandidate(oSubdivisionCandidate); 1646 1675 1647 const float viewSpaceVol = m VspTree->GetBoundingBox().GetVolume();1676 const float viewSpaceVol = mHierarchyManager->GetViewSpaceBox().GetVolume(); 1648 1677 mTotalCost = (float)objects.size() * prop / viewSpaceVol; 1649 1678 -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1370 r1379 312 312 friend class HierarchyManager; 313 313 314 public: 315 314 protected: 316 315 struct SortableEntry; 317 316 typedef vector<SortableEntry> SortableEntryContainer; 318 317 318 public: 319 319 320 /** Additional data which is passed down the BSP tree during traversal. 320 321 */ … … 589 590 void EvalPriority(BvhTraversalData &tData) const; 590 591 591 /** Evaluates render cost of next split. 592 */ 593 float EvalRenderCost( 594 const BvhTraversalData &tData, 595 const ObjectContainer &objectsLeft, 596 const ObjectContainer &objectsRight) const; 592 /** Evaluates render cost of the bv induced by these objects 593 */ 594 float EvalRenderCost(const ObjectContainer &objects) const; 597 595 598 596 /** Evaluates tree stats in the BSP tree leafs. … … 704 702 AxisAlignedBox3 ComputeBoundingBox( 705 703 const ObjectContainer &objects, 706 const AxisAlignedBox3 *parentBox = NULL) ;704 const AxisAlignedBox3 *parentBox = NULL) const; 707 705 708 706 /** Collects list of invalid candidates. Candidates … … 785 783 /// pointer to the hierarchy of view cells 786 784 ViewCellsTree *mViewCellsTree; 787 /// pointer to the view space partition tree788 VspTree *mVspTree;789 785 /// The view cells manager 790 786 ViewCellsManager *mViewCellsManager; -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1370 r1379 1670 1670 "rays.out"); 1671 1671 1672 RegisterOption("Preprocessor.load PolygonsAsMeshes",1673 optBool, 1674 "load PolygonsAsMeshes=",1675 " false");1672 RegisterOption("Preprocessor.loadMeshes", 1673 optBool, 1674 "loadMeshes=", 1675 "true"); 1676 1676 1677 1677 RegisterOption("Preprocessor.pvsRenderErrorSamples", -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1370 r1379 46 46 mOspTree = new OspTree(); 47 47 mOspTree->mVspTree = mVspTree; 48 49 Debug << "creating osp tree" << endl; 48 mOspTree->mHierarchyManager = this; 50 49 break; 51 50 case BV_BASED_OBJ_SUBDIV: 52 51 mBvHierarchy = new BvHierarchy(); 53 mBvHierarchy->mVspTree = mVspTree; 54 55 Debug << "creating bv hierachy" << endl; 52 mBvHierarchy->mHierarchyManager = this; 56 53 break; 57 54 default: … … 59 56 } 60 57 61 if (mVspTree)62 63 58 // hierarchy manager links view space partition and object space partition 59 mVspTree->mHierarchyManager = this; 60 64 61 ParseEnvironment(); 65 62 } … … 74 71 mOspTree->mVspTree = mVspTree; 75 72 76 Debug << "creating osp tree" << endl; 77 78 if (mVspTree) 79 mVspTree->mHierarchyManager = this; 73 mVspTree->mHierarchyManager = this; 80 74 81 75 ParseEnvironment(); … … 160 154 161 155 156 VspTree *HierarchyManager::GetVspTree() 157 { 158 return mVspTree; 159 } 160 161 162 AxisAlignedBox3 HierarchyManager::GetViewSpaceBox() const 163 { 164 return mVspTree->mBoundingBox; 165 } 166 167 162 168 SubdivisionCandidate *HierarchyManager::NextSubdivisionCandidate() 163 169 { … … 223 229 AxisAlignedBox3 *forcedViewSpace) 224 230 { 225 226 231 mHierarchyStats.Reset(); 227 232 mHierarchyStats.Start(); … … 233 238 cout << "Constructing view space / object space tree ... \n"; 234 239 240 // compute view space bounding box 241 mVspTree->ComputeBoundingBox(sampleRays, forcedViewSpace); 242 235 243 // use objects for evaluating vsp tree construction in the first levels 236 244 // of the subdivision … … 245 253 { 246 254 mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 247 PrepareViewSpaceSubdivision(sampleRays, objects , forcedViewSpace);255 PrepareViewSpaceSubdivision(sampleRays, objects); 248 256 } 249 257 … … 270 278 271 279 void HierarchyManager::PrepareViewSpaceSubdivision(const VssRayContainer &sampleRays, 272 const ObjectContainer &objects, 273 AxisAlignedBox3 *forcedViewSpace) 280 const ObjectContainer &objects) 274 281 { 275 282 cout << "starting view space hierarchy construction ... " << endl; … … 277 284 RayInfoContainer *viewSpaceRays = new RayInfoContainer(); 278 285 SubdivisionCandidate *vsc = 279 mVspTree->PrepareConstruction(sampleRays, forcedViewSpace,*viewSpaceRays);286 mVspTree->PrepareConstruction(sampleRays, *viewSpaceRays); 280 287 281 288 mTQueue.Push(vsc); … … 491 498 << mMinDepthForViewSpaceSubdivion << ") " << endl; 492 499 493 PrepareViewSpaceSubdivision(sampleRays, objects , forcedViewSpace);500 PrepareViewSpaceSubdivision(sampleRays, objects); 494 501 495 502 cout << "reseting queue ... "; -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1370 r1379 198 198 void PrintHierarchyStatistics(ofstream &stream) const; 199 199 200 VspTree *GetVspTree() { return mVspTree; } 200 VspTree *GetVspTree(); 201 202 AxisAlignedBox3 GetViewSpaceBox() const; 201 203 202 204 void ExportObjectSpaceHierarchy( … … 266 268 void PrepareViewSpaceSubdivision( 267 269 const VssRayContainer &sampleRays, 268 const ObjectContainer &objects, 269 AxisAlignedBox3 *forcedViewSpace = NULL); 270 const ObjectContainer &objects); 270 271 271 272 bool ObjectSpaceSubdivisionConstructed() const; -
GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.cpp
r1344 r1379 177 177 bool ObjParser::ParseFile(const string filename, 178 178 SceneGraphNode *root, 179 const bool load PolygonsAsMeshes,179 const bool loadMeshes, 180 180 vector<FaceParentInfo> *parents) 181 181 { -
GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.h
r1344 r1379 17 17 virtual bool ParseFile(const std::string filename, 18 18 SceneGraphNode *root, 19 const bool load PolygonsAsMeshes = false,19 const bool loadMeshes = true, 20 20 vector<FaceParentInfo> *parents = NULL); 21 21 -
GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.h
r1287 r1379 37 37 class KdTreeStatistics; 38 38 class SubdivisionCandidate; 39 class HierarchyManager; 40 39 41 40 42 … … 738 740 ViewCellsTree *mViewCellsTree; 739 741 742 /// pointer to the view space partition 743 /// note: should be handled over the hierarchy manager 740 744 VspTree *mVspTree; 745 746 /// pointer to the hierarchy manager 747 HierarchyManager *mHierarchyManager; 741 748 742 749 /// The view cells manager … … 756 763 757 764 765 ////////////////////////////// 758 766 //-- local termination 759 767 … … 772 780 773 781 782 //////////////////////// 774 783 //-- global criteria 775 784 … … 786 795 787 796 797 /////////////////////////////////////////// 788 798 //-- split heuristics based parameters 789 799 … … 793 803 /// if only driving axis should be used for split 794 804 bool mOnlyDrivingAxis; 795 805 /// represents min and max band for sweep 806 float mSplitBorder; 807 808 //////////////////////////////////////////////// 809 796 810 /// current time stamp (used for keeping split history) 797 811 int mTimeStamp; 798 812 // if rays should be stored in leaves 799 813 bool mStoreRays; 800 801 814 /// epsilon for geometric comparisons 802 815 float mEpsilon; 803 804 816 /// subdivision stats output file 805 817 ofstream mSubdivisionStats; … … 810 822 /// number of currenly generated view cells 811 823 int mCreatedLeaves; 812 813 /// represents min and max band for sweep 814 float mSplitBorder; 815 824 816 825 /// weight between render cost decrease and node render cost 817 826 float mRenderCostDecreaseWeight; 818 827 819 828 /// stores the kd node intersectables used for pvs 820 829 KdIntersectableMap mKdIntersectables; 821 822 830 823 831 private: 824 832 -
GTP/trunk/Lib/Vis/Preprocessing/src/Parser.h
r1344 r1379 20 20 virtual bool ParseFile(const std::string filename, 21 21 SceneGraphNode *root, 22 const bool load PolygonsAsMeshes = false,22 const bool loadMeshes = true, 23 23 std::vector<FaceParentInfo> *parents = NULL) 24 24 {return false;}; -
GTP/trunk/Lib/Vis/Preprocessing/src/PlyParser.cpp
r1344 r1379 260 260 PlyParser::ParseFile(const string filename, 261 261 SceneGraphNode *root, 262 const bool load PolygonsAsMeshes,262 const bool loadMeshes, 263 263 vector<FaceParentInfo> *parents) 264 264 { -
GTP/trunk/Lib/Vis/Preprocessing/src/PlyParser.h
r1344 r1379 16 16 bool ParseFile(const string filename, 17 17 SceneGraphNode *root, 18 const bool load PolygonsAsMeshes = false,18 const bool loadMeshes = true, 19 19 vector<FaceParentInfo> *parents = NULL); 20 20 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1359 r1379 145 145 146 146 Environment::GetSingleton()->GetBoolValue("Preprocessor.useGlDebugger", mUseGlDebugger); 147 Environment::GetSingleton()->GetBoolValue("Preprocessor.load PolygonsAsMeshes", mLoadPolygonsAsMeshes);147 Environment::GetSingleton()->GetBoolValue("Preprocessor.loadMeshes", mLoadMeshes); 148 148 Environment::GetSingleton()->GetBoolValue("Preprocessor.quitOnFinish", mQuitOnFinish); 149 149 Environment::GetSingleton()->GetBoolValue("Preprocessor.computeVisibility", mComputeVisibility); … … 161 161 162 162 Debug << "detect empty view space=" << mDetectEmptyViewSpace << endl; 163 Debug << "load polygons as meshes: " << mLoadPolygonsAsMeshes << endl;163 Debug << "load meshes: " << mLoadMeshes << endl; 164 164 165 165 if (mRayCastMethod == 0) … … 259 259 filename, 260 260 mSceneGraph->GetRoot(), 261 mLoad PolygonsAsMeshes,261 mLoadMeshes, 262 262 &mFaceParents); 263 263 } 264 264 else 265 265 { 266 result = parser->ParseFile(filename, mSceneGraph->GetRoot(), mLoad PolygonsAsMeshes);266 result = parser->ParseFile(filename, mSceneGraph->GetRoot(), mLoadMeshes); 267 267 } 268 268 … … 285 285 filename, 286 286 node, 287 mLoad PolygonsAsMeshes,287 mLoadMeshes, 288 288 &mFaceParents); 289 289 } 290 290 else 291 291 { 292 success = parser->ParseFile(filename, node, mLoad PolygonsAsMeshes);292 success = parser->ParseFile(filename, node, mLoadMeshes); 293 293 } 294 294 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r1292 r1379 218 218 219 219 bool mQuitOnFinish; 220 bool mLoad PolygonsAsMeshes;220 bool mLoadMeshes; 221 221 bool mComputeVisibility; 222 222 -
GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.cpp
r1344 r1379 44 44 UnigraphicsParser::ParseFile(const string filename, 45 45 SceneGraphNode *root, 46 const bool load PolygonsAsMeshes,46 const bool loadMeshes, 47 47 vector<FaceParentInfo> *parents) 48 48 { -
GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.h
r1344 r1379 17 17 virtual bool ParseFile(const std::string filename, 18 18 SceneGraphNode *root, 19 const bool load PolygonsAsMeshes = false,19 const bool loadMeshes = false, 20 20 vector<FaceParentInfo> *parents = NULL); 21 21 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1370 r1379 479 479 { 480 480 mBoundingBox = *forcedBoundingBox; 481 } 482 else // compute vsp tree bounding box 483 { 484 mBoundingBox.Initialize(); 485 VssRayContainer::const_iterator rit, rit_end = rays.end(); 486 487 //-- compute bounding box 488 for (rit = rays.begin(); rit != rit_end; ++ rit) 489 { 490 VssRay *ray = *rit; 491 492 // compute bounding box of view space 493 mBoundingBox.Include(ray->GetTermination()); 494 mBoundingBox.Include(ray->GetOrigin()); 495 } 481 return; 482 } 483 484 ////////////////////////////////////////////// 485 // bounding box of view space includes all visibility events 486 mBoundingBox.Initialize(); 487 VssRayContainer::const_iterator rit, rit_end = rays.end(); 488 489 for (rit = rays.begin(); rit != rit_end; ++ rit) 490 { 491 VssRay *ray = *rit; 492 493 mBoundingBox.Include(ray->GetTermination()); 494 mBoundingBox.Include(ray->GetOrigin()); 496 495 } 497 496 } … … 769 768 VspLeaf *leaf = dynamic_cast<VspLeaf *>(tData.mNode); 770 769 770 /////////////////////////////////////////////////////////////////// 771 771 //-- the front and back traversal data is filled with the new values 772 772 … … 784 784 785 785 //-- compute pvs 786 787 786 frontData.mPvs = EvalPvsSize(*frontData.mRays); 788 787 backData.mPvs = EvalPvsSize(*backData.mRays); 789 790 Debug << "f pvs: " << frontData.mPvs << " b pvs: " << backData.mPvs << " pvs " << tData.mPvs << endl; 791 792 // split front and back node geometry and compute area 788 //Debug << "f pvs: " << frontData.mPvs << " b pvs: " << backData.mPvs << " pvs " << tData.mPvs << endl; 789 790 //-- split front and back node geometry and compute area 793 791 tData.mBoundingBox.Split(splitPlane.mAxis, 794 792 splitPlane.mPosition, … … 799 797 backData.mProbability = tData.mProbability - frontData.mProbability; 800 798 801 802 /////////////////////////////////////////// 803 // subdivide further 804 805 // store maximal and minimal depth 799 // update some stats 800 // store maximal depth 806 801 if (tData.mDepth > mVspStats.maxDepth) 807 802 { 808 Debug << "max depth increases to " << tData.mDepth 809 << " at " << mVspStats.Leaves() << " leaves" << endl; 803 //Debug << "max depth increases to " << tData.mDepth << " at " << mVspStats.Leaves() << " leaves" << endl; 810 804 mVspStats.maxDepth = tData.mDepth; 811 805 } … … 813 807 // two more leaves 814 808 mVspStats.nodes += 2; 815 809 810 811 /////////////////////////////////////////// 812 //-- create front and back and subdivide further 813 816 814 VspInterior *interior = new VspInterior(splitPlane); 817 818 819 //-- create front and back leaf820 821 815 VspInterior *parent = leaf->GetParent(); 822 816 … … 862 856 #endif 863 857 858 // set the time stamp so the order of traversal can be reconstructed 864 859 interior->mTimeStamp = mTimeStamp ++; 865 860 … … 1414 1409 const float viewSpaceVol = mBoundingBox.GetVolume(); 1415 1410 1416 // create unique ids for pvs heuristics 1411 ////////////////////////////////////////////// 1412 // mark objects in the front / back / both using mailboxing 1413 // then count pvs sizes 1417 1414 Intersectable::NewMail(3); 1418 1415 KdLeaf::NewMail(3); … … 1450 1447 1451 1448 1452 //-- pvs rendering heuristics 1449 //////////////////////////////////// 1450 //-- evaluate render cost heuristics 1453 1451 1454 1452 const int lowerPvsLimit = mViewCellsManager->GetMinPvsSize(); 1455 1453 const int upperPvsLimit = mViewCellsManager->GetMaxPvsSize(); 1456 1454 1457 // only render cost heuristics or combined with standard deviation 1458 const float penaltyOld = EvalPvsPenalty((int)totalPvs, lowerPvsLimit, upperPvsLimit); 1455 const float penaltyOld = EvalPvsPenalty((int)totalPvs, lowerPvsLimit, upperPvsLimit); 1459 1456 const float penaltyFront = EvalPvsPenalty((int)pvsFront, lowerPvsLimit, upperPvsLimit); 1460 1457 const float penaltyBack = EvalPvsPenalty((int)pvsBack, lowerPvsLimit, upperPvsLimit); … … 1463 1460 const float newRenderCost = penaltyFront * pFront + penaltyBack * pBack; 1464 1461 1462 // we also return the old render cost 1465 1463 normalizedOldRenderCost = oldRenderCost / viewSpaceVol; 1466 1464 1465 // the render cost decrase for this split 1467 1466 const float renderCostDecrease = (oldRenderCost - newRenderCost) / viewSpaceVol; 1468 1467 #ifdef _DEBUG 1469 1468 Debug << "\neval vsp render cost decrease" << endl 1470 1469 << "back pvs: " << pvsBack << " front pvs " << pvsFront << " total pvs: " << totalPvs << endl … … 1472 1471 << "old rc: " << normalizedOldRenderCost << " new rc: " << newRenderCost / viewSpaceVol << endl 1473 1472 << "render cost decrease: " << renderCostDecrease << endl; 1474 1473 #endif 1475 1474 return renderCostDecrease; 1476 1475 } … … 2651 2650 2652 2651 SubdivisionCandidate *VspTree::PrepareConstruction(const VssRayContainer &sampleRays, 2653 AxisAlignedBox3 *forcedViewSpace,2654 2652 RayInfoContainer &rays) 2655 2653 { … … 2661 2659 VspSubdivisionCandidate::sVspTree = this; 2662 2660 2663 // compute view space bounding box2664 ComputeBoundingBox(sampleRays, forcedViewSpace);2665 2666 2661 // initialise termination criteria 2667 2662 mTermMinProbability *= mBoundingBox.GetVolume(); … … 2672 2667 2673 2668 const int pvsSize = EvalPvsSize(rays); 2674 2675 Debug << "pvs size: " << (int)pvsSize << endl; 2676 Debug << "rays size: " << (int)rays.size() << endl; 2669 //Debug << "pvs size: " << (int)pvsSize << endl; 2670 //Debug << "rays size: " << (int)rays.size() << endl; 2677 2671 2678 2672 //-- prepare view space partition … … 2851 2845 ++ pvsSize; 2852 2846 } 2847 2853 2848 ++ obj->mCounter; 2854 2849 break; … … 2870 2865 pvsSize += (int)leaf->mObjects.size(); 2871 2866 } 2867 2872 2868 ++ leaf->mCounter; 2873 2869 break; -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r1357 r1379 945 945 SubdivisionCandidate *PrepareConstruction( 946 946 const VssRayContainer &sampleRays, 947 AxisAlignedBox3 *forcedViewSpace,948 947 RayInfoContainer &rays); 949 948 -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp
r1344 r1379 30 30 #include "ViewCellsManager.h" 31 31 #include "ResourceManager.h" 32 #include "IntersectableWrapper.h" 32 33 #include <assert.h> 34 33 35 34 36 namespace GtpVisibilityPreprocessor { … … 82 84 // --------------------------------------------------------------------------- 83 85 X3dParseHandlers::X3dParseHandlers(SceneGraphNode *root, 84 const bool load PolygonsAsMeshes):86 const bool loadMeshes): 85 87 mElementCount(0) 86 88 , mAttrCount(0) 87 89 , mCharacterCount(0) 88 90 , mSpaceCount(0) 89 , mLoad PolygonsAsMeshes(loadPolygonsAsMeshes)91 , mLoadMeshes(loadMeshes) 90 92 , mCurrentMesh(NULL) 91 93 { … … 224 226 } 225 227 226 227 //-- each polygon is one single mesh 228 if (mLoadPolygonsAsMeshes) 228 //////////////////////////////////// 229 //-- each triangle is one single mesh 230 231 if (!mLoadMeshes) 229 232 { 230 233 cout << "m"; 231 FaceContainer::const_iterator fit, fit_end = mCurrentMesh->mFaces.end(); 234 Mesh tempMesh(*mCurrentMesh); 235 ApplyTransformations(mTransformations, &tempMesh); 236 237 FaceContainer::const_iterator fit, fit_end = tempMesh.mFaces.end(); 232 238 233 for (fit = mCurrentMesh->mFaces.begin(); fit != fit_end; ++ fit)239 for (fit = tempMesh.mFaces.begin(); fit != fit_end; ++ fit) 234 240 { 235 241 cout << "f"; 242 // triangulate the faces 236 243 Face *face = *fit; 237 244 vector<Triangle3> triangles; 245 Polygon3 poly(face, &tempMesh); 246 poly.Triangulate(triangles); 247 248 vector<Triangle3>::const_iterator tit, tit_end = triangles.end(); 249 250 for (tit = triangles.begin(); tit != tit_end; ++ tit) 251 { 252 cout << "triangle: " << *tit << endl; 253 TriangleIntersectable *ti = new TriangleIntersectable(*tit); 254 mCurrentNode->mGeometry.push_back(ti); 255 } 256 #if 0 238 257 // we create a new mesh for each face from the current mesh 239 258 Mesh *mesh = MeshManager::GetSingleton()->CreateResource(); … … 249 268 cout << "i"; 250 269 const int index = (*vit); 251 252 270 // add vertices 253 271 mesh->mVertices.push_back(mCurrentMesh->mVertices[index]); 254 255 // indices don't make much sense if mesh == face, 256 // but we need them anyway ... 272 // indices don't make much sense if mesh == face, but we need them anyway ... 257 273 vcIndices.push_back(i); 258 274 } … … 260 276 mesh->mFaces.push_back(new Face(vcIndices)); 261 277 262 // write transformations directly in mesh278 // write transformations directly into the mesh 263 279 // note: could be transformed in parent mesh, save some transformations 264 280 ApplyTransformations(mTransformations, mesh); … … 283 299 } 284 300 } 301 #endif 285 302 } 286 303 … … 656 673 X3dParser::ParseFile(const string filename, 657 674 SceneGraphNode *root, 658 const bool load PolygonsAsMeshes,675 const bool loadMeshes, 659 676 vector<FaceParentInfo> *parents) 660 677 { … … 689 706 // to do. 690 707 // 691 X3dParseHandlers handler(root, load PolygonsAsMeshes);708 X3dParseHandlers handler(root, loadMeshes); 692 709 parser->setDocumentHandler(&handler); 693 710 parser->setErrorHandler(&handler); -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.h
r1344 r1379 18 18 const string filename, 19 19 SceneGraphNode *root, 20 const bool load PolygonsAsMeshes = false,20 const bool loadMeshes = false, 21 21 vector<FaceParentInfo> *parents = NULL); 22 22 -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParserXerces.h
r1020 r1379 41 41 // Constructors and Destructor 42 42 // ----------------------------------------------------------------------- 43 X3dParseHandlers(SceneGraphNode *root, const bool load PolygonsAsMeshes = false);43 X3dParseHandlers(SceneGraphNode *root, const bool loadMeshes = false); 44 44 ~X3dParseHandlers(); 45 45 … … 88 88 Material *mCurrentMaterial; 89 89 90 bool mLoad PolygonsAsMeshes;90 bool mLoadMeshes; 91 91 92 92 typedef stack<Matrix4x4> TrafoStack;
Note: See TracChangeset
for help on using the changeset viewer.