- Timestamp:
- 01/18/07 20:20:48 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1990 r1996 1317 1317 1318 1318 RegisterOption("GvsPreprocessor.stats", 1319 optString, 1320 "gvs_stats=", 1321 "gvsStats.log"); 1322 1319 optString, 1320 "gvs_stats=", 1321 "gvsStats.log"); 1322 1323 RegisterOption("GvsPreprocessor.minContribution", 1324 optInt, 1325 "gvs_min_contribution=", 1326 "50"); 1327 1328 RegisterOption("GvsPreprocessor.maxViewCells", 1329 optInt, 1330 "gvs_max_viewcells=", 1331 "5"); 1332 1333 1323 1334 /**********************************************************************/ 1324 1335 /* View cells related options */ -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r1990 r1996 16 16 { 17 17 18 #define GVS_DEBUG 118 #define GVS_DEBUG 0 19 19 20 20 struct VizStruct … … 33 33 mSamplingType(SamplingStrategy::VIEWCELL_BASED_DISTRIBUTION), 34 34 //mSamplingType(SamplingStrategy::DIRECTION_BASED_DISTRIBUTION), 35 m NumViewCells(0),35 mProcessedViewCells(0), 36 36 mCurrentViewCell(NULL) 37 37 { … … 39 39 Environment::GetSingleton()->GetIntValue("GvsPreprocessor.initialSamples", mInitialSamples); 40 40 Environment::GetSingleton()->GetIntValue("GvsPreprocessor.samplesPerPass", mSamplesPerPass); 41 Environment::GetSingleton()->GetIntValue("GvsPreprocessor.minContribution", mMinContribution); 41 42 Environment::GetSingleton()->GetFloatValue("GvsPreprocessor.epsilon", mEps); 42 43 Environment::GetSingleton()->GetFloatValue("GvsPreprocessor.threshold", mThreshold); 43 44 Environment::GetSingleton()->GetBoolValue("GvsPreprocessor.perViewCell", mPerViewCell); 45 Environment::GetSingleton()->GetIntValue("GvsPreprocessor.maxViewCells", mMaxViewCells); 44 46 45 47 char gvsStatsLog[100]; … … 54 56 Debug << "epsilon: " << mEps << endl; 55 57 Debug << "stats: " << gvsStatsLog << endl; 58 Debug << "per view cell: " << mPerViewCell << endl; 59 Debug << "max view cells: " << mMaxViewCells << endl; 60 Debug << "min contribution: " << mMinContribution << endl; 56 61 57 62 if (1) … … 66 71 GvsPreprocessor::~GvsPreprocessor() 67 72 { 73 ClearRayQueue(); 74 } 75 76 77 void GvsPreprocessor::ClearRayQueue() 78 { 68 79 // clean ray queue 69 80 while (!mRayQueue.empty()) … … 80 91 bool GvsPreprocessor::NextViewCell() 81 92 { 82 if (mViewCellsManager->GetNumViewCells() == mNumViewCells) 93 //if (mViewCellsManager->GetNumViewCells() == mProcessedViewCells) 94 // return false; // no more view cells 95 96 if (mProcessedViewCells == (int)mViewCells.size()) 83 97 return false; // no more view cells 84 98 85 if (1) 86 mCurrentViewCell = mViewCellsManager->GetViewCell(mNumViewCells); 87 else 88 { 89 // HACK 90 int idx = (int)RandomValue(0.0f, (float)mViewCellsManager->GetNumViewCells() - 0.5f); 91 mCurrentViewCell = mViewCellsManager->GetViewCell(idx); 92 } 93 94 if (!mCurrentViewCell->GetMesh()) 99 mCurrentViewCell = mViewCells[mProcessedViewCells]; 100 101 if (!mCurrentViewCell->GetMesh()) 95 102 mViewCellsManager->CreateMesh(mCurrentViewCell); 96 103 97 ++ mNumViewCells; 104 mGvsStats.mViewCellId = mCurrentViewCell->GetId(); 105 106 Debug << "vc: " << mCurrentViewCell->GetId() << endl; 107 108 ++ mProcessedViewCells; 98 109 99 110 return true; … … 101 112 102 113 103 boolGvsPreprocessor::CheckDiscontinuity(const VssRay ¤tRay,104 105 114 int GvsPreprocessor::CheckDiscontinuity(const VssRay ¤tRay, 115 const Triangle3 &hitTriangle, 116 const VssRay &oldRay) 106 117 { 107 118 // the predicted hitpoint: we expect to hit the same mesh again … … 123 134 124 135 if (!newRay) 125 return false;136 return 1; 126 137 127 138 // set flag for visualization … … 140 151 } 141 152 142 return true;143 } 144 145 return false;153 return 1; 154 } 155 156 return 0; 146 157 } 147 158 … … 269 280 const VssRay &oldRay) 270 281 { 282 int castRays = 0; 283 271 284 // cast reverse rays if necessary 272 CheckDiscontinuity(ray1, hitTriangle, oldRay);273 CheckDiscontinuity(ray2, hitTriangle, oldRay);285 castRays += CheckDiscontinuity(ray1, hitTriangle, oldRay); 286 castRays += CheckDiscontinuity(ray2, hitTriangle, oldRay); 274 287 275 288 if (EqualVisibility(ray1, ray2) || (Magnitude(p1 - p2) <= MIN_DIST)) 276 289 { 277 return 0;290 return castRays; 278 291 } 279 292 … … 284 297 SimpleRay sray(oldRay.mOrigin, p - oldRay.mOrigin, SamplingStrategy::GVS, 1.0f); 285 298 286 VssRay *newRay = mRayCaster->CastRay(sray, mViewCellsManager->GetViewSpaceBox(), mPerViewCell); 287 288 if (!newRay) return 0; 299 VssRay *newRay = mRayCaster->CastRay(sray, mViewCellsManager->GetViewSpaceBox(), !mPerViewCell); 300 301 ++ castRays; 302 303 if (!newRay) return castRays; 289 304 290 305 newRay->mFlags |= VssRay::BorderSample; … … 294 309 295 310 // subdivide further 296 c onst int samples1= SubdivideEdge(hitTriangle, p1, p, ray1, *newRay, oldRay);297 c onst int samples2= SubdivideEdge(hitTriangle, p, p2, *newRay, ray2, oldRay);311 castRays += SubdivideEdge(hitTriangle, p1, p, ray1, *newRay, oldRay); 312 castRays += SubdivideEdge(hitTriangle, p, p2, *newRay, ray2, oldRay); 298 313 299 314 // this ray will not be further processed … … 301 316 delete newRay; 302 317 303 return samples1 + samples2 + 1;318 return castRays; 304 319 } 305 320 … … 352 367 353 368 // don't cast double rays as we need only the forward rays 354 const bool castDoubleRays = false;369 const bool castDoubleRays = !mPerViewCell; 355 370 // cannot prune invalid rays because we have to compare adjacent rays. 356 371 const bool pruneInvalidRays = false; 357 372 373 374 ////////// 375 //-- fill up simple rays with random rays so we can cast 16 376 377 //const int numRandomRays = 0; 378 const int numRandomRays = 16 - (int)simpleRays.size(); 379 ViewCellBasedDistribution vcStrat(*this, mCurrentViewCell); 380 381 GenerateRays(numRandomRays, vcStrat, simpleRays); 382 383 ///////////////////// 384 385 358 386 // keep origin for per view cell sampling 359 CastRays(simpleRays, vssRays, castDoubleRays, pruneInvalidRays, mPerViewCell); 387 CastRays(simpleRays, vssRays, castDoubleRays, pruneInvalidRays); 388 389 const int numBorderSamples = (int)vssRays.size() - numRandomRays; 360 390 361 391 // set flags 362 392 VssRayContainer::const_iterator rit, rit_end = vssRays.end(); 363 for (rit = vssRays.begin(); rit != rit_end; ++ rit) 364 { 365 (*rit)->mFlags |= VssRay::BorderSample; 393 int i = 0; 394 395 for (rit = vssRays.begin(); rit != rit_end; ++ rit, ++ i) 396 { 397 if (i < numBorderSamples) 398 (*rit)->mFlags |= VssRay::BorderSample; 366 399 } 367 400 … … 369 402 EnqueueRays(vssRays); 370 403 371 const int n = (int)vssRays.size(); 372 int castRays = n; 404 int castRays = simpleRays.size(); 373 405 374 406 // recursivly subdivide each edge 375 for (int i = 0; i < n ; ++ i)407 for (int i = 0; i < numBorderSamples; ++ i) 376 408 { 377 409 castRays += SubdivideEdge(hitTriangle, 378 410 enlargedTriangle[i], 379 enlargedTriangle[(i + 1) % n ],411 enlargedTriangle[(i + 1) % numBorderSamples], 380 412 *vssRays[i], 381 *vssRays[(i + 1) % n ],413 *vssRays[(i + 1) % numBorderSamples], 382 414 currentRay); 383 415 } … … 389 421 390 422 391 Vector3 GvsPreprocessor::GetPassingPoint(const VssRay ¤tRay, 392 const Triangle3 &occluder, 393 const VssRay &oldRay) const 423 bool GvsPreprocessor::GetPassingPoint(const VssRay ¤tRay, 424 const Triangle3 &occluder, 425 const VssRay &oldRay, 426 Vector3 &newPoint) const 394 427 { 395 428 //-- The plane p = (xp, hit(x), hit(xold)) is intersected … … 408 441 409 442 if (!intersects) 410 cerr << "big error!! no intersection" << endl; 443 { 444 cerr << "big error!! no intersection " << pt1 << " " << pt2 << endl; 445 return false; 446 } 411 447 412 448 // get the intersection point on the old ray … … 417 453 418 454 // Evaluate new hitpoint just outside the triangle 419 Vector3 newPoint;420 421 455 const float eps = mEps; 422 456 … … 432 466 433 467 //cout << "passing point: " << newPoint << endl << endl; 434 return newPoint;468 return true; 435 469 } 436 470 … … 455 489 456 490 // get a point which is passing just outside of the occluder 457 const Vector3 newPoint = GetPassingPoint(currentRay, occluder, oldRay); 491 Vector3 newPoint; 492 493 // why is there sometimes no intersecton found? 494 if (!GetPassingPoint(currentRay, occluder, oldRay, newPoint)) 495 return NULL; 496 458 497 const Vector3 predicted = CalcPredictedHitPoint(currentRay, hitTriangle, oldRay); 459 498 … … 479 518 ray.Clear(); 480 519 ray.Init(newOrigin, -newDir, Ray::LOCAL_RAY); 481 //ray.Init(newOrigin, -newDir, Ray::LINE_SEGMENT);482 520 483 521 //cout << "z"; … … 496 534 497 535 VssRay *reverseRay = 498 mRayCaster->CastRay(simpleRay, mViewCellsManager->GetViewSpaceBox(), mPerViewCell);536 mRayCaster->CastRay(simpleRay, mViewCellsManager->GetViewSpaceBox(), !mPerViewCell); 499 537 500 538 ++ mGvsStats.mReverseSamples; … … 513 551 514 552 ViewCellBasedDistribution vcStrat(*this, mCurrentViewCell); 515 516 553 GenerateRays(numSamples, vcStrat, simpleRays); 517 554 … … 520 557 VssRayContainer samples; 521 558 522 const bool castDoubleRays = false;559 const bool castDoubleRays = !mPerViewCell; 523 560 const bool pruneInvalidRays = true; 524 const bool keepOrigin = mPerViewCell; 525 526 CastRays(simpleRays, samples, castDoubleRays, pruneInvalidRays, keepOrigin); 561 562 CastRays(simpleRays, samples, castDoubleRays, pruneInvalidRays); 527 563 528 564 // add to ray queue … … 556 592 VssRay *ray = mRayQueue.top(); 557 593 mRayQueue.pop(); 558 if (!ray) cout << "Error!!!!!" << endl;594 559 595 const int newSamples = AdaptiveBorderSampling(*ray); 560 596 … … 598 634 599 635 //exporter->ExportRays(vcRays, RgbColor(1, 0, 0)); 600 exporter->ExportRays(vcRays2, RgbColor(0, 1, 0));636 //exporter->ExportRays(vcRays2, RgbColor(0, 1, 0)); 601 637 //exporter->ExportRays(vcRays3, RgbColor(1, 1, 1)); 602 638 } … … 609 645 Material m; 610 646 611 char str[64]; sprintf(str, "pass%06d.wrl", m NumViewCells);647 char str[64]; sprintf(str, "pass%06d.wrl", mProcessedViewCells); 612 648 613 649 Exporter *exporter = Exporter::GetExporter(str); … … 655 691 void GvsPreprocessor::VisualizeViewCells() 656 692 { 657 char str[64]; sprintf(str, "tmp/pass%06d_%04d-", m NumViewCells, mPass);693 char str[64]; sprintf(str, "tmp/pass%06d_%04d-", mProcessedViewCells, mPass); 658 694 659 695 // visualization … … 685 721 { 686 722 mGvsStats.mPerViewCellSamples = 0; 687 int oldContribution = 0;723 int oldContribution = mGvsStats.mTotalContribution; 688 724 int passSamples = 0; 689 725 690 while (mGvsStats.mPerViewCellSamples < mTotalSamples) 726 //while (mGvsStats.mPerViewCellSamples < mTotalSamples) 727 while (1) 691 728 { 692 729 // Ray queue empty => … … 699 736 passSamples += newSamples; 700 737 mGvsStats.mPerViewCellSamples += newSamples; 701 702 if (0 && 703 passSamples % (mSamplesPerPass + 1) == mSamplesPerPass)738 //cout << "here4 " << passSamples % (mSamplesPerPass + 1) << endl; 739 740 if (passSamples >= mSamplesPerPass) 704 741 { 705 742 ++ mPass; … … 711 748 712 749 mGvsStats.mPass = mPass; 713 mGvsStats.Stop(); 714 mGvsStats.Print(mGvsStatsStream); 715 716 //cout << "\nPass " << mPass << " #samples: " << mGvsStats.mTotalSamples << " of " << mTotalSamples << endl; 750 751 cout << "\nPass " << mPass << " #samples: " << mGvsStats.mPerViewCellSamples << endl; 752 cout << "contribution=" << mGvsStats.mPassContribution << " (of " << mMinContribution << ")" << endl; 753 754 // termination criterium 755 if (mGvsStats.mPassContribution < mMinContribution) 756 { 757 break; 758 } 717 759 718 760 // reset … … 725 767 726 768 769 void GvsPreprocessor::CompileViewCellsList() 770 { 771 while ((int)mViewCells.size() < mMaxViewCells) 772 { 773 if (0) 774 { 775 mViewCells.push_back(mViewCellsManager->GetViewCell((int)mViewCells.size())); 776 } 777 else 778 { 779 // HACK 780 const int tries = 10000; 781 int i = 0; 782 783 for (i = 0; i < tries; ++ i) 784 { 785 const int idx = (int)RandomValue(0.0f, (float)mViewCellsManager->GetNumViewCells() - 0.5f); 786 787 ViewCell *viewCell = mViewCellsManager->GetViewCell(idx); 788 789 if (!viewCell->Mailed()) 790 { 791 viewCell->Mail(); 792 break; 793 } 794 795 mViewCells.push_back(viewCell); 796 } 797 798 if (i == tries) 799 { 800 cerr << "big error! no view cell found" << endl; 801 return; 802 } 803 } 804 } 805 } 806 807 727 808 void GvsPreprocessor::PerViewCellComputation() 728 809 { 729 const int maxViewCells = 25; 730 731 while (mNumViewCells < maxViewCells && NextViewCell()) 732 { 733 cout << "processing view cell " << mNumViewCells << endl; 810 while (NextViewCell()) 811 { 812 cout << "\n***********************\nprocessing view cell " << mProcessedViewCells << endl; 734 813 735 814 // compute the pvs of the current view cell 736 815 ProcessViewCell(); 816 817 mGvsStats.mTrianglePvs = mCurrentViewCell->GetPvs().GetSize(); 737 818 738 819 // exchange triangle pvs with objects … … 748 829 //-- stats 749 830 750 mGvsStats.mViewCells = mNumViewCells;//mPass; 831 mGvsStats.mViewCells = mProcessedViewCells;//mPass; 832 mGvsStats.mPerViewCellPvs = mCurrentViewCell->GetPvs().GetSize(); 751 833 mGvsStats.mTotalPvs += mCurrentViewCell->GetPvs().GetSize(); 752 834 mGvsStats.mTotalSamples += mGvsStats.mPerViewCellSamples; … … 754 836 mGvsStats.Stop(); 755 837 mGvsStats.Print(mGvsStatsStream); 838 839 // is this really necessary? 840 ClearRayQueue(); 756 841 } 757 842 } … … 863 948 if (mPerViewCell) 864 949 { 950 // list of view cells to compute 951 CompileViewCellsList(); 952 865 953 PerViewCellComputation(); 866 954 } … … 916 1004 { 917 1005 app << "#Pass\n" << mPass << endl; 1006 app << "#ViewCellId\n" << mViewCellId << endl; 918 1007 app << "#Time\n" << Time() << endl; 919 1008 app << "#TotalSamples\n" << mTotalSamples << endl; … … 925 1014 app << "#ViewCells\n" << mViewCells << endl; 926 1015 app << "#TotalPvs\n" << mTotalPvs << endl; 1016 app << "#PerViewCellPvs\n" << mPerViewCellPvs << endl; 1017 app << "#TrianglePvs\n" << mTrianglePvs << endl; 1018 app << "#RaysPerSec\n" << RaysPerSec() << endl; 927 1019 app << "#PerViewCellSamples\n" << mPerViewCellSamples << endl << endl; 928 1020 } -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h
r1990 r1996 38 38 mViewCells = 0; 39 39 mPerViewCellSamples = 0; 40 mPerViewCellPvs = 0; 41 mTrianglePvs = 0; 42 mViewCellId = 0; 40 43 } 41 44 … … 54 57 int mViewCells; 55 58 int mPerViewCellSamples; 56 59 int mPerViewCellPvs; 60 int mTrianglePvs; 61 int mViewCellId; 62 63 float RaysPerSec() const { if (!Time()) return 0; return (float)mTotalSamples / Time() * 1e-6f; } 64 57 65 void Print(ostream &app) const; 58 66 … … 135 143 Does reverse sampling if gap found. 136 144 */ 137 boolCheckDiscontinuity(const VssRay ¤tRay,138 139 145 int CheckDiscontinuity(const VssRay ¤tRay, 146 const Triangle3 &hitTriangle, 147 const VssRay &oldRay); 140 148 141 149 /** Adds new samples to the ray queue and classifies them … … 169 177 const VssRay &oldRay) const; 170 178 171 172 Vector3 GetPassingPoint(const VssRay ¤tRay,173 const Triangle3 &hitTriangle,174 const VssRay &oldRay) const;179 bool GetPassingPoint(const VssRay ¤tRay, 180 const Triangle3 &occluder, 181 const VssRay &oldRay, 182 Vector3 &newPoint) const; 175 183 176 184 bool NextViewCell(); … … 189 197 190 198 void ProcessViewCell(); 199 void ClearRayQueue(); 200 201 void CompileViewCellsList(); 202 191 203 192 204 ////////////////////// … … 222 234 ViewCell *mCurrentViewCell; 223 235 224 int mNumViewCells; 236 int mProcessedViewCells; 237 238 int mMinContribution; 239 240 ViewCellContainer mViewCells; 241 242 int mMaxViewCells; 225 243 }; 226 244 -
GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp
r1990 r1996 38 38 const AxisAlignedBox3 &box, 39 39 const bool castDoubleRay, 40 const bool pruneInvalidRays, 41 const bool keepOrigin 40 const bool pruneInvalidRays 42 41 ) 43 42 { … … 103 102 box, 104 103 castDoubleRay, 105 pruneInvalidRays, 106 keepOrigin 104 pruneInvalidRays 107 105 ); 108 106 } … … 114 112 const AxisAlignedBox3 &sbox, 115 113 const bool castDoubleRay, 116 const bool pruneInvalidRays, 117 const bool keepOrigin) 114 const bool pruneInvalidRays) 118 115 { 119 116 int i; … … 230 227 sbox, 231 228 castDoubleRay, 232 pruneInvalidRays, 233 keepOrigin 229 pruneInvalidRays 234 230 ); 235 231 } -
GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.h
r1990 r1996 42 42 const AxisAlignedBox3 &box, 43 43 const bool castDoubleRay, 44 const bool pruneInvalidRays = true, 45 const bool keepOrigin = false); 44 const bool pruneInvalidRays = true); 46 45 47 46 virtual void CastRays16( … … 50 49 const AxisAlignedBox3 &sbox, 51 50 const bool castDoubleRay, 52 const bool pruneInvalidRays = true, 53 const bool keepOrigin = false); 51 const bool pruneInvalidRays = true); 54 52 55 53 protected: -
GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.cpp
r1990 r1996 25 25 const AxisAlignedBox3 &box, 26 26 const bool castDoubleRay, 27 const bool pruneInvalidRays, 28 const bool keepOrigin 29 ) 27 const bool pruneInvalidRays) 30 28 { 31 29 if (simpleRay.mType == Ray::GLOBAL_RAY) … … 75 73 box, 76 74 castDoubleRay, 77 pruneInvalidRays, 78 keepOrigin 75 pruneInvalidRays 79 76 ); 80 77 } … … 198 195 const AxisAlignedBox3 &sbox, 199 196 const bool castDoubleRays, 200 const bool pruneInvalidRays, 201 const bool keepOrigin) 197 const bool pruneInvalidRays) 202 198 { 203 199 #if DEBUG_RAYCAST … … 210 206 for (sit = rays.begin(); sit != sit_end; ++ sit) 211 207 { 212 CastRay(*sit, vssRays, sbox, castDoubleRays, pruneInvalidRays , keepOrigin);208 CastRay(*sit, vssRays, sbox, castDoubleRays, pruneInvalidRays); 213 209 } 214 210 -
GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.h
r1990 r1996 40 40 const AxisAlignedBox3 &box, 41 41 const bool castDoubleRay, 42 const bool pruneInvalidRays = true, 43 const bool keepOrigin = false 42 const bool pruneInvalidRays = true 44 43 ); 45 44 … … 48 47 const AxisAlignedBox3 &sbox, 49 48 const bool castDoubleRay, 50 const bool pruneInvalidRays = true, 51 const bool keepOrigin = false 49 const bool pruneInvalidRays = true 52 50 ); 53 51 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1990 r1996 1147 1147 VssRayContainer &vssRays, 1148 1148 const bool castDoubleRays, 1149 const bool pruneInvalidRays, 1150 const bool keepOrigin 1149 const bool pruneInvalidRays 1151 1150 ) 1152 1151 { … … 1199 1198 mViewCellsManager->GetViewSpaceBox(), 1200 1199 castDoubleRays, 1201 pruneInvalidRays, 1202 keepOrigin); 1200 pruneInvalidRays); 1203 1201 1204 1202 rayBucket.clear(); … … 1229 1227 mViewCellsManager->GetViewSpaceBox(), 1230 1228 castDoubleRays, 1231 pruneInvalidRays, 1232 keepOrigin); 1229 pruneInvalidRays); 1233 1230 1234 1231 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r1990 r1996 145 145 VssRayContainer &vssRays, 146 146 const bool castDoubleRays, 147 const bool pruneInvalidRays = true, 148 const bool keepOrigin = false); 147 const bool pruneInvalidRays = true); 149 148 150 149 /** Compute pixel error of the current PVS solution by sampling given number of viewpoints */ -
GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp
r1990 r1996 26 26 VssRay *RayCaster::CastRay(const SimpleRay &simpleRay, 27 27 const AxisAlignedBox3 &box, 28 const bool keepOrigin) 29 { 30 // note: make no sense otherwise 31 const bool castDoubleRay = false; 32 28 const bool castDoubleRay) 29 { 33 30 VssRayContainer rays; 34 CastRay(simpleRay, rays, box, castDoubleRay, true , keepOrigin);31 CastRay(simpleRay, rays, box, castDoubleRay, true); 35 32 36 33 if (!rays.empty()) … … 221 218 const AxisAlignedBox3 &box, 222 219 const bool castDoubleRay, 223 const bool pruneInvalidRays, 224 const bool keepOrigin) 220 const bool pruneInvalidRays) 225 221 { 226 222 int hits = 0; … … 283 279 if (!pruneInvalidRays || hitA.mObject) { 284 280 VssRay *vssRay = new VssRay( 285 keepOrigin? simpleRay.mOrigin : clipB,281 !castDoubleRay ? simpleRay.mOrigin : clipB, 286 282 hitA.mPoint, 287 283 hitB.mObject, … … 309 305 { 310 306 VssRay *vssRay = new VssRay( 311 keepOrigin ? simpleRay.mOrigin :clipA,307 clipA, 312 308 hitB.mPoint, 313 309 hitA.mObject, -
GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h
r1990 r1996 45 45 VssRay *CastRay(const SimpleRay &simpleRay, 46 46 const AxisAlignedBox3 &box, 47 const bool keepOrigin);47 const bool castDoubleRay); 48 48 49 49 virtual int CastRay(const SimpleRay &simpleRay, … … 51 51 const AxisAlignedBox3 &box, 52 52 const bool castDoubleRay, 53 const bool pruneInvalidRays = true, 54 const bool keepOrigin = false 55 ) = 0; 53 const bool pruneInvalidRays = true) = 0; 56 54 57 55 virtual void CastRays16( … … 60 58 const AxisAlignedBox3 &sbox, 61 59 const bool castDoubleRay, 62 const bool pruneInvalidRays = true, 63 const bool keepOrigin = false 64 ) = 0; 60 const bool pruneInvalidRays = true) = 0; 65 61 66 62 … … 101 97 const AxisAlignedBox3 &box, 102 98 const bool castDoubleRay, 103 const bool pruneInvalidRays = true, 104 const bool keepOrigin = false); 99 const bool pruneInvalidRays = true); 105 100 106 101 /** Checks if ray is valid. -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
r1994 r1996 20 20 HaltonSequence HwGlobalLinesDistribution::sHalton; 21 21 22 HaltonSequence ViewCellBasedDistribution::sHalton; 22 23 23 24 SamplingStrategy::SamplingStrategy(Preprocessor &preprocessor): … … 651 652 } else 652 653 if (strcmp(curr, "mutation")==0) { 653 mDistributions.push_back(new MutationBasedDistribution(mPreprocessor)); 654 // temp matt: still no mutationstrategy! 655 //mDistributions.push_back(new MutationBasedDistribution(mPreprocessor)); 654 656 } 655 657 … … 738 740 739 741 740 } 741 742 742 bool ViewCellBasedDistribution::GenerateSample(SimpleRay &ray) 743 { 744 Vector3 origin, direction; 745 746 ViewCellContainer &viewCells = 747 mPreprocessor.mViewCellsManager->GetViewCells(); 748 749 Vector3 point; 750 Vector3 normal, normal2; 751 752 float r[1]; 753 sHalton.GetNext(1, r); 754 755 const int objIdx = (int)(r[0] * (float)mPreprocessor.mObjects.size() - 1.0f); 756 // = (int)RandomValue(0, (float)mPreprocessor.mObjects.size() - 0.5f); 757 Intersectable *object = mPreprocessor.mObjects[objIdx]; 758 759 //cout << "obj: " << objIdx << endl; 760 761 object->GetRandomSurfacePoint(point, normal); 762 mViewCell->GetRandomSurfacePoint(origin, normal2); 763 764 direction = point - origin; 765 766 // move a little bit back to avoid piercing through walls 767 // that bound the view cell 768 origin -= 0.01f * normal2; 769 770 // $$ jb the pdf is yet not correct for all sampling methods! 771 const float c = Magnitude(direction); 772 773 if ((c <= Limits::Small) /*|| (DotProd(direction, normal) < 0)*/) 774 { 775 return false; 776 } 777 778 // $$ jb the pdf is yet not correct for all sampling methods! 779 const float pdf = 1.0f; 780 781 direction *= 1.0f / c; 782 ray = SimpleRay(origin, direction, VIEWCELL_BASED_DISTRIBUTION, pdf); 783 784 //cout << "ray: " << ray.mOrigin << " " << ray.mDirection << endl; 785 786 return true; 787 } 788 789 790 } 791 792
Note: See TracChangeset
for help on using the changeset viewer.