Changeset 465 for trunk/VUT/GtpVisibilityPreprocessor
- Timestamp:
- 12/14/05 19:17:40 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r462 r465 13 13 #;../data/vienna/vienna-plane.x3d 14 14 # filename ../data/vienna/viewcells-25-sel.x3d 15 filename ../data/atlanta/atlanta2.x3d15 # filename ../data/atlanta/atlanta2.x3d 16 16 # filename ../data/soda/soda.dat 17 #filename ../data/soda/soda5.dat17 filename ../data/soda/soda5.dat 18 18 } 19 19 … … 26 26 VssPreprocessor { 27 27 samplesPerPass 100000 28 initialSamples 100000029 vssSamples 300000028 initialSamples 500000 29 vssSamples 200000 30 30 vssSamplesPerPass 100000 31 31 useImportanceSampling true … … 38 38 39 39 maxDepth 40 40 minPvs 3 41 minRays 100 40 minPvs 30 41 minRays 1000 42 42 minSize 0.001 43 maxCostRatio 2.043 maxCostRatio 0.9 44 44 maxRayContribution 0.05 45 45 46 46 maxTotalMemory 200 47 maxStaticMemory 10047 maxStaticMemory 20 48 48 49 49 splitType regular … … 284 284 Termination { 285 285 maxDepth 40 286 minPvs 90287 minRays 10286 minPvs 5 287 minRays 500 288 288 minSize 0.1 289 289 maxCostRatio 999.0 … … 299 299 300 300 # maximal cost for merging a view cell 301 maxCostRatio 1.4 301 PostProcess { 302 maxCostRatio 5000000 303 minViewCells 100 304 maxPvsSize 50000 305 } 302 306 } 303 307 -
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r464 r465 1398 1398 "100000"); 1399 1399 1400 RegisterOption("VspKdTree.maxCostRatio",1401 optFloat,1402 "-vsp_kd_max_cost_ratio=",1403 "1.5");1404 1405 1400 RegisterOption("VspKdTree.Termination.maxDepth", 1406 1401 optInt, … … 1480 1475 "vsp_min_colldepth=", 1481 1476 "4"); 1482 1477 1478 RegisterOption("VspKdTree.PostProcess.maxCostRatio", 1479 optFloat, 1480 "-vsp_kd_post_process_max_cost_ratio=", 1481 "1.5"); 1482 1483 RegisterOption("VspKdTree.PostProcess.minViewCells", 1484 optInt, 1485 "vsp_term_post_process_min_view_cells=", 1486 "1000"); 1487 1488 RegisterOption("VspKdTree.PostProcess.maxPvsSize", 1489 optInt, 1490 "vsp_term_post_process_max_pvs_size=", 1491 "100"); 1492 1483 1493 /************************************************************************************/ 1484 1494 /* VSS Preprocessor cells related options */ -
trunk/VUT/GtpVisibilityPreprocessor/src/RenderSimulator.cpp
r463 r465 338 338 339 339 340 /******************************************************** /341 /* class BspRenderSimulator implementation */342 /******************************************************** /340 /*************************************************************/ 341 /* class VspKdRenderSimulator implementation */ 342 /*************************************************************/ 343 343 344 344 … … 358 358 359 359 SimulationStatistics VspKdRenderSimulator::SimulateRendering() 360 { 361 SimulationStatistics simStat; 360 {SimulationStatistics simStat; 362 361 363 362 simStat.Reset(); 364 363 simStat.Start(); 365 364 366 // TODO 365 Real renderTime = 0; 366 367 // overhead for loading the PVS of the view cells 368 float loadPvsOverhead = 0; 369 // probability that view point lies in a view cell 370 float pInVcTotal = 0; 371 372 // total probability that a view cell border is crossed 373 /* const float pCrossVcTotal = mVspBspTree->GetBoundingBox().SurfaceArea(); 374 375 // collect all view cells 376 ViewCellContainer viewCells; 377 mVspBspTree->CollectViewCells(viewCells); 378 379 ViewCellContainer::const_iterator it, it_end = viewCells.end(); 380 381 // surface area substitute for probability 382 PolygonContainer geom; 383 float overallarea = 0; 384 for (it = viewCells.begin(); it != it_end; ++ it) 385 { 386 // compute view cell area 387 mVspBspTree->ConstructGeometry(dynamic_cast<BspViewCell *>(*it), geom); 388 389 const float area = Polygon3::GetArea(geom); 390 if (area < 0.0001) 391 Debug << "warning, area: " << area << endl; 392 CLEAR_CONTAINER(geom); 393 394 // area substitute for view point probability 395 float pInVc = area; 396 397 // compute render time of PVS times probability that view point is in view cell 398 float vcCost = pInVc * RenderPvs(*(*it), mObjRenderCost); 399 //Debug << "p: " << pInVc << " rendercost: " << RenderPvs(*(*it), mObjRenderCost) << endl; 400 renderTime += vcCost; 401 402 if (vcCost > simStat.maxCost) 403 simStat.maxCost = vcCost; 404 else if (vcCost < simStat.minCost) 405 simStat.minCost = vcCost; 406 407 // probability that a view cell border is crossed 408 float pCrossVc = area * mMoveSpeed; 409 410 // crossing the border of a view cell is also depending on the move speed 411 loadPvsOverhead += pCrossVc * mVcOverhead; 412 overallarea += area; 413 pInVcTotal += pInVc; 414 } 415 Debug << "overall area: " << overallarea << endl; 416 417 renderTime /= pInVcTotal; 418 loadPvsOverhead /= pCrossVcTotal; 419 420 simStat.avgRtWithoutOverhead = renderTime; 421 simStat.avgRenderTime = renderTime + loadPvsOverhead; 422 423 simStat.maxCost /= pInVcTotal; 424 simStat.minCost /= pInVcTotal; 425 367 426 simStat.Stop(); 368 427 */ 369 428 return simStat; 370 429 } 371 430 372 431 Real VspKdRenderSimulator::RenderPvs(ViewCell &viewCell, 373 432 float objRenderTime) const 374 433 { 375 434 return 0; // TODO -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r463 r465 1037 1037 return 0; 1038 1038 1039 if (castRay)1040 mVspKdTree->CastRay(ray);1039 // if (castRay) 1040 // mVspKdTree->CastRay(ray); 1041 1041 1042 1042 int sampleContributions = 0; … … 1064 1064 if (!ViewCellsConstructed()) 1065 1065 return; 1066 1067 bool exportRays = true; 1066 1068 1067 1069 //-- export tree leaves … … 1073 1075 exporter->ExportVspKdTree(*mVspKdTree); 1074 1076 1075 if ( 0)1077 if (1) 1076 1078 exporter->ExportGeometry(objects); 1077 1078 bool exportRays = false;1079 1079 1080 1080 if (exportRays) … … 1149 1149 //-- export final view cells 1150 1150 Exporter *exporter = Exporter::GetExporter("vspkdtree_merged.x3d"); 1151 //exporter->SetWireframe();1151 exporter->SetWireframe(); 1152 1152 //exporter->ExportVspKdTreeViewCells(*mVspKdTree, vcStats.maxPvs); 1153 1153 exporter->ExportVspKdTreeViewCells(*mVspKdTree); 1154 1154 1155 Debug << "average PVS size: " << mVspKdTree->GetAvgPvsSize() << endl;1156 1157 if (0)1155 if (1) 1156 { 1157 exporter->SetFilled(); 1158 1158 exporter->ExportGeometry(objects); 1159 1160 bool exportRays = false; 1161 1159 } 1162 1160 if (exportRays) 1163 1161 { -
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp
r463 r465 44 44 if (!object) 45 45 return; 46 47 if (side <= 0) 48 { 49 if (!object->Mailed() && !object->Mailed(2)) 46 47 if (side <= 0) 48 { 49 if (!object->Mailed() && !object->Mailed(2)) 50 50 { 51 51 ++ pvsBack; … … 57 57 } 58 58 } 59 59 60 60 if (side >= 0) 61 61 { 62 if (!object->Mailed(1) && !object->Mailed(2)) 62 if (!object->Mailed(1) && !object->Mailed(2)) 63 63 { 64 64 ++ pvsFront; … … 78 78 // Inline constructor 79 79 VspKdNode::VspKdNode(VspKdInterior *p): 80 mParent(p), mAxis(-1), mDepth(p ? p->mDepth + 1 : 0) 80 mParent(p), mAxis(-1), mDepth(p ? p->mDepth + 1 : 0) 81 81 {} 82 82 83 VspKdNode::~VspKdNode() 83 VspKdNode::~VspKdNode() 84 84 {}; 85 85 … … 94 94 } 95 95 96 bool VspKdNode::IsLeaf() const 97 { 98 return mAxis == -1; 99 } 100 101 int VspKdNode::GetAccessTime() 96 bool VspKdNode::IsLeaf() const 97 { 98 return mAxis == -1; 99 } 100 101 int VspKdNode::GetAccessTime() 102 102 { 103 103 return 0x7FFFFFF; … … 118 118 } 119 119 120 void VspKdInterior::SetupChildLinks(VspKdNode *b, VspKdNode *f) 120 void VspKdInterior::SetupChildLinks(VspKdNode *b, VspKdNode *f) 121 121 { 122 122 mBack = b; … … 126 126 } 127 127 128 void VspKdInterior::ReplaceChildLink(VspKdNode *oldChild, 128 void VspKdInterior::ReplaceChildLink(VspKdNode *oldChild, 129 129 VspKdNode *newChild) 130 130 { … … 135 135 } 136 136 137 int VspKdInterior::Type() const 138 { 139 return EInterior; 140 } 141 137 int VspKdInterior::Type() const 138 { 139 return EInterior; 140 } 141 142 142 VspKdInterior::~VspKdInterior() 143 143 { … … 145 145 DEL_PTR(mFront); 146 146 } 147 148 void VspKdInterior::Print(ostream &s) const 147 148 void VspKdInterior::Print(ostream &s) const 149 149 { 150 150 switch (mAxis) … … 163 163 mFront->Print(s); 164 164 } 165 166 int VspKdInterior::ComputeRayIntersection(const RayInfo &rayData, float &t) 165 166 int VspKdInterior::ComputeRayIntersection(const RayInfo &rayData, float &t) 167 167 { 168 168 return rayData.ComputeRayIntersection(mAxis, mPosition, t); … … 191 191 } 192 192 193 VspKdLeaf::~VspKdLeaf() 194 { 195 } 196 197 int VspKdLeaf::Type() const 198 { 199 return ELeaf; 200 } 201 202 void VspKdLeaf::Print(ostream &s) const 193 VspKdLeaf::~VspKdLeaf() 194 { 195 } 196 197 int VspKdLeaf::Type() const 198 { 199 return ELeaf; 200 } 201 202 void VspKdLeaf::Print(ostream &s) const 203 203 { 204 204 s << endl << "L: r = " << (int)mRays.size() << endl; 205 205 }; 206 206 207 void VspKdLeaf::AddRay(const RayInfo &data) 207 void VspKdLeaf::AddRay(const RayInfo &data) 208 208 { 209 209 mValidPvs = false; … … 212 212 } 213 213 214 int VspKdLeaf::GetPvsSize() const 214 int VspKdLeaf::GetPvsSize() const 215 215 { 216 216 return mPvsSize; 217 217 } 218 218 219 void VspKdLeaf::SetPvsSize(const int s) 219 void VspKdLeaf::SetPvsSize(const int s) 220 220 { 221 221 mPvsSize = s; … … 223 223 224 224 void VspKdLeaf::Mail() 225 { 226 mMailbox = sMailId; 227 } 228 229 void VspKdLeaf::NewMail() 230 { 231 ++ sMailId; 232 } 233 234 bool VspKdLeaf::Mailed() const 235 { 236 return mMailbox == sMailId; 225 { 226 mMailbox = sMailId; 227 } 228 229 void VspKdLeaf::NewMail() 230 { 231 ++ sMailId; 232 } 233 234 bool VspKdLeaf::Mailed() const 235 { 236 return mMailbox == sMailId; 237 237 } 238 238 … … 247 247 } 248 248 249 float VspKdLeaf::GetAvgRayContribution() const 249 float VspKdLeaf::GetAvgRayContribution() const 250 250 { 251 251 return GetPvsSize() / ((float)mRays.size() + Limits::Small); 252 252 } 253 253 254 float VspKdLeaf::GetSqrRayContribution() const 254 float VspKdLeaf::GetSqrRayContribution() const 255 255 { 256 256 return sqr(GetAvgRayContribution()); … … 296 296 void VspKdLeaf::UpdatePvsSize() 297 297 { 298 if (!mValidPvs) 298 if (!mValidPvs) 299 299 { 300 300 Intersectable::NewMail(); 301 301 int pvsSize = 0; 302 for(RayInfoContainer::iterator ri = mRays.begin(); 302 for(RayInfoContainer::iterator ri = mRays.begin(); 303 303 ri != mRays.end(); ++ ri) 304 304 { 305 if ((*ri).mRay->IsActive()) 305 if ((*ri).mRay->IsActive()) 306 306 { 307 307 Intersectable *object; 308 308 #if BIDIRECTIONAL_RAY 309 309 object = (*ri).mRay->mOriginObject; 310 311 if (object && !object->Mailed()) 310 311 if (object && !object->Mailed()) 312 312 { 313 313 ++ pvsSize; … … 316 316 #endif 317 317 object = (*ri).mRay->mTerminationObject; 318 if (object && !object->Mailed()) 318 if (object && !object->Mailed()) 319 319 { 320 320 ++ pvsSize; … … 336 336 337 337 VspKdTree::VspKdTree(): mOnlyDrivingAxis(true) 338 { 338 { 339 339 environment->GetIntValue("VspKdTree.Termination.maxDepth", mTermMaxDepth); 340 340 environment->GetIntValue("VspKdTree.Termination.minPvs", mTermMinPvs); … … 348 348 environment->GetFloatValue("VspKdTree.epsilon", mEpsilon); 349 349 environment->GetFloatValue("VspKdTree.ct_div_ci", mCtDivCi); 350 350 351 351 environment->GetFloatValue("VspKdTree.maxTotalMemory", mMaxTotalMemory); 352 352 environment->GetFloatValue("VspKdTree.maxStaticMemory", mMaxStaticMemory); 353 353 354 354 environment->GetIntValue("VspKdTree.accessTimeThreshold", mAccessTimeThreshold); 355 355 environment->GetIntValue("VspKdTree.minCollapseDepth", mMinCollapseDepth); 356 356 357 environment->GetFloatValue("VspKdTree.maxCostRatio", mMaxCostRatio); 358 environment->GetIntValue("ViewCells.maxViewCells", mMaxViewCells); 359 360 MergeCandidate::sMaxPvsSize = 300; // TODO: add option 357 //environment->GetIntValue("ViewCells.maxViewCells", mMaxViewCells); 358 359 environment->GetIntValue("VspKdTree.PostProcess.minViewCells", mMinViewCells); 360 environment->GetFloatValue("VspKdTree.PostProcess.maxCostRatio", mMaxCostRatio); 361 environment->GetIntValue("VspKdTree.PostProcess.maxPvsSize", 362 MergeCandidate::sMaxPvsSize); 361 363 362 364 // split type … … 364 366 environment->GetStringValue("VspKdTree.splitType", sname); 365 367 string name(sname); 366 368 367 369 Debug << "======= vsp kd tree options ========" << endl; 368 370 Debug << "max depth: "<< mTermMaxDepth << endl; … … 385 387 splitType = ESplitHeuristic; 386 388 } 387 else 389 else 388 390 { 389 391 cerr << "Invalid VspKdTree split type " << name << endl; … … 410 412 app << "#N_RAYS ( Number of rays )\n" 411 413 << rays << endl; 412 414 413 415 app << "#N_INITPVS ( Initial PVS size )\n" 414 416 << initialPvsSize << endl; 415 417 416 418 app << "#N_NODES ( Number of nodes )\n" << nodes << "\n"; 417 419 … … 419 421 420 422 app << "#N_SPLITS ( Number of splits in axes x y z dx dy dz \n"; 421 423 422 424 for (int i=0; i<7; i++) 423 425 app << splits[i] <<" "; … … 478 480 ViewCell::NewMail(); 479 481 480 while (!nodeStack.empty()) 482 while (!nodeStack.empty()) 481 483 { 482 484 VspKdNode *node = nodeStack.top(); 483 485 nodeStack.pop(); 484 486 485 if (node->IsLeaf()) 487 if (node->IsLeaf()) 486 488 { 487 489 ViewCell *viewCell = dynamic_cast<VspKdLeaf *>(node)->mViewCell; 488 490 489 if (!viewCell->Mailed()) 491 if (!viewCell->Mailed()) 490 492 { 491 493 viewCell->Mail(); … … 493 495 } 494 496 } 495 else 497 else 496 498 { 497 499 VspKdInterior *interior = dynamic_cast<VspKdInterior *>(node); … … 507 509 { 508 510 mStat.Start(); 509 511 510 512 mMaxMemory = mMaxStaticMemory; 511 513 DEL_PTR(mRoot); … … 515 517 // first construct a leaf that will get subdivided 516 518 VspKdLeaf *leaf = dynamic_cast<VspKdLeaf *>(mRoot); 517 519 518 520 mStat.nodes = 1; 519 521 mBox.Initialize(); … … 528 530 mBox.Include((*ri)->GetOrigin()); 529 531 if ((*ri)->mTerminationObject) 530 mBox.Include((*ri)->GetTermination()); 532 mBox.Include((*ri)->GetTermination()); 531 533 } 532 534 … … 537 539 //leaf->AddRay(RayInfo(*ri)); 538 540 VssRay *ray = *ri; 539 541 540 542 float minT, maxT; 541 543 … … 544 546 { 545 547 float len = ray->Length(); 546 547 if (!len) 548 549 if (!len) 548 550 len = Limits::Small; 549 550 leaf->AddRay(RayInfo(ray, minT / len, maxT / len)); 551 } 552 } 553 551 552 leaf->AddRay(RayInfo(ray, minT / len, maxT / len)); 553 } 554 } 555 554 556 mStat.rays = (int)leaf->mRays.size(); 555 557 leaf->UpdatePvsSize(); 556 558 557 559 mStat.initialPvsSize = leaf->GetPvsSize(); 558 560 559 561 // Subdivide(); 560 562 mRoot = Subdivide(TraversalData(leaf, mBox, 0)); 561 563 562 if (mSplitCandidates) 564 if (mSplitCandidates) 563 565 { 564 566 // force release of this vector … … 566 568 mSplitCandidates = new vector<SortableEntry>; 567 569 } 568 570 569 571 mStat.Stop(); 570 572 … … 581 583 priority_queue<TraversalData> tStack; 582 584 //stack<TraversalData> tStack; 583 585 584 586 tStack.push(tdata); 585 587 586 588 AxisAlignedBox3 backBox; 587 589 AxisAlignedBox3 frontBox; 588 590 589 591 int lastMem = 0; 590 592 591 while (!tStack.empty()) 593 while (!tStack.empty()) 592 594 { 593 595 float mem = GetMemUsage(); 594 595 if (lastMem / 10 != ((int)mem) / 10) 596 597 if (lastMem / 10 != ((int)mem) / 10) 596 598 { 597 599 Debug << mem << " MB" << endl; 598 600 } 599 601 lastMem = (int)mem; 600 601 if (1 && mem > mMaxMemory) 602 603 if (1 && mem > mMaxMemory) 602 604 { 603 605 Debug << "memory limit reached: " << mem << endl; 604 606 // count statistics on unprocessed leafs 605 while (!tStack.empty()) 607 while (!tStack.empty()) 606 608 { 607 609 EvaluateLeafStats(tStack.top()); … … 610 612 break; 611 613 } 612 614 613 615 TraversalData data = tStack.top(); 614 tStack.pop(); 615 616 tStack.pop(); 617 616 618 VspKdNode *node = SubdivideNode((VspKdLeaf *) data.mNode, 617 619 data.mBox, backBox, frontBox); 618 620 if (result == NULL) 619 621 result = node; 620 621 if (!node->IsLeaf()) 622 623 if (!node->IsLeaf()) 622 624 { 623 625 VspKdInterior *interior = dynamic_cast<VspKdInterior *>(node); … … 626 628 tStack.push(TraversalData(interior->GetBack(), backBox, data.mDepth + 1)); 627 629 tStack.push(TraversalData(interior->GetFront(), frontBox, data.mDepth + 1)); 628 } 629 else 630 } 631 else 630 632 { 631 633 EvaluateLeafStats(data); … … 649 651 int axis = 0; 650 652 float costRatio = 0; 651 652 if (splitType == ESplitRegular) 653 654 if (splitType == ESplitRegular) 653 655 { 654 656 costRatio = BestCostRatioRegular(leaf, … … 659 661 pvsBack, 660 662 pvsFront); 661 } 663 } 662 664 else if (splitType == ESplitHeuristic) 663 665 { 664 666 costRatio = BestCostRatioHeuristic(leaf, 665 axis, 667 axis, 666 668 position, 667 669 raysBack, … … 670 672 pvsFront); 671 673 } 672 else 674 else 673 675 { 674 676 cerr << "VspKdTree: Unknown split heuristics\n"; … … 676 678 } 677 679 678 if (costRatio > mTermMaxCostRatio) 680 if (costRatio > mTermMaxCostRatio) 679 681 { 680 682 Debug << "Too big cost ratio " << costRatio << endl; … … 683 685 684 686 if (0) 685 Debug << "pvs=" << leaf->mPvsSize 686 << " rays=" << (int)leaf->mRays.size() 687 << " rc=" << leaf->GetAvgRayContribution() 687 Debug << "pvs=" << leaf->mPvsSize 688 << " rays=" << (int)leaf->mRays.size() 689 << " rc=" << leaf->GetAvgRayContribution() 688 690 << " axis=" << axis << endl; 689 691 690 692 return axis; 691 693 } 692 694 693 695 694 696 695 697 float VspKdTree::EvalCostRatio(VspKdLeaf *leaf, 696 698 const int axis, … … 709 711 710 712 Intersectable::NewMail(3); 711 713 712 714 // eval pvs size 713 715 int pvsSize = leaf->GetPvsSize(); … … 719 721 ri != leaf->mRays.end(); ++ ri) 720 722 { 721 if (!(*ri).mRay->IsActive()) 723 if (!(*ri).mRay->IsActive()) 722 724 continue; 723 725 724 726 // determine the side of this ray with respect to the plane 725 727 float t; 726 728 int side = (*ri).ComputeRayIntersection(axis, position, t); 727 729 // (*ri).mRay->mSide = side; 728 730 729 731 if (side <= 0) 730 732 ++ raysBack; 731 733 732 734 if (side >= 0) 733 735 ++ raysFront; 734 736 735 737 AddObject2Pvs((*ri).mRay->mTerminationObject, side, pvsBack, pvsFront); 736 } 738 } 737 739 738 740 if (0) … … 743 745 return sum / oldCost; 744 746 } 745 else 747 else 746 748 { 747 749 AxisAlignedBox3 box = GetBBox(leaf); 748 750 749 751 float minBox = box.Min(axis); 750 752 float maxBox = box.Max(axis); 751 753 float sizeBox = maxBox - minBox; 752 754 753 755 // float sum = raysBack*(position - minBox) + raysFront*(maxBox - position); 754 756 const float sum = pvsBack * (position - minBox) + pvsFront * (maxBox - position); 755 757 756 758 newCost = mCtDivCi + sum / sizeBox; 757 759 758 760 //Debug << axis << " " << pvsSize << " " << pvsBack << " " << pvsFront << endl; 759 761 // float oldCost = leaf->mRays.size(); 760 762 const float oldCost = (float)pvsSize; 761 763 762 764 return newCost / oldCost; 763 765 } … … 778 780 float nCostRatio[3]; 779 781 int bestAxis = -1; 780 782 781 783 AxisAlignedBox3 sBox = GetBBox(leaf); 782 784 783 785 const int sAxis = sBox.Size().DrivingAxis(); 784 786 785 for (axis = 0; axis < 3; ++ axis) 786 { 787 if (!mOnlyDrivingAxis || axis == sAxis) 788 { 789 787 for (axis = 0; axis < 3; ++ axis) 788 { 789 if (!mOnlyDrivingAxis || axis == sAxis) 790 { 791 790 792 nPosition[axis] = (sBox.Min()[axis] + sBox.Max()[axis]) * 0.5f; 791 793 792 794 nCostRatio[axis] = EvalCostRatio(leaf, 793 795 axis, … … 803 805 else if (nCostRatio[axis] < nCostRatio[bestAxis]) 804 806 { 805 /*Debug << "pvs front " << nPvsBack[axis] 807 /*Debug << "pvs front " << nPvsBack[axis] 806 808 << " pvs back " << nPvsFront[axis] 807 809 << " overall pvs " << leaf->GetPvsSize() << endl;*/ 808 810 bestAxis = axis; 809 811 } 810 812 811 813 } 812 814 } … … 821 823 pvsBack = nPvsBack[bestAxis]; 822 824 pvsFront = nPvsFront[bestAxis]; 823 825 824 826 return nCostRatio[bestAxis]; 825 827 } … … 835 837 AxisAlignedBox3 box = GetBBox(leaf); 836 838 // AxisAlignedBox3 dirBox = GetDirBBox(node); 837 839 838 840 axis = box.Size().DrivingAxis(); 839 841 840 842 SortSplitCandidates(leaf, axis); 841 843 842 844 // go through the lists, count the number of objects left and right 843 845 // and evaluate the following cost funcion: 844 846 // C = ct_div_ci + (ql*rl + qr*rr)/queries 845 847 846 848 int rl = 0, rr = (int)leaf->mRays.size(); 847 849 int pl = 0, pr = leaf->GetPvsSize(); … … 850 852 float maxBox = box.Max(axis); 851 853 float sizeBox = maxBox - minBox; 852 854 853 855 float minBand = minBox + 0.1f*(maxBox - minBox); 854 856 float maxBand = minBox + 0.9f*(maxBox - minBox); 855 857 856 858 float sum = rr*sizeBox; 857 859 float minSum = 1e20f; 858 860 859 861 Intersectable::NewMail(); 860 862 … … 866 868 { 867 869 Intersectable *object = (*ri).mRay->mTerminationObject; 868 870 869 871 if (object) 870 if (!object->Mailed()) 872 if (!object->Mailed()) 871 873 { 872 874 object->Mail(); 873 875 object->mCounter = 1; 874 } 876 } 875 877 else 876 878 ++ object->mCounter; 877 879 } 878 880 } 879 881 880 882 Intersectable::NewMail(); 881 883 882 884 for (vector<SortableEntry>::const_iterator ci = mSplitCandidates->begin(); 883 ci < mSplitCandidates->end(); ++ ci) 885 ci < mSplitCandidates->end(); ++ ci) 884 886 { 885 887 VssRay *ray; 886 887 switch ((*ci).type) 888 { 889 case SortableEntry::ERayMin: 888 889 switch ((*ci).type) 890 { 891 case SortableEntry::ERayMin: 890 892 { 891 893 ++ rl; 892 894 ray = (VssRay *) (*ci).data; 893 895 Intersectable *object = ray->mTerminationObject; 894 if (object && !object->Mailed()) 896 if (object && !object->Mailed()) 895 897 { 896 898 object->Mail(); … … 899 901 break; 900 902 } 901 case SortableEntry::ERayMax: 903 case SortableEntry::ERayMax: 902 904 { 903 905 -- rr; 904 906 905 907 ray = (VssRay *) (*ci).data; 906 908 Intersectable *object = ray->mTerminationObject; 907 909 908 910 if (object) 909 911 { … … 911 913 -- pr; 912 914 } 913 915 914 916 break; 915 917 } 916 918 } 917 918 if ((*ci).value > minBand && (*ci).value < maxBand) 919 920 if ((*ci).value > minBand && (*ci).value < maxBand) 919 921 { 920 922 sum = pl*((*ci).value - minBox) + pr*(maxBox - (*ci).value); 921 923 922 924 // cout<<"pos="<<(*ci).value<<"\t q=("<<ql<<","<<qr<<")\t r=("<<rl<<","<<rr<<")"<<endl; 923 925 // cout<<"cost= "<<sum<<endl; 924 925 if (sum < minSum) 926 927 if (sum < minSum) 926 928 { 927 929 minSum = sum; 928 930 position = (*ci).value; 929 931 930 932 raysBack = rl; 931 933 raysFront = rr; 932 934 933 935 pvsBack = pl; 934 936 pvsFront = pr; 935 937 936 938 } 937 939 } … … 941 943 float newCost = mCtDivCi + minSum / sizeBox; 942 944 float ratio = newCost / oldCost; 943 945 944 946 //Debug << "costRatio=" << ratio << " pos=" << position << " t=" << (position - minBox) / (maxBox - minBox) 945 947 // <<"\t q=(" << queriesBack << "," << queriesFront << ")\t r=(" << raysBack << "," << raysFront << ")" << endl; 946 948 947 949 return ratio; 948 950 } … … 952 954 { 953 955 mSplitCandidates->clear(); 954 956 955 957 int requestedSize = 2 * (int)(node->mRays.size()); 956 958 // creates a sorted split candidates array 957 959 if (mSplitCandidates->capacity() > 500000 && 958 requestedSize < (int)(mSplitCandidates->capacity()/10) ) 960 requestedSize < (int)(mSplitCandidates->capacity()/10) ) 959 961 { 960 962 DEL_PTR(mSplitCandidates); 961 963 mSplitCandidates = new vector<SortableEntry>; 962 964 } 963 965 964 966 mSplitCandidates->reserve(requestedSize); 965 967 966 // insert all queries 968 // insert all queries 967 969 for(RayInfoContainer::const_iterator ri = node->mRays.begin(); 968 ri < node->mRays.end(); ++ ri) 970 ri < node->mRays.end(); ++ ri) 969 971 { 970 972 bool positive = (*ri).mRay->HasPosDir(axis); 971 mSplitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMin : SortableEntry::ERayMax, 973 mSplitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMin : SortableEntry::ERayMax, 972 974 (*ri).ExtrapOrigin(axis), (void *)&*ri)); 973 975 974 976 mSplitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMax : SortableEntry::ERayMin, 975 977 (*ri).ExtrapTermination(axis), (void *)&*ri)); 976 978 } 977 979 978 980 stable_sort(mSplitCandidates->begin(), mSplitCandidates->end()); 979 981 } … … 994 996 if (data.mDepth >= mTermMaxDepth) 995 997 ++ mStat.maxDepthNodes; 996 998 997 999 if (leaf->GetPvsSize() < mTermMinPvs) 998 1000 ++ mStat.minPvsNodes; … … 1003 1005 if (leaf->GetAvgRayContribution() > mTermMaxRayContribution) 1004 1006 ++ mStat.maxRayContribNodes; 1005 1006 if (SqrMagnitude(data.mBox.Size()) <= mTermMinSize) 1007 1008 if (SqrMagnitude(data.mBox.Size()) <= mTermMinSize) 1007 1009 ++ mStat.minSizeNodes; 1008 1010 } 1009 1011 1010 1012 1011 inline bool VspKdTree::TerminationCriteriaMet(const VspKdLeaf *leaf, 1013 inline bool VspKdTree::TerminationCriteriaMet(const VspKdLeaf *leaf, 1012 1014 const AxisAlignedBox3 &box) const 1013 1015 { 1014 return ((leaf->GetPvsSize() < mTermMinPvs) || 1016 return ((leaf->GetPvsSize() < mTermMinPvs) || 1015 1017 (leaf->mRays.size() < mTermMinRays) || 1016 1018 //(leaf->GetAvgRayContribution() > mTermMaxRayContribution ) || 1017 (leaf->mDepth >= mTermMaxDepth) || 1019 (leaf->mDepth >= mTermMaxDepth) || 1018 1020 (SqrMagnitude(box.Size()) <= mTermMinSize)); 1019 1021 } … … 1027 1029 if (TerminationCriteriaMet(leaf, box)) 1028 1030 { 1029 if (1 && leaf->mDepth >= mTermMaxDepth) 1031 if (1 && leaf->mDepth >= mTermMaxDepth) 1030 1032 { 1031 1033 Debug << "Warning: max depth reached depth=" << (int)leaf->mDepth<<" rays=" << (int)leaf->mRays.size() << endl; … … 1033 1035 } 1034 1036 //Debug << "depth: " << (int)leaf->mDepth << " pvs: " << leaf->GetPvsSize() << " rays: " << leaf->mRays.size() << endl; 1035 1037 1036 1038 return leaf; 1037 1039 } 1038 1040 1039 1041 float position; 1040 1042 // first count ray sides … … 1043 1045 int pvsBack; 1044 1046 int pvsFront; 1045 1047 1046 1048 // select subdivision axis 1047 1049 const int axis = SelectPlane(leaf, box, position, raysBack, raysFront, pvsBack, pvsFront); … … 1049 1051 //Debug << "rays back=" << raysBack << " rays front=" << raysFront << " pvs back=" << pvsBack << " pvs front=" << pvsFront << endl; 1050 1052 1051 if (axis == -1) 1053 if (axis == -1) 1052 1054 { 1053 1055 return leaf; 1054 1056 } 1055 1057 1056 1058 mStat.nodes += 2; 1057 1059 //++ mStat.splits[axis]; … … 1063 1065 node->mPosition = position; 1064 1066 node->mBox = box; 1065 1067 1066 1068 backBBox = box; 1067 1069 frontBBox = box; … … 1077 1079 // and setup child links 1078 1080 node->SetupChildLinks(back, front); 1079 1080 if (axis <= VspKdNode::SPLIT_Z) 1081 1082 if (axis <= VspKdNode::SPLIT_Z) 1081 1083 { 1082 1084 backBBox.SetMax(axis, position); 1083 1085 frontBBox.SetMin(axis, position); 1084 1086 1085 1087 for(RayInfoContainer::iterator ri = leaf->mRays.begin(); 1086 ri != leaf->mRays.end(); ++ ri) 1087 { 1088 if ((*ri).mRay->IsActive()) 1088 ri != leaf->mRays.end(); ++ ri) 1089 { 1090 if ((*ri).mRay->IsActive()) 1089 1091 { 1090 1092 // first unref ray from the former leaf … … 1094 1096 int side = node->ComputeRayIntersection(*ri, t); 1095 1097 1096 if (side == 0) 1098 if (side == 0) 1097 1099 { 1098 if ((*ri).mRay->HasPosDir(axis)) 1100 if ((*ri).mRay->HasPosDir(axis)) 1099 1101 { 1100 1102 back->AddRay(RayInfo((*ri).mRay, … … 1104 1106 t, 1105 1107 (*ri).mMaxT)); 1106 } 1107 else 1108 } 1109 else 1108 1110 { 1109 1111 back->AddRay(RayInfo((*ri).mRay, … … 1114 1116 t)); 1115 1117 } 1116 } 1118 } 1117 1119 else 1118 if (side == 1) 1120 if (side == 1) 1119 1121 front->AddRay(*ri); 1120 1122 else … … 1123 1125 (*ri).mRay->Unref(); 1124 1126 } 1125 } 1126 else 1127 } 1128 else 1127 1129 { 1128 1130 // rays front/back 1129 1131 1130 1132 for (RayInfoContainer::iterator ri = leaf->mRays.begin(); 1131 ri != leaf->mRays.end(); ++ ri) 1132 { 1133 if ((*ri).mRay->IsActive()) 1133 ri != leaf->mRays.end(); ++ ri) 1134 { 1135 if ((*ri).mRay->IsActive()) 1134 1136 { 1135 1137 // first unref ray from the former leaf … … 1141 1143 else 1142 1144 side = -1; 1143 1145 1144 1146 if (side == 1) 1145 1147 front->AddRay(*ri); 1146 1148 else 1147 back->AddRay(*ri); 1148 } 1149 back->AddRay(*ri); 1150 } 1149 1151 else 1150 1152 (*ri).mRay->Unref(); 1151 1153 } 1152 1154 } 1153 1155 1154 1156 // update stats 1155 1157 mStat.rayRefs -= (int)leaf->mRays.size(); … … 1175 1177 VspKdNode *node = tstack.top(); 1176 1178 tstack.pop(); 1177 1178 if (!node->IsLeaf()) 1179 1180 if (!node->IsLeaf()) 1179 1181 { 1180 1182 VspKdInterior *in = dynamic_cast<VspKdInterior *>(node); 1181 1183 // cout<<"depth="<<(int)in->depth<<" time="<<in->lastAccessTime<<endl; 1182 if (in->mDepth >= mMinCollapseDepth && in->mLastAccessTime <= maxAccessTime) 1184 if (in->mDepth >= mMinCollapseDepth && in->mLastAccessTime <= maxAccessTime) 1183 1185 { 1184 1186 released = CollapseSubtree(node, time); 1185 1187 break; 1186 1188 } 1187 if (in->GetBack()->GetAccessTime() < in->GetFront()->GetAccessTime()) 1189 if (in->GetBack()->GetAccessTime() < in->GetFront()->GetAccessTime()) 1188 1190 { 1189 1191 tstack.push(in->GetFront()); 1190 1192 tstack.push(in->GetBack()); 1191 } 1192 else 1193 } 1194 else 1193 1195 { 1194 1196 tstack.push(in->GetBack()); … … 1198 1200 } 1199 1201 1200 while (tstack.empty()) 1202 while (tstack.empty()) 1201 1203 { 1202 1204 // could find node to collaps... … … 1204 1206 break; 1205 1207 } 1206 1208 1207 1209 return released; 1208 1210 } … … 1218 1220 static int pass = 0; 1219 1221 ++ pass; 1220 1222 1221 1223 // check if we should perform a dynamic subdivision of the leaf 1222 1224 if (// leaf->mRays.size() > (unsigned)termMinCost && 1223 (leaf->GetPvsSize() >= mTermMinPvs) && 1225 (leaf->GetPvsSize() >= mTermMinPvs) && 1224 1226 (SqrMagnitude(leafBBox.Size()) > sizeThreshold) ) 1225 1227 { 1226 1228 // memory check and release 1227 if (GetMemUsage() > mMaxTotalMemory) 1229 if (GetMemUsage() > mMaxTotalMemory) 1228 1230 ReleaseMemory(pass); 1229 1231 1230 1232 AxisAlignedBox3 backBBox, frontBBox; 1231 1233 … … 1245 1247 // schedule rays for removal 1246 1248 for(VssRayContainer::const_iterator ri = remove.begin(); 1247 ri != remove.end(); ++ ri) 1248 { 1249 (*ri)->ScheduleForRemoval(); 1249 ri != remove.end(); ++ ri) 1250 { 1251 (*ri)->ScheduleForRemoval(); 1250 1252 } 1251 1253 1252 1254 int inactive = 0; 1253 1255 1254 for (VssRayContainer::const_iterator ri = remove.begin(); ri != remove.end(); ++ ri) 1256 for (VssRayContainer::const_iterator ri = remove.begin(); ri != remove.end(); ++ ri) 1255 1257 { 1256 1258 if ((*ri)->ScheduledForRemoval()) … … 1263 1265 1264 1266 // cout<<"all/inactive"<<remove.size()<<"/"<<inactive<<endl; 1265 for (VssRayContainer::const_iterator ri = add.begin(); ri != add.end(); ++ ri) 1267 for (VssRayContainer::const_iterator ri = add.begin(); ri != add.end(); ++ ri) 1266 1268 { 1267 1269 AddRay(*ri); … … 1277 1279 1278 1280 tstack.push(RayTraversalData(mRoot, RayInfo(ray))); 1279 1281 1280 1282 RayTraversalData data; 1281 1283 1282 1284 // cout<<"Number of ray refs = "<<ray->RefCount()<<endl; 1283 while (!tstack.empty()) 1285 while (!tstack.empty()) 1284 1286 { 1285 1287 data = tstack.top(); 1286 1288 tstack.pop(); 1287 1289 1288 if (!data.mNode->IsLeaf()) 1290 if (!data.mNode->IsLeaf()) 1289 1291 { 1290 1292 // split the set of rays in two groups intersecting the 1291 1293 // two subtrees 1292 1294 TraverseInternalNode(data, tstack); 1293 } 1294 else 1295 } 1296 else 1295 1297 { 1296 1298 // remove the ray from the leaf 1297 1299 // find the ray in the leaf and swap it with the last ray... 1298 1300 VspKdLeaf *leaf = (VspKdLeaf *)data.mNode; 1299 1300 if (!leaf->Mailed()) 1301 1302 if (!leaf->Mailed()) 1301 1303 { 1302 1304 leaf->Mail(); 1303 1305 1304 1306 if (affectedLeaves) 1305 1307 affectedLeaves->push_back(leaf); 1306 1307 if (removeAllScheduledRays) 1308 1309 if (removeAllScheduledRays) 1308 1310 { 1309 1311 int tail = (int)leaf->mRays.size() - 1; 1310 1312 1311 for (int i=0; i < (int)(leaf->mRays.size()); ++ i) 1313 for (int i=0; i < (int)(leaf->mRays.size()); ++ i) 1312 1314 { 1313 if (leaf->mRays[i].mRay->ScheduledForRemoval()) 1315 if (leaf->mRays[i].mRay->ScheduledForRemoval()) 1314 1316 { 1315 1317 // find a ray to replace it with 1316 while (tail >= i && leaf->mRays[tail].mRay->ScheduledForRemoval()) 1318 while (tail >= i && leaf->mRays[tail].mRay->ScheduledForRemoval()) 1317 1319 { 1318 1320 ++ mStat.removedRayRefs; 1319 1321 leaf->mRays[tail].mRay->Unref(); 1320 1322 leaf->mRays.pop_back(); 1321 1323 1322 1324 -- tail; 1323 1325 } 1324 1326 1325 1327 if (tail < i) 1326 1328 break; 1327 1329 1328 1330 ++ mStat.removedRayRefs; 1329 1331 1330 1332 leaf->mRays[i].mRay->Unref(); 1331 1333 leaf->mRays[i] = leaf->mRays[tail]; … … 1336 1338 } 1337 1339 } 1338 1340 1339 1341 if (!removeAllScheduledRays) 1340 for (int i=0; i < (int)leaf->mRays.size(); i++) 1342 for (int i=0; i < (int)leaf->mRays.size(); i++) 1341 1343 { 1342 if (leaf->mRays[i].mRay == ray) 1344 if (leaf->mRays[i].mRay == ray) 1343 1345 { 1344 1346 ++ mStat.removedRayRefs; … … 1353 1355 } 1354 1356 1355 if (ray->RefCount() != 0) 1357 if (ray->RefCount() != 0) 1356 1358 { 1357 1359 cerr << "Error: Number of remaining refs = " << ray->RefCount() << endl; … … 1364 1366 { 1365 1367 stack<RayTraversalData> tstack; 1366 1368 1367 1369 tstack.push(RayTraversalData(mRoot, RayInfo(ray))); 1368 1370 1369 1371 RayTraversalData data; 1370 1371 while (!tstack.empty()) 1372 1373 while (!tstack.empty()) 1372 1374 { 1373 1375 data = tstack.top(); 1374 1376 tstack.pop(); 1375 1377 1376 if (!data.mNode->IsLeaf()) 1378 if (!data.mNode->IsLeaf()) 1377 1379 { 1378 1380 TraverseInternalNode(data, tstack); 1379 } 1380 else 1381 } 1382 else 1381 1383 { 1382 1384 // remove the ray from the leaf … … 1390 1392 } 1391 1393 1392 void VspKdTree::TraverseInternalNode(RayTraversalData &data, 1394 void VspKdTree::TraverseInternalNode(RayTraversalData &data, 1393 1395 stack<RayTraversalData> &tstack) 1394 1396 { 1395 1397 VspKdInterior *in = dynamic_cast<VspKdInterior *>(data.mNode); 1396 1397 if (in->mAxis <= VspKdNode::SPLIT_Z) 1398 1399 if (in->mAxis <= VspKdNode::SPLIT_Z) 1398 1400 { 1399 1401 // determine the side of this ray with respect to the plane 1400 float t; 1402 float t; 1401 1403 int side = in->ComputeRayIntersection(data.mRayData, t); 1402 1403 if (side == 0) 1404 { 1405 if (data.mRayData.mRay->HasPosDir(in->mAxis)) 1406 { 1407 tstack.push(RayTraversalData(in->GetBack(), 1404 1405 if (side == 0) 1406 { 1407 if (data.mRayData.mRay->HasPosDir(in->mAxis)) 1408 { 1409 tstack.push(RayTraversalData(in->GetBack(), 1408 1410 RayInfo(data.mRayData.mRay, data.mRayData.mMinT, t))); 1409 1411 1410 1412 tstack.push(RayTraversalData(in->GetFront(), 1411 1413 RayInfo(data.mRayData.mRay, t, data.mRayData.mMaxT))); 1412 1413 } 1414 else 1414 1415 } 1416 else 1415 1417 { 1416 1418 tstack.push(RayTraversalData(in->GetBack(), … … 1429 1431 else 1430 1432 tstack.push(RayTraversalData(in->GetBack(), data.mRayData)); 1431 } 1432 else 1433 } 1434 else 1433 1435 { 1434 1436 // directional split … … 1446 1448 // use mail 1 for this purpose 1447 1449 stack<VspKdNode *> tstack; 1448 1450 1449 1451 int rayCount = 0; 1450 1452 int totalRayCount = 0; … … 1462 1464 tstack.push(sroot); 1463 1465 VssRay::NewMail(); 1464 1465 while (!tstack.empty()) 1466 1467 while (!tstack.empty()) 1466 1468 { 1467 1469 ++ collapsedNodes; 1468 1470 1469 1471 VspKdNode *node = tstack.top(); 1470 1472 tstack.pop(); 1471 if (node->IsLeaf()) 1473 if (node->IsLeaf()) 1472 1474 { 1473 1475 VspKdLeaf *leaf = (VspKdLeaf *) node; 1474 1476 1475 1477 for(RayInfoContainer::iterator ri = leaf->mRays.begin(); 1476 ri != leaf->mRays.end(); ++ ri) 1478 ri != leaf->mRays.end(); ++ ri) 1477 1479 { 1478 1480 ++ totalRayCount; 1479 1480 if ((*ri).mRay->IsActive() && !(*ri).mRay->Mailed()) 1481 1482 if ((*ri).mRay->IsActive() && !(*ri).mRay->Mailed()) 1481 1483 { 1482 1484 (*ri).mRay->Mail(); … … 1484 1486 } 1485 1487 } 1486 } 1487 else 1488 } 1489 else 1488 1490 { 1489 1491 tstack.push(((VspKdInterior *)node)->GetFront()); … … 1491 1493 } 1492 1494 } 1493 1495 1494 1496 VssRay::NewMail(); 1495 1497 1496 1498 // create a new node that will hold the rays 1497 1499 VspKdLeaf *newLeaf = new VspKdLeaf(sroot->mParent, rayCount); 1498 1500 1499 1501 if (newLeaf->mParent) 1500 1502 newLeaf->mParent->ReplaceChildLink(sroot, newLeaf); … … 1502 1504 tstack.push(sroot); 1503 1505 1504 while (!tstack.empty()) 1506 while (!tstack.empty()) 1505 1507 { 1506 1508 VspKdNode *node = tstack.top(); 1507 1509 tstack.pop(); 1508 1510 1509 if (node->IsLeaf()) 1511 if (node->IsLeaf()) 1510 1512 { 1511 1513 VspKdLeaf *leaf = dynamic_cast<VspKdLeaf *>(node); 1512 1514 1513 1515 for(RayInfoContainer::iterator ri = leaf->mRays.begin(); 1514 ri != leaf->mRays.end(); ++ ri) 1515 { 1516 // unref this ray from the old node 1517 if ((*ri).mRay->IsActive()) 1516 ri != leaf->mRays.end(); ++ ri) 1517 { 1518 // unref this ray from the old node 1519 if ((*ri).mRay->IsActive()) 1518 1520 { 1519 1521 (*ri).mRay->Unref(); 1520 if (!(*ri).mRay->Mailed()) 1522 if (!(*ri).mRay->Mailed()) 1521 1523 { 1522 1524 (*ri).mRay->Mail(); 1523 1525 newLeaf->AddRay(*ri); 1524 1526 } 1525 } 1527 } 1526 1528 else 1527 1529 (*ri).mRay->Unref(); 1528 1530 } 1529 } 1530 else 1531 { 1532 VspKdInterior *interior = 1531 } 1532 else 1533 { 1534 VspKdInterior *interior = 1533 1535 dynamic_cast<VspKdInterior *>(node); 1534 1536 tstack.push(interior->GetBack()); … … 1536 1538 } 1537 1539 } 1538 1540 1539 1541 // delete the node and all its children 1540 1542 DEL_PTR(sroot); 1541 1543 1542 1544 // for(VspKdNode::SRayContainer::iterator ri = newleaf->mRays.begin(); 1543 1545 // ri != newleaf->mRays.end(); ++ ri) … … 1550 1552 mStat.nodes -= collapsedNodes - 1; 1551 1553 mStat.rayRefs -= totalRayCount - rayCount; 1552 1554 1553 1555 #if DEBUG_COLLAPSE 1554 1556 cout << "collapsed nodes" << collapsedNodes << endl; … … 1571 1573 Intersectable::NewMail(); 1572 1574 int pvsSize = 0; 1573 1574 while (!tstack.empty()) 1575 1576 while (!tstack.empty()) 1575 1577 { 1576 1578 VspKdNode *node = tstack.top(); 1577 1579 tstack.pop(); 1578 1579 if (node->IsLeaf()) 1580 1581 if (node->IsLeaf()) 1580 1582 { 1581 1583 VspKdLeaf *leaf = (VspKdLeaf *)node; … … 1583 1585 ri != leaf->mRays.end(); ++ ri) 1584 1586 { 1585 if ((*ri).mRay->IsActive()) 1587 if ((*ri).mRay->IsActive()) 1586 1588 { 1587 1589 Intersectable *object; 1588 1590 #if BIDIRECTIONAL_RAY 1589 1591 object = (*ri).mRay->mOriginObject; 1590 1591 if (object && !object->Mailed()) 1592 1593 if (object && !object->Mailed()) 1592 1594 { 1593 1595 ++ pvsSize; … … 1596 1598 #endif 1597 1599 object = (*ri).mRay->mTerminationObject; 1598 if (object && !object->Mailed()) 1600 if (object && !object->Mailed()) 1599 1601 { 1600 1602 ++ pvsSize; … … 1602 1604 } 1603 1605 } 1604 } 1605 } 1606 else 1606 } 1607 } 1608 else 1607 1609 { 1608 1610 VspKdInterior *in = dynamic_cast<VspKdInterior *>(node); 1609 1610 if (in->mAxis < 3) 1611 1612 if (in->mAxis < 3) 1611 1613 { 1612 1614 if (box.Max(in->mAxis) >= in->mPosition) 1613 1615 tstack.push(in->GetFront()); 1614 1616 1615 1617 if (box.Min(in->mAxis) <= in->mPosition) 1616 1618 tstack.push(in->GetBack()); 1617 } 1618 else 1619 } 1620 else 1619 1621 { 1620 1622 // both nodes for directional splits … … 1634 1636 stack<VspKdNode *> tstack; 1635 1637 tstack.push(mRoot); 1636 1638 1637 1639 minRayContribution = 1.0f; 1638 1640 maxRayContribution = 0.0f; … … 1641 1643 int leaves = 0; 1642 1644 1643 while (!tstack.empty()) 1645 while (!tstack.empty()) 1644 1646 { 1645 1647 VspKdNode *node = tstack.top(); 1646 1648 tstack.pop(); 1647 if (node->IsLeaf()) 1649 if (node->IsLeaf()) 1648 1650 { 1649 1651 leaves++; … … 1656 1658 minRayContribution = c; 1657 1659 sumRayContribution += c; 1658 1659 } 1660 1661 } 1660 1662 else { 1661 1663 VspKdInterior *in = (VspKdInterior *)node; … … 1665 1667 } 1666 1668 } 1667 1669 1668 1670 Debug << "sum=" << sumRayContribution << endl; 1669 1671 Debug << "leaves=" << leaves << endl; … … 1677 1679 stack<VspKdNode *> tstack; 1678 1680 tstack.push(mRoot); 1679 1680 while (!tstack.empty()) 1681 1682 while (!tstack.empty()) 1681 1683 { 1682 1684 VspKdNode *node = tstack.top(); 1683 1685 tstack.pop(); 1684 1685 if (node->IsLeaf()) 1686 1687 if (node->IsLeaf()) 1686 1688 { 1687 1689 VspKdLeaf *leaf = dynamic_cast<VspKdLeaf *>(node); … … 1691 1693 // cout<<num<<" "; 1692 1694 1693 for (int i=0; i < num; i++) 1695 for (int i=0; i < num; i++) 1694 1696 { 1695 1697 Vector3 origin = GetBBox(leaf).GetRandomPoint(); … … 1699 1701 rays.push_back(SimpleRay(origin, direction));*/ 1700 1702 } 1701 1702 } 1703 else 1704 { 1705 VspKdInterior *in = 1703 1704 } 1705 else 1706 { 1707 VspKdInterior *in = 1706 1708 dynamic_cast<VspKdInterior *>(node); 1707 1709 // both nodes for directional splits … … 1722 1724 int sumPvs = 0; 1723 1725 int leaves = 0; 1724 1725 while (!tstack.empty()) 1726 1727 while (!tstack.empty()) 1726 1728 { 1727 1729 VspKdNode *node = tstack.top(); 1728 1730 tstack.pop(); 1729 1730 if (node->IsLeaf()) 1731 1732 if (node->IsLeaf()) 1731 1733 { 1732 1734 VspKdLeaf *leaf = (VspKdLeaf *)node; … … 1735 1737 sumPvs += leaf->GetPvsSize(); 1736 1738 leaves++; 1737 } 1738 else 1739 } 1740 else 1739 1741 { 1740 1742 VspKdInterior *in = (VspKdInterior *)node; … … 1763 1765 if (node->mParent->mAxis >= 3) 1764 1766 return node->mParent->mBox; 1765 1767 1766 1768 AxisAlignedBox3 box(node->mParent->mBox); 1767 1769 if (node->mParent->GetFront() == node) … … 1773 1775 } 1774 1776 1775 int VspKdTree::GetRootPvsSize() const 1777 int VspKdTree::GetRootPvsSize() const 1776 1778 { 1777 1779 return GetPvsSize(mRoot, mBox); 1778 1780 } 1779 1781 1780 const VspKdStatistics &VspKdTree::GetStatistics() const 1782 const VspKdStatistics &VspKdTree::GetStatistics() const 1781 1783 { 1782 1784 return mStat; … … 1788 1790 UpdateRays(remove, add); 1789 1791 } 1790 1792 1791 1793 // return memory usage in MB 1792 float VspKdTree::GetMemUsage() const 1793 { 1794 return 1795 (sizeof(VspKdTree) + 1794 float VspKdTree::GetMemUsage() const 1795 { 1796 return 1797 (sizeof(VspKdTree) + 1796 1798 mStat.Leaves() * sizeof(VspKdLeaf) + 1797 1799 mStat.Interior() * sizeof(VspKdInterior) + 1798 1800 mStat.rayRefs * sizeof(RayInfo)) / (1024.0f * 1024.0f); 1799 1801 } 1800 1801 float VspKdTree::GetRayMemUsage() const 1802 1803 float VspKdTree::GetRayMemUsage() const 1802 1804 { 1803 1805 return mStat.rays * (sizeof(VssRay))/(1024.0f * 1024.0f); 1804 1806 } 1805 1807 1806 int VspKdTree::ComputePvsSize(VspKdNode *node, 1808 int VspKdTree::ComputePvsSize(VspKdNode *node, 1807 1809 const RayInfoContainer &globalRays) const 1808 1810 { … … 1816 1818 for (it = globalRays.begin(); it != globalRays.end(); ++ it) 1817 1819 pvsSize += box.GetMinMaxT(*(*it).mRay, NULL, NULL); 1818 1820 1819 1821 return pvsSize; 1820 1822 } … … 1825 1827 nodeStack.push(mRoot); 1826 1828 1827 while (!nodeStack.empty()) 1829 while (!nodeStack.empty()) 1828 1830 { 1829 1831 VspKdNode *node = nodeStack.top(); 1830 1832 1831 1833 nodeStack.pop(); 1832 1833 if (node->IsLeaf()) 1834 1835 if (node->IsLeaf()) 1834 1836 { 1835 1837 VspKdLeaf *leaf = dynamic_cast<VspKdLeaf *>(node); 1836 1838 leaves.push_back(leaf); 1837 } 1838 else 1839 } 1840 else 1839 1841 { 1840 1842 VspKdInterior *interior = dynamic_cast<VspKdInterior *>(node); … … 1851 1853 { 1852 1854 stack<VspKdNode *> nodeStack; 1853 1855 1854 1856 nodeStack.push(mRoot); 1855 1857 1856 1858 AxisAlignedBox3 box = GetBBox(n); 1857 1859 1858 while (!nodeStack.empty()) 1860 while (!nodeStack.empty()) 1859 1861 { 1860 1862 VspKdNode *node = nodeStack.top(); 1861 1863 nodeStack.pop(); 1862 1864 1863 if (node->IsLeaf()) 1865 if (node->IsLeaf()) 1864 1866 { 1865 1867 VspKdLeaf *leaf = dynamic_cast<VspKdLeaf *>(node); 1866 1868 1867 if (leaf != n && (!onlyUnmailed || !leaf->Mailed())) 1869 if (leaf != n && (!onlyUnmailed || !leaf->Mailed())) 1868 1870 neighbors.push_back(leaf); 1869 } 1870 else 1871 } 1872 else 1871 1873 { 1872 1874 VspKdInterior *interior = dynamic_cast<VspKdInterior *>(node); … … 1878 1880 if (interior->mPosition < box.Min(interior->mAxis)) 1879 1881 nodeStack.push(interior->mFront); 1880 else 1882 else 1881 1883 { 1882 1884 // random decision … … 1902 1904 { 1903 1905 int hits = 0; 1904 1906 1905 1907 stack<RayTraversalData> tStack; 1906 1908 1907 1909 float maxt = 1e6; 1908 1910 float mint = 0; … … 1915 1917 if (mint < 0) 1916 1918 mint = 0; 1917 1919 1918 1920 maxt += Limits::Threshold; 1919 1921 1920 1922 Vector3 entp = ray.Extrap(mint); 1921 1923 Vector3 extp = ray.Extrap(maxt); 1922 1924 1923 1925 VspKdNode *node = mRoot; 1924 1926 VspKdNode *farChild; … … 1926 1928 float position; 1927 1929 int axis; 1928 1929 while (1) 1930 { 1931 if (!node->IsLeaf()) 1930 1931 while (1) 1932 { 1933 if (!node->IsLeaf()) 1932 1934 { 1933 1935 VspKdInterior *in = dynamic_cast<VspKdInterior *>(node); … … 1935 1937 axis = in->mAxis; 1936 1938 1937 if (entp[axis] <= position) 1938 { 1939 if (extp[axis] <= position) 1939 if (entp[axis] <= position) 1940 { 1941 if (extp[axis] <= position) 1940 1942 { 1941 1943 node = in->mBack; 1942 1944 // cases N1,N2,N3,P5,Z2,Z3 1943 1945 continue; 1944 } else 1946 } else 1945 1947 { 1946 1948 // case N4 … … 1949 1951 } 1950 1952 } 1951 else 1952 { 1953 if (position <= extp[axis]) 1953 else 1954 { 1955 if (position <= extp[axis]) 1954 1956 { 1955 1957 node = in->mFront; 1956 1958 // cases P1,P2,P3,N5,Z1 1957 1959 continue; 1958 } 1959 else 1960 } 1961 else 1960 1962 { 1961 1963 node = in->mFront; … … 1971 1973 extp = ray.GetLoc() + ray.GetDir()*tdist; 1972 1974 maxt = tdist; 1973 } 1974 else 1975 } 1976 else 1975 1977 { 1976 1978 // compute intersection with all objects in this leaf … … 1978 1980 if (ray.mFlags & Ray::STORE_KDLEAVES) 1979 1981 ray.kdLeaves.push_back(leaf); 1980 1982 1981 1983 ObjectContainer::const_iterator mi; 1982 for ( mi = leaf->mObjects.begin(); mi != leaf->mObjects.end(); mi++) 1984 for ( mi = leaf->mObjects.begin(); mi != leaf->mObjects.end(); mi++) 1983 1985 { 1984 1986 Intersectable *object = *mi; 1985 if (!object->Mailed() ) 1987 if (!object->Mailed() ) 1986 1988 { 1987 1989 object->Mail(); … … 1991 1993 } 1992 1994 } 1993 1995 1994 1996 if (hits && ray.GetType() == Ray::LOCAL_RAY) 1995 1997 if (ray.intersections[0].mT <= maxt) 1996 1998 break; 1997 1999 1998 2000 // get the next node from the stack 1999 2001 if (tStack.empty()) 2000 2002 break; 2001 2003 2002 2004 entp = extp; 2003 2005 mint = maxt; 2004 2006 if (ray.GetType() == Ray::LINE_SEGMENT && mint > 1.0f) 2005 2007 break; 2006 2008 2007 2009 RayTraversalData &s = tStack.top(); 2008 2010 node = s.mNode; … … 2013 2015 } 2014 2016 } 2015 2017 2016 2018 return hits; 2017 2019 } … … 2034 2036 if (ray->mTerminationObject) 2035 2037 vc->GetPvs().AddSample(ray->mTerminationObject); 2036 2038 2037 2039 if (ray->mOriginObject) 2038 2040 vc->GetPvs().AddSample(ray->mOriginObject); … … 2050 2052 ViewCell::NewMail(); 2051 2053 2052 // exclude root cell 2053 //mRootCell->Mail(); 2054 2055 while (!nodeStack.empty()) 2054 while (!nodeStack.empty()) 2056 2055 { 2057 2056 VspKdNode *node = nodeStack.top(); 2058 2057 nodeStack.pop(); 2059 2058 2060 if (node->IsLeaf()) 2059 if (node->IsLeaf()) 2061 2060 { 2062 2061 ++ vcStat.leaves; … … 2064 2063 VspKdViewCell *viewCell = dynamic_cast<VspKdLeaf *>(node)->mViewCell; 2065 2064 2066 if (!viewCell->Mailed()) 2065 if (!viewCell->Mailed()) 2067 2066 { 2068 2067 viewCell->Mail(); 2069 2068 2070 2069 ++ vcStat.viewCells; 2071 2070 const int pvsSize = viewCell->GetPvs().GetSize(); … … 2083 2082 2084 2083 if ((int)viewCell->mVspKdLeaves.size() > vcStat.maxLeaves) 2085 vcStat.maxLeaves = (int)viewCell->mVspKdLeaves.size(); 2086 } 2087 } 2088 else 2084 vcStat.maxLeaves = (int)viewCell->mVspKdLeaves.size(); 2085 } 2086 } 2087 else 2089 2088 { 2090 2089 VspKdInterior *interior = dynamic_cast<VspKdInterior *>(node); … … 2095 2094 } 2096 2095 } 2096 2097 2097 2098 2098 … … 2130 2130 } 2131 2131 2132 vc->Mail(); 2133 2132 2134 // clean up old view cells 2133 2135 DEL_PTR(fVc); … … 2143 2145 vector<VspKdLeaf *> leaves; 2144 2146 priority_queue<MergeCandidate> mergeQueue; 2145 2147 2146 2148 // collect the leaves, e.g., the "voxels" that will build the view cells 2147 2149 CollectLeaves(leaves); … … 2161 2163 { 2162 2164 VspKdLeaf *leaf = *it; 2163 2165 2164 2166 // no leaf is part of two merge candidates 2165 2167 if (!leaf->Mailed()) … … 2170 2172 FindNeighbors(leaf, neighbors, true); 2171 2173 2172 vector<VspKdLeaf *>::const_iterator nit, 2174 vector<VspKdLeaf *>::const_iterator nit, 2173 2175 nit_end = neighbors.end(); 2174 2176 … … 2180 2182 int merged = 0; 2181 2183 2182 float savedMaxCostRatio = 0; 2183 2184 Debug << "merge cost " << mergeQueue.top().GetMergeCost() << " of " << mMaxCostRatio << endl; 2184 //Debug << mMinViewCells << " " << mMaxCostRatio << endl; 2185 2185 2186 2186 // use priority queue to merge leaves 2187 while (!mergeQueue.empty() && 2188 ((mMaxViewCells < vcSize) || 2189 (mergeQueue.top().GetMergeCost() < mMaxCostRatio))) 2190 { 2191 ViewCell::NewMail(); 2192 2193 Debug << "=====================" << endl; 2187 while (!mergeQueue.empty() && 2188 (vcSize > mMinViewCells))// && 2189 //(mergeQueue.top().GetMergeCost() < mMaxCostRatio)) 2190 { 2191 //Debug << mergeQueue.top().GetMergeCost() << " " << mMaxCostRatio << endl; 2194 2192 MergeCandidate mc = mergeQueue.top(); 2195 2193 mergeQueue.pop(); 2196 2194 2195 // both view cells equal! 2197 2196 if (mc.GetLeaf1()->GetViewCell() == mc.GetLeaf2()->GetViewCell()) 2198 // both view cells the same!2199 {2200 Debug << "same view cell!!" << endl;2201 -- vcSize;2202 2203 2197 continue; 2204 }2205 2198 2206 2199 if (mc.Valid()) 2207 2200 { 2208 mc.GetLeaf1()->GetViewCell()->Mail(); 2209 mc.GetLeaf2()->GetViewCell()->Mail(); 2210 2211 Debug << "merging cells with cost " << mc.GetMergeCost() << " of " << mMaxCostRatio << endl; 2212 savedMaxCostRatio = mc.GetMergeCost(); 2213 2201 ViewCell::NewMail(); 2214 2202 MergeViewCells(mc.GetLeaf1(), mc.GetLeaf2()); 2215 2203 2216 2204 ++ merged; 2217 2205 -- vcSize; … … 2219 2207 // merge candidate not valid, because one of the leaves was already 2220 2208 // merged with another one 2221 else 2222 { 2223 Debug << "not valid " << mc.GetMergeCost() << endl; 2224 2209 else 2210 { 2225 2211 // validate and reinsert into queue 2226 2212 mc.SetValid(); 2227 Debug << "ag. valid " << mc.GetMergeCost() << endl;2228 2229 2213 mergeQueue.push(mc); 2230 } 2231 } 2232 2233 if (mergeQueue.empty()) 2234 Debug << "empty queue" << endl; 2235 2236 Debug << "max cost ratio: " << savedMaxCostRatio << endl; 2214 //Debug << "validate " << mc.GetMergeCost() << endl; 2215 } 2216 } 2217 2218 // collapse tree according to view cell partition 2219 CollapseTree(mRoot); 2220 2221 // revalidate leaves 2222 ValidateViewCellLeaves(); 2223 2237 2224 2238 2225 return merged; 2226 } 2227 2228 2229 void VspKdTree::ValidateViewCellLeaves() 2230 { 2231 // list not valid anymore => clear 2232 stack<VspKdNode *> nodeStack; 2233 nodeStack.push(mRoot); 2234 2235 ViewCell::NewMail(); 2236 2237 while (!nodeStack.empty()) 2238 { 2239 VspKdNode *node = nodeStack.top(); 2240 nodeStack.pop(); 2241 2242 if (node->IsLeaf()) 2243 { 2244 VspKdLeaf *leaf = dynamic_cast<VspKdLeaf *>(node); 2245 2246 VspKdViewCell *viewCell = leaf->GetViewCell(); 2247 2248 if (!viewCell->Mailed()) 2249 { 2250 Debug << "jhere2" << endl; 2251 viewCell->mVspKdLeaves.clear(); 2252 viewCell->Mail(); 2253 } 2254 2255 viewCell->mVspKdLeaves.push_back(leaf); 2256 } 2257 else 2258 { 2259 VspKdInterior *interior = dynamic_cast<VspKdInterior *>(node); 2260 2261 nodeStack.push(interior->GetFront()); 2262 nodeStack.push(interior->GetBack()); 2263 } 2264 } 2265 } 2266 2267 VspKdNode *VspKdTree::CollapseTree(VspKdNode *node) 2268 { 2269 if (node->IsLeaf()) 2270 return node; 2271 2272 Debug << "here554444" << endl; 2273 VspKdInterior *interior = dynamic_cast<VspKdInterior *>(node); 2274 2275 VspKdNode *front = CollapseTree(interior->GetFront()); 2276 VspKdNode *back = CollapseTree(interior->GetBack()); 2277 2278 if (front->IsLeaf() && back->IsLeaf()) 2279 { 2280 VspKdLeaf *frontLeaf = dynamic_cast<VspKdLeaf *>(front); 2281 VspKdLeaf *backLeaf = dynamic_cast<VspKdLeaf *>(back); 2282 2283 //-- collapse tree 2284 if (frontLeaf->GetViewCell() == backLeaf->GetViewCell()) 2285 { 2286 VspKdViewCell *vc = frontLeaf->GetViewCell(); 2287 2288 VspKdLeaf *leaf = new VspKdLeaf(interior->GetParent(), 0); 2289 leaf->SetViewCell(vc); 2290 2291 // replace a link from node's parent 2292 if (leaf->mParent) 2293 leaf->mParent->ReplaceChildLink(node, leaf); 2294 2295 delete interior; 2296 2297 return leaf; 2298 } 2299 } 2300 2301 return node; 2239 2302 } 2240 2303 … … 2258 2321 void MergeCandidate::EvalMergeCost() 2259 2322 { 2260 // compute pvs differences2323 //-- compute pvs difference 2261 2324 VspKdViewCell *vc1 = mLeaf1->GetViewCell(); 2262 2325 VspKdViewCell *vc2 = mLeaf2->GetViewCell(); 2263 2264 //VspKdViewCell *vc1 = dynamic_cast<VspKdViewCell *>(mLeaf1->GetViewCell());2265 //VspKdViewCell *vc2 = dynamic_cast<VspKdViewCell *>(mLeaf2->GetViewCell());2266 2326 2267 2327 const int diff1 = vc1->GetPvs().Diff(vc2->GetPvs()); 2268 2328 const int vcPvs = diff1 + vc1->GetPvs().GetSize(); 2269 2329 2270 //-- compute ratio of old cost 2330 //-- compute ratio of old cost 2271 2331 //-- (added size of left and right view cell times pvs size) 2272 2332 //-- to new rendering cost (size of merged view cell times pvs size) 2273 const float oldCost = 2274 (float)vc1->GetPvs().GetSize() * vc1->GetSize() + 2333 const float oldCost = 2334 (float)vc1->GetPvs().GetSize() * vc1->GetSize() + 2275 2335 (float)vc2->GetPvs().GetSize() * vc2->GetSize(); 2276 2336 2277 const float newCost = 2337 const float newCost = 2278 2338 (float)vcPvs * (vc1->GetSize() + vc2->GetSize()); 2279 2339 2280 mMergeCost = newCost / oldCost; 2281 2282 Debug << "******************************" << endl; 2283 Debug << "pvs size: " << vcPvs << " max: " << sMaxPvsSize << endl; 2284 if (vcPvs > sMaxPvsSize) // strong penalty if pvs size too large 2285 mMergeCost += 1.0; 2286 2287 Debug << "old cost: " << oldCost << endl; 2288 Debug << "new cost: " << newCost << endl; 2340 mMergeCost = newCost - oldCost; 2341 2342 // if (vcPvs > sMaxPvsSize) // strong penalty if pvs size too large 2343 // mMergeCost += 1.0; 2289 2344 } 2290 2345 … … 2310 2365 2311 2366 bool MergeCandidate::Valid() const 2312 { 2313 //Debug << mLeaf1->GetViewCell()->mMailbox << " " << mLeaf1Id << endl; 2314 //Debug << mLeaf2->GetViewCell()->mMailbox << " " << mLeaf2Id << endl; 2315 2316 return 2317 (mLeaf1->GetViewCell()->mMailbox == mLeaf1Id) && 2367 { 2368 return 2369 (mLeaf1->GetViewCell()->mMailbox == mLeaf1Id) && 2318 2370 (mLeaf2->GetViewCell()->mMailbox == mLeaf2Id); 2319 2371 } … … 2328 2380 mLeaf1Id = mLeaf1->GetViewCell()->mMailbox; 2329 2381 mLeaf2Id = mLeaf2->GetViewCell()->mMailbox; 2330 2382 2331 2383 EvalMergeCost(); 2332 2384 } -
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.h
r463 r465 299 299 { 300 300 public: 301 301 302 friend class VspKdTree; 302 303 … … 670 671 bool MergeViewCells(VspKdLeaf *l1, VspKdLeaf *l2); 671 672 672 673 /** Collapses the tree with respect to the view cell partition. 674 @returns node of type leaf if the node could be collapsed, this node otherwise 675 */ 676 VspKdNode *CollapseTree(VspKdNode *node); 677 678 /** Helper function revalidating the view cell leaf list after merge. 679 */ 680 void ValidateViewCellLeaves(); 681 673 682 protected: 674 683 … … 749 758 int mMaxViewCells; 750 759 760 /// minimal number of view cells 761 int mMinViewCells; 762 751 763 ///////////////////////////// 752 764 VspKdStatistics mStat; -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp
r462 r465 462 462 cout<<"VssTree root PVS size = "<<vssTree->GetRootPvsSize()<<endl; 463 463 464 ExportVssTree("vss-tree-100.x3d", vssTree, Vector3(1,0,0)); 465 ExportVssTree("vss-tree-001.x3d", vssTree, Vector3(0,0,1)); 466 ExportVssTree("vss-tree-101.x3d", vssTree, Vector3(1,0,1)); 467 ExportVssTree("vss-tree-101m.x3d", vssTree, Vector3(-1,0,-1)); 468 469 ExportVssTreeLeaves(vssTree, 10); 464 if (0) 465 { 466 ExportVssTree("vss-tree-100.x3d", vssTree, Vector3(1,0,0)); 467 ExportVssTree("vss-tree-001.x3d", vssTree, Vector3(0,0,1)); 468 ExportVssTree("vss-tree-101.x3d", vssTree, Vector3(1,0,1)); 469 ExportVssTree("vss-tree-101m.x3d", vssTree, Vector3(-1,0,-1)); 470 ExportVssTreeLeaves(vssTree, 10); 471 } 470 472 471 473 // viewcells->UpdatePVS(newVssRays); … … 543 545 544 546 /// compute view cell contribution of rays 545 mViewCellsManager->ComputeSampleContributions(passRays,547 /* mViewCellsManager->ComputeSampleContributions(passRays, 546 548 sampleContributions, 547 549 contributingSamples); … … 560 562 CLEAR_CONTAINER(passRays); 561 563 } 562 564 */ 563 565 samples+=num; 564 566 float pvs = vssTree->GetAvgPvsSize(); … … 574 576 } 575 577 578 cout << "here" << endl; 576 579 //-- post process view cells 577 580 mViewCellsManager->PostProcess(objects, storedRays); -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp
r462 r465 357 357 stream<<"<IndexedLineSet coordIndex=\""<<endl; 358 358 else 359 stream<<"<IndexedFaceSet ccw=\"TRUE\" coordIndex=\""<<endl; 359 //stream<<"<IndexedFaceSet ccw=\"TRUE\" coordIndex=\""<<endl; 360 stream << "<IndexedFaceSet coordIndex=\"" << endl; 360 361 361 362 FaceContainer::const_iterator fi = mesh->mFaces.begin(); … … 431 432 //-- create and write indices 432 433 if (mWireframe) 433 stream << "<IndexedLineSet ccw=\"TRUE\" coordIndex=\"" <<endl;434 stream<<"<IndexedLineSet coordIndex=\""<<endl; 434 435 else 435 stream << "<IndexedFaceSet ccw=\"TRUE\" coordIndex=\"" << endl;436 436 //stream << "<IndexedFaceSet ccw=\"TRUE\" coordIndex=\"" << endl; 437 stream << "<IndexedFaceSet coordIndex=\"" << endl; 437 438 int index = 0; 438 439 … … 497 498 //-- create and write indices 498 499 if (mWireframe) 499 stream << "<IndexedLineSet ccw=\"TRUE\" coordIndex=\"" <<endl;500 stream<<"<IndexedLineSet coordIndex=\""<<endl; 500 501 else 501 stream << "<IndexedFaceSet ccw=\"TRUE\" coordIndex=\"" << endl; 502 //stream << "<IndexedFaceSet ccw=\"TRUE\" coordIndex=\"" << endl; 503 stream << "<IndexedFaceSet coordIndex=\"" << endl; 502 504 503 505 int index = 0;
Note: See TracChangeset
for help on using the changeset viewer.