Changeset 2726 for GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
- Timestamp:
- 05/30/08 02:37:07 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r2725 r2726 13 13 #include "Polygon3.h" 14 14 #include "IntersectableWrapper.h" 15 15 #include "Timer/PerfTimer.h" 16 16 17 17 … … 27 27 28 28 static ObjectContainer myobjects; 29 static int sInvalidSamples = 0; 30 31 /////////// 32 //-- timers 33 34 35 static PerfTimer rayTimer; 36 static PerfTimer kdPvsTimer; 37 static PerfTimer gvsTimer; 38 static PerfTimer initialTimer; 39 static PerfTimer intersectionTimer; 40 static PerfTimer preparationTimer; 41 static PerfTimer mainLoopTimer; 42 static PerfTimer contributionTimer; 43 static PerfTimer castTimer; 44 static PerfTimer generationTimer; 45 46 47 ///////////////////// 29 48 30 49 … … 145 164 const float len = Magnitude(currentRay.mTermination - currentRay.mOrigin); 146 165 147 #if 1148 166 // distance large => this is likely to be a discontinuity 149 if ((predictedLen - len) > mThreshold) 150 #else 167 if ((predictedLen - len) > mThreshold) 151 168 // q: rather use relative distance? 152 if ((predictedLen / len) > mThreshold)153 #endif 154 { 169 //if ((predictedLen / len) > mThreshold) 170 { 171 #if 0 155 172 // apply reverse sampling to find the gap 156 173 VssRay *newRay = ReverseSampling(currentRay, hitTriangle, oldRay); … … 162 179 if (0) newRay->mFlags |= VssRay::ReverseSample; 163 180 181 rayTimer.Entry(); 164 182 // check if ray can be processed further 165 183 // note: ray deletion handled by ray pool) 166 184 HandleRay(newRay); 185 rayTimer.Exit(); 167 186 168 187 return 1; 169 188 } 189 #else 190 static VssRayContainer reverseRays; 191 reverseRays.clear(); 192 193 // apply reverse sampling to find the gap 194 ReverseSampling2(currentRay, hitTriangle, oldRay, reverseRays); 195 196 rayTimer.Entry(); 197 198 int castRays = 0; 199 // check if reverse sampling was successful 200 for (size_t i = 0; i < reverseRays.size(); ++ i) 201 { 202 // check if ray can be processed further 203 // note: ray deletion handled by ray pool) 204 if (reverseRays[i]) 205 { 206 ++ castRays; 207 HandleRay(reverseRays[i]); 208 } 209 } 210 211 rayTimer.Exit(); 212 213 return castRays; 214 215 #endif 170 216 } 171 217 … … 193 239 void GvsPreprocessor::UpdateStatsForVisualization(KdIntersectable *kdInt) 194 240 { 241 int numObj = 0; 242 195 243 // count new objects in pvs due to kd node conversion 196 244 myobjects.clear(); … … 198 246 mKdTree->CollectObjectsWithDublicates(kdInt->GetItem(), myobjects); 199 247 200 int numObj;201 202 248 ObjectContainer::const_iterator oit, oit_end = myobjects.end(); 203 249 204 250 for (oit = myobjects.begin(); oit != oit_end; ++ oit) 205 numObj = CountObject(*oit);251 numObj += CountObject(*oit); 206 252 207 253 mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt, numObj); … … 209 255 210 256 257 void GvsPreprocessor::AddKdNodeToPvs(const Vector3 &termination) 258 { 259 kdPvsTimer.Entry(); 260 261 // exchange the triangle with the node in the pvs for kd pvs 262 KdNode *node = mKdTree->GetPvsNode(termination); 263 264 //KdNode *node = mKdTree->GetPvsNodeCheck(ray.mTermination, obj); 265 //if (!node) cerr << "e " << obj->GetBox() << " " << ray.mTermination << endl; else 266 if (!node->Mailed()) 267 { 268 // add to pvs 269 node->Mail(); 270 KdIntersectable *kdInt = mKdTree->GetOrCreateKdIntersectable(node); 271 mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f); 272 273 if (QT_VISUALIZATION_SHOWN) UpdateStatsForVisualization(kdInt); 274 } 275 276 kdPvsTimer.Exit(); 277 } 278 279 211 280 bool GvsPreprocessor::HasContribution(VssRay &ray) 212 281 { … … 214 283 return false; 215 284 285 contributionTimer.Entry(); 286 216 287 bool result; 217 288 … … 219 290 { 220 291 // store the rays + the intersected view cells 221 const bool storeViewCells = false; //GVS_DEBUG;292 const bool storeViewCells = false; 222 293 223 294 mViewCellsManager->ComputeSampleContribution(ray, … … 230 301 else // original per view cell gvs 231 302 { 232 Intersectable *obj = ray.mTerminationObject;233 234 303 // test if triangle was accounted for yet 235 result = AddTriangleObject( obj);304 result = AddTriangleObject(ray.mTerminationObject); 236 305 237 if (mUseKdPvs && (1 || result)) 238 { 239 // exchange the triangle with the node in the pvs for kd pvs 240 KdNode *node = mKdTree->GetPvsNode(ray.mTermination); 241 242 //KdNode *node = mKdTree->GetPvsNodeCheck(ray.mTermination, obj); 243 //if (!node) cerr << "e " << obj->GetBox() << " " << ray.mTermination << endl; else 244 if (!node->Mailed()) 245 { 246 // add to pvs 247 node->Mail(); 248 KdIntersectable *kdInt = mKdTree->GetOrCreateKdIntersectable(node); 249 mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f); 250 251 if (QT_VISUALIZATION_SHOWN) UpdateStatsForVisualization(kdInt); 252 } 253 } 254 } 306 if (mUseKdPvs) 307 AddKdNodeToPvs(ray.mTermination); 308 } 309 310 contributionTimer.Exit(); 255 311 256 312 return result; … … 363 419 const Vector3 p = (p1 + p2) * 0.5f; 364 420 //cout << "p: " << p << " " << p1 << " " << p2 << endl; 421 422 SimpleRay sray(oldRay.mOrigin, p - oldRay.mOrigin, SamplingStrategy::GVS, 1.0f); 423 424 #if 1 425 castTimer.Entry(); 426 // cast single ray to check if a triangle was missed 427 VssRay *newRay = mRayCaster->CastRay(sray, mViewCellsManager->GetViewSpaceBox(), !mPerViewCell); 428 castTimer.Exit(); 429 ++ castRays; 430 431 // this ray will not be further processed 432 // note: ray deletion is handled by ray pool 433 if (!newRay) return castRays; 434 435 // new triangle discovered? => add new ray to queue 436 rayTimer.Entry(); 437 HandleRay(newRay); 438 rayTimer.Exit(); 439 440 441 442 #else 443 365 444 // cast ray into the new point 366 SimpleRay sray(oldRay.mOrigin, p - oldRay.mOrigin, SamplingStrategy::GVS, 1.0f); 367 368 VssRay *newRay = mRayCaster->CastRay(sray, mViewCellsManager->GetViewSpaceBox(), !mPerViewCell); 369 370 ++ castRays; 371 445 static SimpleRayContainer importanceRays; 446 importanceRays.clear(); 447 448 generationTimer.Entry(); 449 450 451 importanceRays.push_back(sray); 452 453 const int numRandomRays = 15; 454 455 GenerateJitteredRays(importanceRays, sray, numRandomRays, 0); 456 GenerateRays(numRandomRays, *mDistribution, importanceRays, sInvalidSamples); 457 458 generationTimer.Exit(); 459 460 // for the original implementation we don't cast double rays 461 const bool castDoubleRays = !mPerViewCell; 462 // cannot prune invalid rays because we have to compare adjacent rays 463 const bool pruneInvalidRays = false; 464 465 static VssRayContainer vssRays; 466 vssRays.clear(); 467 468 castTimer.Entry(); 469 CastRays(importanceRays, vssRays, castDoubleRays, pruneInvalidRays); 470 castTimer.Exit(); 471 472 castRays += (int)vssRays.size(); 473 474 VssRay *newRay = vssRays.empty() ? NULL : vssRays[0]; 475 476 // new triangle discovered? => add new ray to queue 477 rayTimer.Entry(); 478 for (size_t i = 0; i < vssRays.size(); ++ i) 479 { 480 if (vssRays[i]) 481 HandleRay(vssRays[i]); 482 } 483 484 rayTimer.Exit(); 485 486 // this ray will not be further processed 487 // note: ray deletion is handled by ray pool 372 488 if (!newRay) return castRays; 489 #endif 373 490 374 491 //newRay->mFlags |= VssRay::BorderSample; 375 376 // add new ray to queue377 const bool enqueued = HandleRay(newRay);378 492 379 493 // subdivide further 380 494 castRays += SubdivideEdge(hitTriangle, p1, p, ray1, *newRay, oldRay); 381 495 castRays += SubdivideEdge(hitTriangle, p, p2, *newRay, ray2, oldRay); 382 383 // this ray will not be further processed 384 // note: ray deletion is handled by ray pool 385 496 386 497 return castRays; 387 498 } … … 391 502 { 392 503 Intersectable *tObj = currentRay.mTerminationObject; 393 // q matt: can this be possible 504 505 // question matt: can this be possible? 394 506 if (!tObj) return 0; 395 507 … … 410 522 411 523 /// create rays from sample points and handle them 412 SimpleRayContainer simpleRays; 413 simpleRays.reserve(9); 524 static SimpleRayContainer simpleRays; 525 simpleRays.clear(); 526 //simpleRays.reserve(9); 414 527 415 528 VertexContainer::const_iterator vit, vit_end = enlargedTriangle.end(); … … 432 545 } 433 546 434 // cast rays to triangle vertices and determine visibility 547 548 ////////// 549 //-- fill up simple rays with random rays so we can cast 16 rays at a time 550 551 const int numRandomRays = 16 - (int)simpleRays.size(); 552 SimpleRay mainRay = SimpleRay(currentRay.GetOrigin(), currentRay.GetNormalizedDir(), SamplingStrategy::GVS, 1.0f); 553 554 GenerateJitteredRays(simpleRays, mainRay, numRandomRays, 0); 555 //GenerateRays(numRandomRays, *mDistribution, simpleRays, sInvalidSamples); 556 557 558 ///////////////////// 559 //-- cast rays to vertices and determine visibility 560 435 561 VssRayContainer vssRays; 436 562 437 // don't cast double rays as we need only the forwardrays563 // for the original implementation we don't cast double rays 438 564 const bool castDoubleRays = !mPerViewCell; 439 // cannot prune invalid rays because we have to compare adjacent rays.565 // cannot prune invalid rays because we have to compare adjacent rays 440 566 const bool pruneInvalidRays = false; 441 567 442 443 ////////// 444 //-- fill up simple rays with random rays so we can cast 16 rays simultaniosly 445 446 //const int numRandomRays = 0; 447 const int numRandomRays = 16 - (int)simpleRays.size(); 448 449 GenerateRays(numRandomRays, *mDistribution, simpleRays); 450 451 452 ///////////////////// 453 454 // keep origin for per view cell sampling 568 castTimer.Entry(); 455 569 CastRays(simpleRays, vssRays, castDoubleRays, pruneInvalidRays); 570 castTimer.Exit(); 456 571 457 572 const int numBorderSamples = (int)vssRays.size() - numRandomRays; 458 573 int castRays = (int)simpleRays.size(); 574 575 // handle cast rays 576 EnqueueRays(vssRays); 577 459 578 #if 0 460 579 // set flags … … 464 583 #endif 465 584 466 int castRays = (int)simpleRays.size();467 468 VssRayContainer invalidSamples;469 470 // handle rays471 EnqueueRays(vssRays, invalidSamples);472 585 473 586 // recursivly subdivide each edge … … 483 596 484 597 mGvsStats.mBorderSamples += castRays; 485 486 598 487 599 return castRays; … … 546 658 // other types not implemented yet 547 659 if (tObj->Type() == Intersectable::TRIANGLE_INTERSECTABLE) 548 {549 660 occluder = static_cast<TriangleIntersectable *>(tObj)->GetItem(); 550 }551 661 else 552 {553 662 cout << "reverse sampling: " << tObj->Type() << " not yet implemented" << endl; 554 }663 555 664 // get a point which is passing just outside of the occluder 556 665 Vector3 newPoint; … … 564 673 Vector3 newDir, newOrigin; 565 674 675 ////////////// 566 676 //-- Construct the mutated ray with xnew, 567 677 //-- dir = predicted(x)- pnew as direction vector 678 568 679 newDir = predicted - newPoint; 569 680 … … 608 719 609 720 721 bool GvsPreprocessor::ReverseSampling2(const VssRay ¤tRay, 722 const Triangle3 &hitTriangle, 723 const VssRay &oldRay, 724 VssRayContainer &reverseRays) 725 { 726 // get triangle occluding the path to the hit mesh 727 Triangle3 occluder; 728 Intersectable *tObj = currentRay.mTerminationObject; 729 730 // q: why can this happen? 731 if (!tObj) 732 return NULL; 733 734 // other types not implemented yet 735 if (tObj->Type() == Intersectable::TRIANGLE_INTERSECTABLE) 736 occluder = static_cast<TriangleIntersectable *>(tObj)->GetItem(); 737 else 738 cout << "reverse sampling: " << tObj->Type() << " not yet implemented" << endl; 739 740 // get a point which is passing just outside of the occluder 741 Vector3 newPoint; 742 743 // q: why is there sometimes no intersecton found? 744 if (!GetPassingPoint(currentRay, occluder, oldRay, newPoint)) 745 return NULL; 746 747 const Vector3 predicted = CalcPredictedHitPoint(currentRay, hitTriangle, oldRay); 748 749 Vector3 newDir, newOrigin; 750 751 ////////////// 752 //-- Construct the mutated ray with xnew, 753 //-- dir = predicted(x)- pnew as direction vector 754 755 newDir = predicted - newPoint; 756 757 // take xnew, p = intersect(viewcell, line(pnew, predicted(x)) as origin ? 758 // difficult to say!! 759 const float offset = 0.5f; 760 newOrigin = newPoint - newDir * offset; 761 762 763 ////////////// 764 //-- for per view cell sampling, we must check for intersection 765 //-- with the current view cell 766 767 if (mPerViewCell) 768 { 769 // send ray to view cell 770 static Ray ray; 771 772 ray.Clear(); 773 ray.Init(newOrigin, -newDir, Ray::LOCAL_RAY); 774 775 // check if ray intersects view cell 776 if (!mCurrentViewCell->CastRay(ray)) 777 return NULL; 778 779 Ray::Intersection &hit = ray.intersections[0]; 780 781 // the ray starts from the view cell 782 newOrigin = ray.Extrap(hit.mT); 783 } 784 785 static SimpleRayContainer reverseSimpleRays; 786 reverseSimpleRays.clear(); 787 788 SimpleRay mainRay = SimpleRay(newOrigin, newDir, SamplingStrategy::GVS, 1.0f); 789 790 reverseSimpleRays.push_back(mainRay); 791 GenerateJitteredRays(reverseSimpleRays, mainRay, 15, 0); 792 793 castTimer.Entry(); 794 CastRays(reverseSimpleRays, reverseRays, false, false); 795 castTimer.Exit(); 796 797 mGvsStats.mReverseSamples += reverseRays.size(); 798 799 return true; 800 } 801 802 610 803 int GvsPreprocessor::CastInitialSamples(int numSamples) 611 804 { 612 const long startTime = GetTime();805 initialTimer.Entry(); 613 806 614 807 // generate simple rays 615 SimpleRayContainer simpleRays; 616 808 static SimpleRayContainer simpleRays; 809 simpleRays.clear(); 810 811 812 generationTimer.Entry(); 617 813 ViewCellBorderBasedDistribution vcStrat(*this, mCurrentViewCell); 618 GenerateRays(numSamples, *mDistribution, simpleRays); 814 GenerateRays(numSamples, *mDistribution, simpleRays, sInvalidSamples); 815 generationTimer.Exit(); 619 816 620 817 //cout << "sr: " << simpleRays.size() << endl; 621 818 // generate vss rays 622 VssRayContainer samples; 623 819 static VssRayContainer samples; 820 samples.clear(); 821 624 822 const bool castDoubleRays = !mPerViewCell; 625 823 const bool pruneInvalidRays = true; 626 824 825 castTimer.Entry(); 627 826 CastRays(simpleRays, samples, castDoubleRays, pruneInvalidRays); 628 629 VssRayContainer invalidSamples; 827 castTimer.Exit(); 630 828 631 829 // add to ray queue 632 EnqueueRays(samples , invalidSamples);633 634 //CLEAR_CONTAINER(invalidSamples);635 //Debug << "generated " << numSamples << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 830 EnqueueRays(samples); 831 832 initialTimer.Exit(); 833 636 834 return (int)simpleRays.size(); 637 835 } 638 836 639 837 640 void GvsPreprocessor::EnqueueRays(VssRayContainer &samples, VssRayContainer &invalidSamples) 641 { 838 void GvsPreprocessor::EnqueueRays(VssRayContainer &samples) 839 { 840 rayTimer.Entry(); 841 642 842 // add samples to ray queue 643 843 VssRayContainer::const_iterator vit, vit_end = samples.end(); … … 645 845 { 646 846 VssRay *ray = *vit; 647 648 847 HandleRay(ray); 649 //if (!HandleRay(ray)) invalidSamples.push_back(ray); 650 } 848 // note: deletion of invalid samples handked by ray pool 849 } 850 851 rayTimer.Exit(); 651 852 } 652 853 … … 654 855 int GvsPreprocessor::ProcessQueue() 655 856 { 857 gvsTimer.Entry(); 858 656 859 ++ mGvsStats.mGvsRuns; 657 860 658 861 int castSamples = 0; 659 862 660 while (!mRayQueue.empty()) //&& (mGvsStats.mTotalSamples + castSamples < mTotalSamples) )863 while (!mRayQueue.empty()) 661 864 { 662 865 // handle next ray … … 664 867 mRayQueue.pop(); 665 868 666 const int newSamples = AdaptiveBorderSampling(*ray); 667 668 castSamples += newSamples; 869 castSamples += AdaptiveBorderSampling(*ray); 669 870 // note: don't have to delete because handled by ray pool 670 871 } 671 872 672 /*if (mRayCaster->mVssRayPool.mIndex > mSamplesPerPass) 673 { 674 cout << "warning: new samples: " << castSamples << " " << "queue: " << (int)mRayQueue.size() << endl; 675 Debug << "warning: new samples: " << castSamples << " " << "queue: " << (int)mRayQueue.size() << endl; 676 }*/ 873 gvsTimer.Exit(); 677 874 678 875 return castSamples; … … 694 891 { 695 892 if ((*rit)->mFlags & VssRay::BorderSample) 696 {697 893 vcRays.push_back(*rit); 698 }699 894 else if ((*rit)->mFlags & VssRay::ReverseSample) 700 {701 895 vcRays2.push_back(*rit); 702 }703 896 else 704 {705 897 vcRays3.push_back(*rit); 706 } 707 } 898 } 708 899 } 709 900 … … 719 910 Material m; 720 911 721 char str[64]; sprintf (str, "pass%06d.wrl", mProcessedViewCells);912 char str[64]; sprintf_s(str, "pass%06d.wrl", mProcessedViewCells); 722 913 723 914 Exporter *exporter = Exporter::GetExporter(str); … … 880 1071 void GvsPreprocessor::ComputeViewCellGeometryIntersection() 881 1072 { 1073 intersectionTimer.Entry(); 1074 882 1075 AxisAlignedBox3 box = mCurrentViewCell->GetBox(); 883 1076 … … 927 1120 928 1121 cout << "added " << (int)mTrianglePvs.size() - oldTrianglePvs << " triangles (" << newKdObj << " objects) by intersection" << endl; 1122 1123 intersectionTimer.Exit(); 929 1124 } 930 1125 … … 934 1129 while (mCurrentViewCell = NextViewCell()) 935 1130 { 936 // hack: reset counters 1131 preparationTimer.Entry(); 1132 1133 // hack: reset counters (could be done with a mailing-like approach 937 1134 ObjectContainer::const_iterator oit, oit_end = mObjects.end(); 938 939 1135 for (oit = mObjects.begin(); oit != oit_end; ++ oit) 940 1136 (*oit)->mCounter = NOT_ACCOUNTED_OBJECT; 941 1137 1138 preparationTimer.Exit(); 1139 942 1140 mDistribution->SetViewCell(mCurrentViewCell); 1141 943 1142 ComputeViewCell(); 944 1143 } … … 1041 1240 { 1042 1241 int passSamples = 0; 1242 int randomSamples = 0; 1243 int gvsSamples = 0; 1043 1244 int oldContribution = 0; 1044 1245 … … 1046 1247 { 1047 1248 mRayCaster->InitPass(); 1249 1250 int newRandomSamples, newGvsSamples; 1048 1251 1049 1252 // Ray queue empty => 1050 1253 // cast a number of uniform samples to fill ray queue 1051 int newSamples = CastInitialSamples(mInitialSamples);1052 1254 newRandomSamples = CastInitialSamples(mInitialSamples); 1255 1053 1256 if (!mOnlyRandomSampling) 1054 newSamples += ProcessQueue(); 1055 1056 passSamples += newSamples; 1057 mGvsStats.mTotalSamples += newSamples; 1257 newGvsSamples = ProcessQueue(); 1258 1259 passSamples += newRandomSamples + newGvsSamples; 1260 mGvsStats.mTotalSamples += newRandomSamples + newGvsSamples; 1261 1262 mGvsStats.mRandomSamples += newRandomSamples; 1263 mGvsStats.mGvsSamples += newGvsSamples; 1264 1058 1265 1059 1266 if (passSamples % (mGvsSamplesPerPass + 1) == mGvsSamplesPerPass) … … 1062 1269 1063 1270 mGvsStats.mPassContribution = mGvsStats.mTotalContribution - oldContribution; 1064 1271 1065 1272 //////// 1066 1273 //-- stats … … 1220 1427 void GvsPreprocessor::ComputeViewCell() 1221 1428 { 1222 //if (mCurrentViewCell->GetId() != 499) return; 1223 1224 // clean up 1429 const long startTime = GetTime(); 1430 1431 // initialise 1432 mGvsStats.mPerViewCellSamples = 0; 1433 1434 int oldContribution = 0; 1435 int passSamples = 0; 1436 for (int i = 0; i < 0; ++ i) 1437 mGenericStats[i] = 0; 1438 1225 1439 mTrianglePvs.clear(); 1226 1440 1441 1442 // hack: take bounding box of view cell as view cell bounds 1227 1443 mCurrentViewCell->GetMesh()->ComputeBoundingBox(); 1228 1444 1445 // use mailing for kd node pvs 1229 1446 KdNode::NewMail(); 1230 1231 const long startTime = GetTime();1232 1447 1233 1448 cout << "\n***********************\n" … … 1236 1451 cout << "bb: " << mCurrentViewCell->GetBox() << endl; 1237 1452 1238 mGvsStats.mPerViewCellSamples = 0; 1239 1240 int oldContribution = 0; 1241 int passSamples = 0; 1242 1243 for (int i = 0; i < 0; ++ i) 1244 mGenericStats[i] = 0; 1453 mainLoopTimer.Entry(); 1245 1454 1246 1455 while (1) 1247 1456 { 1457 sInvalidSamples = 0; 1248 1458 int oldPvsSize = mCurrentViewCell->GetPvs().GetSize(); 1249 1459 1250 1460 mRayCaster->InitPass(); 1251 1461 1462 int newRandomSamples, newGvsSamples, newSamples; 1463 1252 1464 // Ray queue empty => 1253 1465 // cast a number of uniform samples to fill ray queue 1254 int newSamples = CastInitialSamples(mInitialSamples);1255 1466 newRandomSamples = CastInitialSamples(mInitialSamples); 1467 1256 1468 if (!mOnlyRandomSampling) 1257 { 1258 int samplesPerRun = ProcessQueue(); 1259 newSamples += samplesPerRun; 1260 //if (samplesPerRun > 0) cout << "spr: " << samplesPerRun << " "; 1261 } 1469 newGvsSamples = ProcessQueue(); 1470 1471 newSamples = newRandomSamples + newGvsSamples; 1262 1472 1263 1473 passSamples += newSamples; 1264 mGvsStats.mPerViewCellSamples += newSamples; 1474 mGvsStats.mPerViewCellSamples += newSamples; 1475 1476 mGvsStats.mRandomSamples += newRandomSamples; 1477 mGvsStats.mGvsSamples += newGvsSamples; 1478 1265 1479 1266 1480 if (passSamples >= mGvsSamplesPerPass) … … 1303 1517 } 1304 1518 1519 mainLoopTimer.Exit(); 1520 1305 1521 // at last compute objects that directly intersect view cell 1306 1522 ComputeViewCellGeometryIntersection(); 1307 1308 1523 1524 1309 1525 //////// 1310 1526 //-- stats … … 1321 1537 // compute pvs size using larger (bvh objects) 1322 1538 // note: for kd pvs we had to do this during gvs computation 1323 1324 1539 if (!mUseKdPvs) 1325 1540 { … … 1343 1558 mGvsStats.mPvsCost = 0; // todo objectPvs.EvalPvsCost(); 1344 1559 } 1345 else if (0) 1346 { 1347 //KdNode::NewMail(); 1348 1349 // compute pvs kd nodes that intersect view cell 1560 else if (0) // compute pvs kd nodes that intersect view cell 1561 { 1350 1562 ObjectContainer mykdobjects; 1351 1563 … … 1387 1599 mGvsStats.mTotalSamples += mGvsStats.mPerViewCellSamples; 1388 1600 1601 cout << "id: " << mCurrentViewCell->GetId() << " pvs cost: " 1602 << mGvsStats.mPvsCost << " pvs tri: " << mTrianglePvs.size() << endl; 1603 1604 cout << "invalid samples ratio: " << (float)sInvalidSamples / mGvsStats.mPerViewCellSamples << endl; 1605 1606 float rayTime = rayTimer.TotalTime(); 1607 float kdPvsTime = kdPvsTimer.TotalTime(); 1608 float gvsTime = gvsTimer.TotalTime(); 1609 float initialTime = initialTimer.TotalTime(); 1610 float intersectionTime = intersectionTimer.TotalTime(); 1611 float preparationTime = preparationTimer.TotalTime(); 1612 float mainLoopTime = mainLoopTimer.TotalTime(); 1613 float contributionTime = contributionTimer.TotalTime(); 1614 float castTime = castTimer.TotalTime(); 1615 float generationTime = generationTimer.TotalTime(); 1616 1617 cout << "handleRay : " << rayTime << endl; 1618 cout << "kd pvs : " << kdPvsTime << endl; 1619 cout << "gvs sampling : " << gvsTime << endl; 1620 cout << "initial sampling : " << initialTime << endl; 1621 cout << "view cell intersection : " << intersectionTime << endl; 1622 cout << "preparation : " << preparationTime << endl; 1623 cout << "main loop : " << mainLoopTime << endl; 1624 cout << "has contribution : " << contributionTime << endl; 1625 cout << "cast time : " << castTime << endl; 1626 cout << "generation time : " << generationTime << endl; 1627 1628 float randomRaysPerSec = mGvsStats.mRandomSamples / (1e6f * initialTime); 1629 float gvsRaysPerSec = mGvsStats.mGvsSamples / (1e6f * gvsTime); 1630 1631 cout << "cast " << randomRaysPerSec << " M random rays/s: " << endl; 1632 cout << "cast " << gvsRaysPerSec << " M gvs rays/s: " << endl; 1633 1389 1634 mGvsStats.Stop(); 1390 1635 mGvsStats.Print(mGvsStatsStream); 1391 1636 1392 cout << "id: " << mCurrentViewCell->GetId() << " pvs cost: " 1393 << mGvsStats.mPvsCost << " pvs tri: " << mTrianglePvs.size() << endl; 1394 } 1395 1396 1397 ObjectContainer triangles; 1637 } 1638 1639 1398 1640 1399 1641 int GvsPreprocessor::ConvertObjectPvs() 1400 1642 { 1643 static ObjectContainer triangles; 1644 1401 1645 int newObjects = 0; 1402 1646
Note: See TracChangeset
for help on using the changeset viewer.