Changeset 329 for trunk/VUT/GtpVisibilityPreprocessor
- Timestamp:
- 10/14/05 18:29:26 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r326 r329 56 56 57 57 Sampling { 58 totalSamples 100 58 totalSamples 1000000 59 59 samplesPerPass 20 60 60 } 61 61 62 62 ViewCells { 63 hierarchyType bspTree 63 # hierarchy kdTree 64 hierarchy bspTree 65 # hierarchy sceneDependent 66 64 67 height 5.0 65 68 maxViewCells 0 66 #hierarchyType kdTree 67 #hierarchyType sceneDependent 69 68 70 # filename ../data/atlanta/atlanta_viewcells_large.x3d 69 71 # filename ../data/vienna/viewcells-25-sel.x3d … … 73 75 74 76 BspTree { 75 # constructionMethod fromRays 76 # constructionMethod fromViewCells 77 constructionMethod fromSceneGeometry 77 Construction { 78 input fromRays 79 # input fromViewCells 80 # input fromSceneGeometry 81 samples 50000 82 sideTolerance 0.002 83 } 84 78 85 79 86 # random polygon = 1 … … 101 108 #splitPlaneStrategy 72 102 109 103 splitPlaneStrategy 66110 splitPlaneStrategy 8 104 111 105 112 maxCandidates 50 -
trunk/VUT/GtpVisibilityPreprocessor/src/AxisAlignedBox3.cpp
r321 r329 1674 1674 { 1675 1675 GetVertex(i, vtx); 1676 side[i] = plane.Side(vtx , SIDE_TOLERANCE);1676 side[i] = plane.Side(vtx); 1677 1677 if (side[i] > 0) 1678 1678 onFrontSide = true; -
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r321 r329 1150 1150 "10"); 1151 1151 1152 RegisterOption("ViewCells.hierarchy Type",1152 RegisterOption("ViewCells.hierarchy", 1153 1153 optString, 1154 "-view_cells_hierarchy _type",1154 "-view_cells_hierarchy", 1155 1155 "bspTree"); 1156 1156 … … 1165 1165 "5.0"); 1166 1166 1167 RegisterOption("BspTree. constructionMethod",1167 RegisterOption("BspTree.Construction.input", 1168 1168 optString, 1169 "-bsp_construction_ method=",1169 "-bsp_construction_input=", 1170 1170 "fromViewCells"); 1171 1172 RegisterOption("BspTree.Construction.samples", 1173 optInt, 1174 "-bsp_construction_samples=", 1175 "100000"); 1176 1177 RegisterOption("BspTree.Construction.sideTolerance", 1178 optFloat, 1179 "-bsp_construction_side_tolerance=", 1180 "0.002"); 1181 1171 1182 1172 1183 RegisterOption("BspTree.Termination.maxPolygons", -
trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.h
r311 r329 162 162 163 163 void AddPassingRay(const Ray &ray, const int contributions) { 164 Debug << "here2" << endl;165 164 mPassingRays.AddRay(ray, contributions); 166 Debug << " here4" << endl;165 Debug << "adding passing ray" << endl; 167 166 } 168 167 -
trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp
r327 r329 6 6 #include "Ray.h" 7 7 8 float Polygon3::sSideTolerance = 0.002f; 9 float Polygon3::sSideToleranceSqrt = 0.000004f; 10 8 11 Polygon3::Polygon3(): 9 12 mMaterial(NULL), mParent(NULL), mPiercingRays(NULL) … … 15 18 16 19 Polygon3::Polygon3(MeshInstance *parent): 17 mMaterial(NULL), mParent(parent) 20 mMaterial(NULL), mParent(parent), mPiercingRays(NULL) 18 21 {} 19 22 20 Polygon3::Polygon3(Face *face, Mesh *parentMesh) 23 Polygon3::Polygon3(Face *face, Mesh *parentMesh): 24 mMaterial(NULL), mParent(NULL), mPiercingRays(NULL) 21 25 { 22 26 VertexIndexContainer::iterator it = face->mVertexIndices.begin(); … … 51 55 Vector3 ptA = mVertices.back(); 52 56 53 int sideA = partition.Side(ptA, SIDE_TOLERANCE);57 int sideA = partition.Side(ptA, sSideTolerance); 54 58 55 59 VertexContainer::const_iterator it; … … 60 64 { 61 65 Vector3 ptB = *it; 62 int sideB = partition.Side(ptB, SIDE_TOLERANCE);66 int sideB = partition.Side(ptB, sSideTolerance); 63 67 64 68 // vertices on different sides => split … … 72 76 // test if split point not too close to previous split point 73 77 if (!foundSplit || 74 (SqrDistance(splitPt, splitPts.back()) > SIDE_TOLERANCE_SQRD))78 (SqrDistance(splitPt, splitPts.back()) > sSideToleranceSqrt)) 75 79 { 76 80 // add vertex to both polygons … … 93 97 // test if split point not too close to previous split point 94 98 if (!foundSplit || 95 (SqrDistance(splitPt, splitPts.back()) > SIDE_TOLERANCE_SQRD))99 (SqrDistance(splitPt, splitPts.back()) > sSideToleranceSqrt)) 96 100 { 97 101 // add vertex to both polygons … … 151 155 for (it = mVertices.begin(); it != mVertices.end(); ++ it) 152 156 { 153 int side = plane.Side(*it, SIDE_TOLERANCE);157 int side = plane.Side(*it, sSideTolerance); 154 158 155 159 if (side > 0) … … 361 365 void Polygon3::AddPiercingRay(Ray *ray) 362 366 { 363 if (!mPiercingRays) 364 mPiercingRays = new RayContainer(); 365 //if (binary_search(mPiercingRays.begin(), mPiercingRays.end(), ray)) return false; 366 367 mPiercingRays->push_back(ray); 368 } 367 GetPiercingRays()->push_back(ray); 368 } -
trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.h
r327 r329 104 104 /// Rays piercing this polygon 105 105 RayContainer *mPiercingRays; 106 107 static float sSideTolerance; 108 static float sSideToleranceSqrt; 106 109 }; 107 110 -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp
r327 r329 48 48 // parse type of view cells 49 49 char viewCellsStr[64]; 50 environment->GetStringValue("ViewCells.hierarchy Type", viewCellsStr);50 environment->GetStringValue("ViewCells.hierarchy", viewCellsStr); 51 51 52 52 int vcType = BSP_VIEW_CELLS; 53 53 54 54 if (strcmp(viewCellsStr, "bspTree") == 0) 55 vcType = BSP_VIEW_CELLS; 55 { 56 Debug << "here bsp" << endl; 57 mViewCellsType = BSP_VIEW_CELLS; 58 } 56 59 else if (strcmp(viewCellsStr, "kdTree") == 0) 57 vcType = KD_VIEW_CELLS; 60 { 61 Debug << "here kd" << endl; 62 mViewCellsType = KD_VIEW_CELLS; 63 } 58 64 else if (strcmp(viewCellsStr, "sceneDependent") == 0) 59 vcType = SCENE_DEPENDENT; 65 { 66 //TODO 67 } 60 68 else 61 69 { … … 64 72 } 65 73 66 // decide about view cell subdivision type used for preprocessing 67 switch (vcType) 68 { 69 case BSP_VIEW_CELLS: 70 case KD_VIEW_CELLS: 71 mViewCellsType = vcType; 72 break; 73 case SCENE_DEPENDENT: 74 mViewCellsType = BSP_VIEW_CELLS; // TODO 75 break; 76 } 74 if (mViewCellsType == KD_VIEW_CELLS) 75 Debug << "kdtree" << endl; 76 else if (mViewCellsType == BSP_VIEW_CELLS) 77 Debug << "bsptree" << endl; 77 78 78 79 return true; … … 143 144 } 144 145 145 146 bool147 Preprocessor::BuildBspTree()148 {149 DEL_PTR(mBspTree);150 151 mBspTree = new BspTree(&mUnbounded);152 153 ObjectContainer objects;154 RayContainer *rays = new RayContainer();155 156 switch (BspTree::sConstructionMethod)157 {158 case BspTree::FROM_INPUT_VIEW_CELLS:159 mBspTree->Construct(mViewCells);160 break;161 case BspTree::FROM_SCENE_GEOMETRY:162 DeleteViewCells(); // we generate new view cells163 mSceneGraph->CollectObjects(&objects);164 mBspTree->Construct(objects, &mViewCells);165 break;166 case BspTree::FROM_RAYS:167 DeleteViewCells(); // we generate new view cells168 mSceneGraph->CollectObjects(&objects);169 mBspTree->Construct(rays, &mViewCells);170 break;171 default:172 Debug << "Error: Method not available\n";173 break;174 }175 return true;176 }177 178 179 180 146 void 181 147 Preprocessor::KdTreeStatistics(ostream &s) -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h
r321 r329 30 30 Preprocessor(); 31 31 32 ~Preprocessor();32 virtual ~Preprocessor(); 33 33 34 34 /** Load the input scene. … … 71 71 entities should be used to drive the heuristical construction (only occluders by default) 72 72 */ 73 virtual bool BuildBspTree() ;73 virtual bool BuildBspTree() = 0; 74 74 75 75 /** Compute visibility method. This method has to be reimplemented by the actual -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r327 r329 13 13 environment->GetIntValue("Sampling.samplesPerPass", mSamplesPerPass); 14 14 environment->GetIntValue("Sampling.totalSamples", mTotalSamples); 15 15 environment->GetIntValue("BspTree.Construction.samples", mBspConstructionSamples); 16 16 17 mKdPvsDepth = 100; 17 18 mStats.open("stats.log"); 18 19 20 } 21 22 SamplingPreprocessor::~SamplingPreprocessor() 23 { 24 // clean up 25 if (mSampleRays) 26 { 27 CLEAR_CONTAINER (*mSampleRays); 28 DEL_PTR (mSampleRays); 29 } 19 30 } 20 31 … … 38 49 node = node->mParent; 39 50 return node; 51 } 52 53 bool 54 SamplingPreprocessor::BuildBspTree() 55 { 56 // delete old tree 57 DEL_PTR(mBspTree); 58 mBspTree = new BspTree(&mUnbounded); 59 60 ObjectContainer objects; 61 62 switch (BspTree::sConstructionMethod) 63 { 64 case BspTree::FROM_INPUT_VIEW_CELLS: 65 mBspTree->Construct(mViewCells); 66 break; 67 case BspTree::FROM_SCENE_GEOMETRY: 68 69 DeleteViewCells(); // we generate new view cells 70 mSceneGraph->CollectObjects(&objects); 71 mBspTree->Construct(objects, &mViewCells); 72 73 break; 74 case BspTree::FROM_RAYS: 75 DeleteViewCells(); // we generate new view cells 76 mSceneGraph->CollectObjects(&objects); 77 mBspTree->Construct(mSampleRays, &mViewCells); 78 break; 79 default: 80 Debug << "Error: Method not available\n"; 81 break; 82 } 83 84 return true; 40 85 } 41 86 … … 106 151 // cast ray to KD tree to find intersection with other objects 107 152 mKdTree->CastRay(ray); 108 153 cout << "k"; 109 154 if (mViewCellsType == BSP_VIEW_CELLS) 110 155 { 111 156 // cast ray to BSP tree to get intersection with view cells 112 mBspTree->CastRay(ray); 113 114 sampleContributions += AddObjectSamples(object, ray); 157 if (mBspTree) 158 { 159 cout << "uhhhhhhh year" << endl; 160 mBspTree->CastRay(ray); 161 162 sampleContributions += AddObjectSamples(object, ray); 115 163 116 if (!ray.intersections.empty()) // second intersection found 117 { 118 sampleContributions += 119 AddObjectSamples(ray.intersections[0].mObject, ray); 164 if (!ray.intersections.empty()) // second intersection found 165 { 166 sampleContributions += 167 AddObjectSamples(ray.intersections[0].mObject, ray); 168 } 120 169 } 121 170 } 122 171 else 123 172 { 173 cout << "z" << endl; 124 174 if (ray.leaves.size()) { 125 175 sampleContributions += AddNodeSamples(object, ray); … … 238 288 { 239 289 int idx = Random((int)mViewCells.size()); 240 Debug << "output view cell no." << idx << endl;290 Debug << "output view cell=" << idx << endl; 241 291 pvsViewCells.push_back(mViewCells[Random((int)mViewCells.size())]); 242 292 } … … 246 296 247 297 vector<Ray> viewCellRays; // used for BSP tree construction 248 const int fromRaysBspThresh = 1000; 298 299 mSampleRays = new RayContainer(); 300 //mSampleRays->reserve(mBspConstructionSamples); 249 301 250 302 while (totalSamples < mTotalSamples) { … … 254 306 int index = 0; 255 307 256 // construct Bsp tree if not 257 if ((mViewCellsType == Preprocessor::BSP_VIEW_CELLS) && 258 !mBspTree->GetRoot() && (totalSamples >= fromRaysBspThresh)) 259 { 260 BuildBspTree(); 261 } 262 308 cout << "totalSamples: " << totalSamples; 263 309 for (i = 0; i < objects.size(); i++) { 310 printf("\nsampling object %d of %d, samples %d\n", i, (int)objects.size(), passSamples); 311 264 312 KdNode *nodeToSample = NULL; 265 313 Intersectable *object = objects[i]; … … 324 372 bool viewcellSample = true; 325 373 int sampleContributions; 374 326 375 if (viewcellSample) { 327 376 nodeToSample = mKdTree->GetRandomLeaf(Plane3(normal, point)); 328 377 329 378 for (int k=0; k < mSamplesPerPass; k++) { 330 331 379 if (nodeToSample) { 332 380 int maxTries = 5; … … 336 384 337 385 if (DotProd(direction, normal) > Limits::Small) 338 break; 386 break; 339 387 } 340 388 … … 348 396 // construct a ray 349 397 SetupRay(ray, point, direction); 350 398 cout << "s"; 351 399 sampleContributions = CastRay(object, ray); 352 400 cout << "r"; 353 401 if (mViewCellsType == BSP_VIEW_CELLS) 354 402 { 355 403 // save rays for bsp tree construction 356 if (!mBspTree->GetRoot() && (totalSamples < fromRaysBspThresh)) 404 if ((BspTree::sConstructionMethod = BspTree::FROM_RAYS) && 405 (totalSamples < mBspConstructionSamples)) 357 406 { 358 viewCellRays.push_back(ray); 407 //cout << "pushing back sampling ray << " << mSampleRays->size() << endl; 408 mSampleRays->push_back(new Ray(ray)); 359 409 } 360 // check whether we can add this to the rays 361 for (int k = 0; k < ray.viewCells.size(); ++ k) 362 for (int j = 0; j < (int)pvsViewCells.size(); ++ j) 363 if (pvsViewCells[j] == ray.viewCells[k]) 364 { 365 vcRays[j].push_back(ray); 366 } 410 else 411 { 412 // construct BSP tree using the samples 413 if (!mBspTree) 414 { 415 Debug << "Building bsp tree" << endl; 416 BuildBspTree(); 417 418 CLEAR_CONTAINER (*mSampleRays); 419 DEL_PTR (mSampleRays); 420 } 421 // check whether we can add this to the rays 422 for (int k = 0; k < ray.viewCells.size(); ++ k) 423 for (int j = 0; j < (int)pvsViewCells.size(); ++ j) 424 if (pvsViewCells[j] == ray.viewCells[k]) 425 { 426 vcRays[j].push_back(ray); 427 } 428 } 367 429 } 430 368 431 } 369 432 } else { … … 371 434 // get random visible mesh 372 435 // object->GetRandomVisibleMesh(Plane3(normal, point)); 373 374 375 } 376 436 } 437 377 438 // NOTE: should be inside loop 378 439 if ( i < pvsOut ) 379 440 rays[i].push_back(ray); 380 441 381 442 if (!ray.intersections.empty()) { 382 443 // check whether we can add this to the rays … … 387 448 } 388 449 } 389 450 390 451 passSamples++; 391 452 392 453 if (sampleContributions) { 393 454 passContributingSamples++; … … 395 456 } 396 457 } 397 458 cout << "pass samples: " << passSamples << endl; 398 459 totalSamples += passSamples; 399 460 … … 439 500 << endl; 440 501 } 441 502 442 503 if (mViewCellsType == KD_VIEW_CELLS) 443 504 cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.h
r308 r329 23 23 ofstream mStats; 24 24 ObjectContainer mObjects; 25 RayContainer *mSampleRays; 26 int mBspConstructionSamples; 25 27 26 28 SamplingPreprocessor(); 29 30 ~SamplingPreprocessor(); 27 31 28 32 virtual bool ComputeVisibility(); … … 54 58 */ 55 59 int AddObjectSamples(Intersectable *obj, const Ray &ray); 60 61 bool BuildBspTree(); 56 62 }; 57 63 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r328 r329 286 286 return splits; 287 287 } 288 288 289 void BspInterior::InheritRays(const Polygon3 &poly, 289 290 Polygon3 &front_piece, … … 427 428 { 428 429 std::stack<BspTraversalData> tStack; 429 430 // traverse tree or create new one431 430 431 // traverse existing tree or create new tree 432 BspNode *firstNode = mRoot ? mRoot : new BspLeaf(); 432 433 433 434 tStack.push(BspTraversalData(firstNode, polys, 0, mRootCell, new RayContainer())); … … 497 498 else // reached leaf => subdivide current viewcell 498 499 { 499 BspNode *root = Subdivide(tStack, tData); 500 501 if (viewCells && root->IsLeaf()) 502 { 503 // generate new view cell for each leaf 504 ViewCell *viewCell = new ViewCell(); 505 viewCells->push_back(viewCell); 500 // root of the new subtree 501 BspNode *subRoot = Subdivide(tStack, tData); 502 503 // generate new view cell for each leaf 504 if (viewCells && subRoot->IsLeaf()) 505 GenerateViewCell(dynamic_cast<BspLeaf *>(subRoot), *viewCells); 506 } 507 } 508 } 509 510 void BspTree::GenerateViewCell(BspLeaf *leaf, ViewCellContainer &viewCells) const 511 { 512 ViewCell *viewCell = new ViewCell(); 513 viewCells.push_back(viewCell); 506 514 507 dynamic_cast<BspLeaf *>(root)->SetViewCell(viewCell); 508 } 509 510 if (!mRoot) // tree empty => new root 511 mRoot = root; 512 } 513 } 515 leaf->SetViewCell(viewCell); 514 516 } 515 517 … … 593 595 594 596 // construct tree from the view cell polygons 595 Construct(polys, NULL);597 Construct(polys, new RayContainer()); 596 598 } 597 599 … … 608 610 609 611 // construct tree from polygon soup 610 Construct(polys, NULL, viewCells);612 Construct(polys, new RayContainer(), viewCells); 611 613 } 612 614 … … 664 666 { 665 667 std::stack<BspTraversalData> tStack; 666 668 667 669 BspTraversalData tData(new BspLeaf(), polys, 0, mRootCell, rays); 670 668 671 tStack.push(tData); 669 672 670 673 long startTime = GetTime(); 671 Debug << "**** Contructing tree using scene geometry ****\n"; 674 cout << "**** Contructing tree using scene geometry ****\n"; 675 672 676 while (!tStack.empty()) 673 677 { … … 676 680 677 681 // subdivide leaf node 678 BspNode *root = Subdivide(tStack, tData); 679 680 if (viewCells && root->IsLeaf()) 681 { // generate new view cell for each leaf 682 ViewCell *viewCell = new ViewCell(); 683 viewCells->push_back(viewCell); 684 685 dynamic_cast<BspLeaf *>(root)->SetViewCell(viewCell); 686 } 687 688 // empty tree => new root corresponding to unbounded space 689 if (!mRoot) 690 mRoot = root; 691 } 692 693 Debug << "**** Finished tree construction ****\n"; 682 BspNode *subRoot = Subdivide(tStack, tData); 683 684 if (viewCells && subRoot->IsLeaf()) 685 GenerateViewCell(dynamic_cast<BspLeaf *>(subRoot), *viewCells); 686 } 687 688 cout << "**** Finished tree construction ****\n"; 694 689 Debug << "BSP tree contruction time: " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 695 690 } … … 716 711 leaf->ProcessPolygons(tData.mPolygons, sStoreSplitPolys); 717 712 DEL_PTR(tData.mPolygons); 718 719 if (tData.mRays)720 CLEAR_CONTAINER(*tData.mRays);721 713 DEL_PTR(tData.mRays); 722 714 … … 724 716 } 725 717 726 727 718 //-- continue subdivision 719 728 720 PolygonContainer coincident; 729 730 BspSplitData splitData; 731 732 splitData.mPolys = tData.mPolygons; 733 splitData.mFrontPolys = new PolygonContainer(), 734 splitData.mBackPolys = new PolygonContainer(); 735 splitData.mCoincident = &coincident; 736 737 splitData.mRays = tData.mRays; 738 splitData.mFrontRays = new RayContainer(); 739 splitData.mBackRays = new RayContainer(); 721 722 PolygonContainer *frontPolys = new PolygonContainer(); 723 PolygonContainer *backPolys = new PolygonContainer(); 724 725 RayContainer *frontRays = new RayContainer(); 726 RayContainer *backRays = new RayContainer(); 727 740 728 741 729 // create new interior node and two leaf nodes 742 BspInterior *interior = 743 SubdivideNode(dynamic_cast<BspLeaf *>(tData.mNode), splitData); 730 BspInterior *interior = SubdivideNode(dynamic_cast<BspLeaf *>(tData.mNode), 731 *tData.mPolygons, 732 *frontPolys, 733 *backPolys, 734 coincident, 735 *tData.mRays, 736 *frontRays, 737 *backRays); 744 738 745 739 ViewCell *frontViewCell = mRootCell; … … 757 751 ExtractViewCells(&backViewCell, 758 752 &frontViewCell, 759 *splitData.mCoincident,753 coincident, 760 754 interior->mPlane, 761 splitData.mBackPolys->empty(),762 splitData.mFrontPolys->empty());755 backPolys->empty(), 756 frontPolys->empty()); 763 757 764 758 // don't need coincident polygons anymore … … 767 761 // push the children on the stack 768 762 tStack.push(BspTraversalData(interior->GetBack(), 769 splitData.mBackPolys,763 backPolys, 770 764 tData.mDepth + 1, 771 765 backViewCell, 772 splitData.mBackRays));766 backRays)); 773 767 774 768 tStack.push(BspTraversalData(interior->GetFront(), 775 splitData.mFrontPolys,769 frontPolys, 776 770 tData.mDepth + 1, 777 771 frontViewCell, 778 splitData.mFrontRays));772 frontRays)); 779 773 780 774 // cleanup … … 817 811 818 812 BspInterior *BspTree::SubdivideNode(BspLeaf *leaf, 819 BspSplitData &splitData) 813 PolygonContainer &polys, 814 PolygonContainer &frontPolys, 815 PolygonContainer &backPolys, 816 PolygonContainer &coincident, 817 RayContainer &rays, 818 RayContainer &backRays, 819 RayContainer &frontRays) 820 820 { 821 821 mStat.nodes += 2; … … 823 823 // select subdivision plane 824 824 BspInterior *interior = 825 new BspInterior(SelectPlane(leaf, *splitData.mPolys, *splitData.mRays));825 new BspInterior(SelectPlane(leaf, polys, rays)); 826 826 827 827 #ifdef _DEBUG 828 828 Debug << interior << endl; 829 829 #endif 830 830 831 831 // partition rays 832 interior->SplitRays(*splitData.mRays, 833 *splitData.mFrontRays, 834 *splitData.mBackRays); 835 832 interior->SplitRays(rays, frontRays, backRays); 833 Debug << "jdfjfj43" << endl; 836 834 // split polygons with split plane 837 mStat.splits +=interior->SplitPolygons( *splitData.mPolys,838 *splitData.mFrontPolys,839 *splitData.mBackPolys,840 *splitData.mCoincident,835 mStat.splits +=interior->SplitPolygons(polys, 836 frontPolys, 837 backPolys, 838 coincident, 841 839 sStoreSplitPolys); 842 843 840 BspInterior *parent = leaf->GetParent(); 844 841 845 842 // replace a link from node's parent 846 if ( parent)843 if (!leaf->IsRoot()) 847 844 { 848 845 parent->ReplaceChildLink(leaf, interior); 849 846 interior->SetParent(parent); 847 } 848 else // new root 849 { 850 mRoot = interior; 850 851 } 851 852 … … 1199 1200 char constructionMethodStr[60]; 1200 1201 1201 environment->GetStringValue("BspTree. constructionMethod", constructionMethodStr);1202 environment->GetStringValue("BspTree.Construction.input", constructionMethodStr); 1202 1203 1203 1204 sConstructionMethod = FROM_INPUT_VIEW_CELLS; … … 1230 1231 1231 1232 environment->GetBoolValue("BspTree.storeSplitPolys", sStoreSplitPolys); 1233 1234 environment->GetFloatValue("BspTree.Construction.sideTolerance", Polygon3::sSideTolerance); 1235 Polygon3::sSideToleranceSqrt = Polygon3::sSideTolerance * Polygon3::sSideTolerance; 1232 1236 1233 1237 Debug << "BSP max depth: " << sTermMaxDepth << endl; … … 1471 1475 } 1472 1476 1477 1473 1478 //} // GtpVisibilityPreprocessor -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r328 r329 276 276 {} 277 277 }; 278 279 /** given as argument for a node subdivision. 280 Stores the polyons and rays and the returned 281 front and back fragments. 282 */ 283 struct BspSplitData 284 { 285 PolygonContainer *mPolys; 286 PolygonContainer *mFrontPolys; 287 PolygonContainer *mBackPolys; 288 PolygonContainer *mCoincident; 289 RayContainer *mRays; 290 RayContainer *mBackRays; 291 RayContainer *mFrontRays; 292 }; 293 278 294 279 typedef std::stack<BspTraversalData> BspTraversalStack; 295 280 … … 427 412 /** Subdivide leaf. 428 413 @param leaf the leaf to be subdivided 429 @param splitData data relevant for the splti 414 415 @param polys the polygons to be split 416 @param frontPolys returns the polygons in front of the split plane 417 @param backPolys returns the polygons in the back of the split plane 418 419 @param rays the polygons to be filtered 420 @param frontRays returns the polygons in front of the split plane 421 @param backRays returns the polygons in the back of the split plane 422 430 423 @returns the root of the subdivision 431 424 */ 432 425 BspInterior *SubdivideNode(BspLeaf *leaf, 433 BspSplitData &splitData); 426 PolygonContainer &polys, 427 PolygonContainer &frontPolys, 428 PolygonContainer &backPolys, 429 PolygonContainer &coincident, 430 RayContainer &rays, 431 RayContainer &backRays, 432 RayContainer &frontRays); 434 433 435 434 /** Filters polygons down the tree. … … 528 527 529 528 529 /** Generates new view cell for a leaf and stores it back in the container. 530 */ 531 void BspTree::GenerateViewCell(BspLeaf *leaf, ViewCellContainer &viewCells) const; 532 530 533 /// Pointer to the root of the tree 531 534 BspNode *mRoot; -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp
r327 r329 615 615 } 616 616 617 617 618 struct BspSplitData 618 619 { … … 628 629 {}; 629 630 BspSplitData(BspNode *node, 630 631 632 631 vector<Plane3 *> planes, 632 vector<bool> sides, 633 bool isFront): 633 634 mNode(node), mPlanes(planes), 634 635 mSides(sides), mIsFront(isFront) … … 686 687 687 688 tData.mPlanes.push_back(interior->GetPlane()); // add plane to split planes 689 688 690 if (planePoly->Valid()) 689 691 polys.push_back(planePoly); -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.h
r313 r329 78 78 static ViewCellContainer foundViewCells; // todo: remove this 79 79 protected: 80 80 81 virtual void 81 82 ExportSceneNode(SceneGraphNode *node); -
trunk/VUT/GtpVisibilityPreprocessor/src/common.h
r312 r329 127 127 #define MAX_FLOAT 1e30f 128 128 129 // tolerance value for side relation 130 #define SIDE_TOLERANCE 0.002f // TODO: Test different values 131 #define SIDE_TOLERANCE_SQRD 0.000004f 129 130 // tolerance value for polygon area 132 131 #define AREA_LIMIT 0.0001f 133 132 -
trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp
r322 r329 42 42 !(BspTree::sConstructionMethod == BspTree::FROM_RAYS)) // construct tree later 43 43 { 44 Debug << "do1" << endl; 44 45 if (BspTree::sConstructionMethod == BspTree::FROM_INPUT_VIEW_CELLS) 45 46 { … … 56 57 } 57 58 59 Debug << "do2" << endl; 58 60 p->BuildBspTree(); 59 61 p->Export("vc_bsptree.x3d", false, false, true); … … 62 64 bool exportSplits = false; 63 65 environment->GetBoolValue("BspTree.exportSplits", exportSplits); 64 66 Debug << "do3" << endl; 65 67 // export the bsp splits 66 68 if (exportSplits)
Note: See TracChangeset
for help on using the changeset viewer.