- Timestamp:
- 01/22/07 20:25:06 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 10 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp
r2012 r2015 14 14 #include "RayCaster.h" 15 15 16 #include "PerfTimer.h" 17 16 18 17 19 namespace GtpVisibilityPreprocessor { 20 21 extern PerfTimer viewCellCastTimer; 22 extern PerfTimer pvsTimer; 23 extern PerfTimer objTimer; 18 24 19 25 const bool pruneInvalidRays = true; … … 88 94 mMixtureDistribution->ComputeContributions(vssRays); 89 95 96 cout<<"view cell cast time:"<<viewCellCastTimer.TotalTime()<<" s"<<endl; 97 cout<<"pvs time:"<<pvsTimer.TotalTime()<<" s"<<endl; 98 cout<<"obj time:"<<objTimer.TotalTime()<<" s"<<endl; 99 90 100 if (mExportRays) { 91 101 Debug<<"Exporting rays..."<<endl<<flush; -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r2014 r2015 744 744 { 745 745 int hits = 0; 746 747 746 float mint = 0.0f, maxt = 1.0f; 748 747 const Vector3 dir = termination - origin; … … 765 764 while (1) 766 765 { 767 if (!node->IsLeaf()) 766 if (!node->IsLeaf()) { 767 KdInterior *in = (KdInterior *)node; 768 position = in->mPosition; 769 axis = in->mAxis; 770 771 if (entp[axis] <= position) 772 { 773 if (extp[axis] <= position) 774 { 775 node = in->mBack; 776 // cases N1,N2,N3,P5,Z2,Z3 777 continue; 778 } 779 else 780 { 781 // case N4 782 node = in->mBack; 783 farChild = in->mFront; 784 } 785 } 786 else 787 { 788 if (position <= extp[axis]) 789 { 790 node = in->mFront; 791 // cases P1,P2,P3,N5,Z1 792 continue; 793 } 794 else 795 { 796 node = in->mFront; 797 farChild = in->mBack; 798 // case P4 799 } 800 } 801 802 // $$ modification 3.5.2004 - hints from Kamil Ghais 803 // case N4 or P4 804 float tdist = (position - origin[axis]) / dir[axis]; 805 //tStack.push(RayTraversalData(farChild, extp, maxt)); //TODO 806 extp = origin + dir * tdist; 807 maxt = tdist; 808 } 809 else 768 810 { 769 KdInterior *in = (KdInterior *)node; 770 position = in->mPosition; 771 axis = in->mAxis; 772 773 if (entp[axis] <= position) 774 { 775 if (extp[axis] <= position) 776 { 777 node = in->mBack; 778 // cases N1,N2,N3,P5,Z2,Z3 779 continue; 780 } 781 else 782 { 783 // case N4 784 node = in->mBack; 785 farChild = in->mFront; 786 } 787 } 788 else 789 { 790 if (position <= extp[axis]) 791 { 792 node = in->mFront; 793 // cases P1,P2,P3,N5,Z1 794 continue; 795 } 796 else 797 { 798 node = in->mFront; 799 farChild = in->mBack; 800 // case P4 801 } 802 } 803 804 // $$ modification 3.5.2004 - hints from Kamil Ghais 805 // case N4 or P4 806 float tdist = (position - origin[axis]) / dir[axis]; 807 //tStack.push(RayTraversalData(farChild, extp, maxt)); //TODO 808 extp = origin + dir * tdist; 809 maxt = tdist; 810 } 811 else 812 { 813 // compute intersection with all objects in this leaf 811 // compute intersection with all objects in this leaf 814 812 KdLeaf *leaf = (KdLeaf *)node; 815 816 // add view cell to intersections 817 ViewCell *vc = leaf->mViewCell; 818 819 if (!vc->Mailed()) 820 { 821 vc->Mail(); 822 viewcells.push_back(vc); 823 ++ hits; 824 } 825 826 // get the next node from the stack 827 if (tStack.empty()) 828 break; 829 830 entp = extp; 831 mint = maxt; 832 833 RayTraversalData &s = tStack.top(); 834 node = s.mNode; 835 extp = s.mExitPoint; 836 maxt = s.mMaxT; 837 tStack.pop(); 813 814 // add view cell to intersections 815 ViewCell *vc = leaf->mViewCell; 816 817 if (!vc->Mailed()) { 818 vc->Mail(); 819 viewcells.push_back(vc); 820 ++ hits; 821 } 822 823 // get the next node from the stack 824 if (tStack.empty()) 825 break; 826 827 entp = extp; 828 mint = maxt; 829 830 RayTraversalData &s = tStack.top(); 831 node = s.mNode; 832 extp = s.mExitPoint; 833 maxt = s.mMaxT; 834 tStack.pop(); 838 835 } 839 836 } 840 837 841 838 return hits; 842 839 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Makefile
r2014 r2015 1 1 ############################################################################# 2 2 # Makefile for building: preprocessor 3 # Generated by qmake (2.00a) (Qt 4.1.2) on: po 22. I 1 6:16:0320073 # Generated by qmake (2.00a) (Qt 4.1.2) on: po 22. I 17:10:45 2007 4 4 # Project: preprocessor.pro 5 5 # Template: app … … 63 63 $(MAKE) -f $(MAKEFILE).Debug uninstall 64 64 65 Makefile: preprocessor.pro C:/Qt/4.1.2/mkspecs/win32-msvc 2005\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \65 Makefile: preprocessor.pro C:/Qt/4.1.2/mkspecs/win32-msvc.net\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \ 66 66 C:\Qt\4.1.2\mkspecs\features\qt_config.prf \ 67 67 C:\Qt\4.1.2\mkspecs\features\exclusive_builds.prf \ -
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
r1998 r2015 310 310 bool RequiresResort() const 311 311 { 312 // the last part should not be more than log of the sorted part. this 313 // way we can achieve logarithmic behaviour for insertion and find 314 const int dirtySize = (int)mEntries.size() - mLastSorted; 315 return dirtySize > 4*(int)(log((double)mEntries.size()) / log(2.0)); 316 } 317 318 312 // the last part should not be more than log of the sorted part. this 313 // way we can achieve logarithmic behaviour for insertion and find 314 const int dirtySize = (int)mEntries.size() - mLastSorted; 315 return dirtySize > 500; 316 // 4*(int)(log((double)mEntries.size()) / log(2.0)); 317 } 318 319 bool RequiresResortLog() const 320 { 321 // the last part should not be more than log of the sorted part. this 322 // way we can achieve logarithmic behaviour for insertion and find 323 const int dirtySize = (int)mEntries.size() - mLastSorted; 324 return dirtySize > 4*(int)(log((double)mEntries.size()) / log(2.0)); 325 } 326 327 319 328 int GetLastSorted() const 320 329 { … … 600 609 const bool checkDirty) 601 610 { 602 bool found = false;603 604 611 PvsEntry<T, S> dummy(sample, PvsData()); 605 612 … … 611 618 612 619 if ((it != mEntries.end()) && ((*it).mObject == sample)) 613 found = true; 620 // if (it != sorted_end) 621 return true; 614 622 615 623 // sample not found yet => search further in the unsorted part 616 if ( !found &&checkDirty) {624 if (checkDirty) { 617 625 618 626 for (it = sorted_end; (it != mEntries.end()) && ((*it).mObject != sample); ++ it) ; 619 627 620 628 if (it != mEntries.end()) 621 found =true;629 return true; 622 630 } 623 631 624 return f ound;632 return false; 625 633 } 626 634 -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
r2010 r2015 7 7 #include "RssTree.h" 8 8 #include "Mutation.h" 9 #include "PerfTimer.h" 9 10 10 11 namespace GtpVisibilityPreprocessor { 12 13 extern PerfTimer pvsTimer; 11 14 12 15 //HaltonSequence SamplingStrategy::sHalton; … … 545 548 } 546 549 550 pvsTimer.Entry(); 551 // resort pvss 552 mPreprocessor.mViewCellsManager->SortViewCellPvs(); 553 pvsTimer.Exit(); 547 554 548 555 UpdateRatios(); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r2003 r2015 149 149 const ObjectPvs &ViewCell::GetPvs() const 150 150 { 151 151 return mPvs; 152 152 } 153 153 … … 155 155 ObjectPvs &ViewCell::GetPvs() 156 156 { 157 157 return mPvs; 158 158 } 159 159 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2014 r2015 28 28 29 29 30 30 31 #define USE_RAY_LENGTH_AS_CONTRIBUTION 0 31 32 #define DIST_WEIGHTED_CONTRIBUTION 0 … … 37 38 namespace GtpVisibilityPreprocessor { 38 39 40 41 PerfTimer viewCellCastTimer; 42 PerfTimer pvsTimer; 43 PerfTimer objTimer; 39 44 40 45 // HACK … … 1694 1699 1695 1700 VssRayContainer::const_iterator it, it_end = rays.end(); 1696 1701 1697 1702 for (it = rays.begin(); it != it_end; ++ it) 1698 1703 { … … 1707 1712 } 1708 1713 1714 cout<<"view cell cast time:"<<viewCellCastTimer.TotalTime()<<" s"<<endl; 1715 cout<<"pvs time:"<<pvsTimer.TotalTime()<<" s"<<endl; 1716 1709 1717 return sum; 1710 1718 } … … 2235 2243 2236 2244 2245 void 2246 ViewCellsManager::SortViewCellPvs() 2247 { 2248 2249 ViewCellContainer::iterator it, it_end = mViewCells.end(); 2250 for (it = mViewCells.begin(); it != it_end; ++ it) { 2251 ObjectPvs &pvs = (*it)->GetPvs(); 2252 if (pvs.RequiresResortLog()) 2253 pvs.Sort(); 2254 } 2255 } 2256 2237 2257 void ViewCellsManager::ComputeViewCellContribution(ViewCell *viewCell, 2238 2258 VssRay &ray, … … 2242 2262 { 2243 2263 // check if we are outside of view space 2244 if (!obj || !viewCell->GetValid()) 2245 return; 2246 2247 // if ray not outside of view space 2248 float relContribution = 0.0f; 2249 float absContribution = 0.0f; 2250 2251 if (obj) 2252 { 2253 // todo: maybe not correct for kd node pvs 2254 if (addRays) 2255 { 2256 float pdf = viewCell->GetPvs().AddSampleDirtyCheck(obj, ray.mPdf); 2257 2258 if (pdf == ray.mPdf) 2259 { 2260 absContribution = 1.0f; 2261 if (viewCell->GetPvs().RequiresResort()) 2262 viewCell->GetPvs().SimpleSort(); 2263 } 2264 } 2265 else 2266 { 2267 if (viewCell->GetPvs().GetSampleContribution( 2268 obj, 2269 ray.mPdf, 2270 relContribution)) 2271 { 2272 absContribution = 1.0f; 2273 } 2274 } 2275 2276 // $$ clear the relative contribution as it is currently not correct anyway 2277 relContribution = 0.0f; 2278 2279 if (absContribution == 1.0f) 2280 { 2281 ++ ray.mPvsContribution; 2282 relContribution = 1.0f; 2283 2284 2264 // $$JB tmp commented to speedup up computations 2265 #if 0 2266 if (!obj || !viewCell->GetValid()) 2267 return; 2268 #endif 2269 2270 2271 // if ray not outside of view space 2272 float relContribution = 0.0f; 2273 float absContribution = 0.0f; 2274 bool hasAbsContribution; 2275 2276 // todo: maybe not correct for kd node pvs 2277 if (addRays) { 2278 hasAbsContribution = viewCell->GetPvs().AddSampleDirtyCheck(obj, 2279 ray.mPdf); 2280 } 2281 else { 2282 hasAbsContribution = viewCell->GetPvs().GetSampleContribution( 2283 obj, 2284 ray.mPdf, 2285 relContribution); 2286 } 2287 2288 // $$ clear the relative contribution as it is currently not correct anyway 2289 // relContribution = 0.0f; 2290 2291 if (hasAbsContribution) { 2292 ++ ray.mPvsContribution; 2293 absContribution = relContribution = 1.0f; 2294 if (viewCell->GetPvs().RequiresResort()) 2295 viewCell->GetPvs().SimpleSort(); 2296 2285 2297 #if CONTRIBUTION_RELATIVE_TO_PVS_SIZE 2286 2298 relContribution /= viewcell->GetPvs().GetSize(); 2287 2299 #endif 2288 2300 2289 2301 #if DIST_WEIGHTED_CONTRIBUTION 2290 2291 2292 2293 2294 2302 // recalculate the contribution - weight the 1.0f contribution by the sqr distance to the 2303 // object-> a new contribution in the proximity of the viewcell has a larger weight! 2304 relContribution /= SqrDistance(GetViewCellBox(viewcell).Center(), 2305 ray.mTermination); 2306 2295 2307 #endif 2296 2297 2308 } 2309 2298 2310 #if SUM_RAY_CONTRIBUTIONS || AVG_RAY_CONTRIBUTIONS 2299 2311 ray.mRelativePvsContribution += relContribution; 2300 2312 #else 2301 2302 2303 2313 // recalculate relative contribution - use max of Rel Contribution 2314 if (ray.mRelativePvsContribution < relContribution) 2315 ray.mRelativePvsContribution = relContribution; 2304 2316 #endif 2305 2306 2307 } 2317 } 2318 2319 2308 2320 2309 2321 … … 2365 2377 2366 2378 if (!ray.mTerminationObject) 2367 return 0.0f; 2368 2369 static ViewCellContainer viewCells; 2370 2371 2379 return 0.0f; 2380 2372 2381 static Ray hray; 2373 2382 hray.Init(ray); … … 2382 2391 Vector3 origin = hray.Extrap(tmin); 2383 2392 Vector3 termination = hray.Extrap(tmax); 2384 2393 2385 2394 ViewCell::NewMail(); 2386 2387 viewCells.clear(); 2388 2389 // traverse the view space subdivision 2390 CastLineSegment(origin, termination, viewCells); 2395 2396 viewCellCastTimer.Entry(); 2397 2398 static ViewCellContainer viewCells; 2399 static VssRay *lastVssRay = NULL; 2400 2401 if (lastVssRay == NULL || 2402 !(ray.mOrigin == lastVssRay->mTermination) || 2403 !(ray.mTermination == lastVssRay->mOrigin)) { 2404 viewCells.clear(); 2405 // traverse the view space subdivision 2406 CastLineSegment(origin, termination, viewCells); 2407 lastVssRay = &ray; 2408 } 2409 2410 viewCellCastTimer.Exit(); 2391 2411 2392 2412 mSamplesStat.mViewCells += (int)viewCells.size(); … … 2394 2414 if (storeViewCells) 2395 2415 { 2416 cerr<<"Store viewcells should not be used in the test!"<<endl; 2396 2417 // copy viewcells memory efficiently 2397 2418 #if VSS_STORE_VIEWCELLS … … 2403 2424 #endif 2404 2425 } 2405 2426 2406 2427 Intersectable *terminationObj; 2428 2429 objTimer.Entry(); 2407 2430 2408 2431 // obtain pvs entry (can be different from hit object) 2409 2432 if (!useHitObjects) 2410 2433 terminationObj = GetIntersectable(ray, true); 2411 2434 else 2412 terminationObj = ray.mTerminationObject; 2435 terminationObj = ray.mTerminationObject; 2436 2437 objTimer.Exit(); 2438 2439 pvsTimer.Entry(); 2413 2440 2414 2441 ViewCellContainer::const_iterator it = viewCells.begin(); … … 2422 2449 addRays); 2423 2450 } 2451 2452 pvsTimer.Exit(); 2424 2453 2425 2454 mSamplesStat.mPvsContributions += ray.mPvsContribution; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r1990 r2015 44 44 45 45 46 47 46 48 struct PvsFilterStatistics { 47 49 PvsFilterStatistics(): … … 373 375 int maxPvsSize) const; 374 376 375 377 378 // resort pvss after a pass of the algorithm 379 void 380 SortViewCellPvs(); 381 376 382 /** Sets validity of view cell 377 383 */ -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r1789 r2015 3447 3447 float t; 3448 3448 const float thresh = 1e-6f; // matt: change this to adjustable value 3449 3449 3450 3450 while (1) 3451 3451 { -
GTP/trunk/Lib/Vis/Preprocessing/src/VspKdTree.cpp
r1012 r2015 299 299 } 300 300 301 VspKdViewCell *VspKdLeaf::GetViewCell()302 {303 return mViewCell;304 }305 301 306 302 void VspKdLeaf::SetViewCell(VspKdViewCell *viewCell) … … 2098 2094 int axis; 2099 2095 2096 cerr<<"HERE"<<endl; 2100 2097 while (1) 2101 2098 { 2102 2099 if (!node->IsLeaf()) 2103 2100 { 2104 VspKdInterior *in = dynamic_cast<VspKdInterior *>(node);2101 VspKdInterior *in = (VspKdInterior *)node; 2105 2102 position = in->mPosition; 2106 2103 axis = in->mAxis; … … 2146 2143 { 2147 2144 // compute intersection with all objects in this leaf 2148 VspKdLeaf *leaf = dynamic_cast<VspKdLeaf *>(node);2145 VspKdLeaf *leaf = (VspKdLeaf *)node; 2149 2146 ViewCell *vc = leaf->GetViewCell(); 2150 2147 … … 2156 2153 } 2157 2154 2155 #if 0 2158 2156 if (0) //matt TODO: REMOVE LATER 2159 leaf->mRays.push_back(RayInfo(new VssRay(origin, termination, NULL, NULL, 0))); 2160 2157 leaf->mRays.push_back(RayInfo(new VssRay(origin, termination, NULL, NULL, 0))); 2158 #endif 2159 2161 2160 // get the next node from the stack 2162 2161 if (tStack.empty()) -
GTP/trunk/Lib/Vis/Preprocessing/src/VspKdTree.h
r1112 r2015 433 433 /** Returns view cell associated with this leaf. 434 434 */ 435 VspKdViewCell *GetViewCell(); 435 VspKdViewCell *GetViewCell() { 436 return mViewCell; 437 } 436 438 437 439 /** Returns number of times the max cost ratio was missed until -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r2003 r2015 268 268 269 269 270 bool VspInterior::IsLeaf() const 271 { 272 return false; 273 } 274 275 276 VspNode *VspInterior::GetBack() 277 { 278 return mBack; 279 } 280 281 282 VspNode *VspInterior::GetFront() 283 { 284 return mFront; 285 } 286 287 288 AxisAlignedPlane VspInterior::GetPlane() const 289 { 290 return mPlane; 291 } 292 293 294 float VspInterior::GetPosition() const 295 { 296 return mPlane.mPosition; 297 } 298 299 300 int VspInterior::GetAxis() const 301 { 302 return mPlane.mAxis; 303 } 270 271 304 272 305 273 … … 388 356 389 357 390 ViewCellLeaf *VspLeaf::GetViewCell() const391 {392 return mViewCell;393 }394 358 395 359 … … 400 364 401 365 402 bool VspLeaf::IsLeaf() const403 {404 return true;405 }406 366 407 367 … … 2376 2336 int axis; 2377 2337 2338 ViewCell::NewMail(); 2339 2378 2340 while (1) 2379 2341 { 2380 2342 if (!node->IsLeaf()) 2381 2343 { 2382 VspInterior *in = dynamic_cast<VspInterior *>(node);2344 VspInterior *in = (VspInterior *)node; 2383 2345 position = in->GetPosition(); 2384 2346 axis = in->GetAxis(); … … 2425 2387 { 2426 2388 // compute intersection with all objects in this leaf 2427 VspLeaf *leaf = dynamic_cast<VspLeaf *>(node);2389 VspLeaf *leaf = (VspLeaf *)node; 2428 2390 ViewCell *viewCell; 2429 if (0) 2430 viewCell = mViewCellsTree->GetActiveViewCell(leaf->GetViewCell()); 2431 else 2432 viewCell = leaf->GetViewCell(); 2433 2391 // if (0) 2392 // viewCell = mViewCellsTree->GetActiveViewCell(leaf->GetViewCell()); 2393 // else 2394 2395 viewCell = leaf->GetViewCell(); 2396 2434 2397 // don't have to mail if each view cell belongs to exactly one leaf 2435 if (!useMailboxing || !viewCell->Mailed()) 2436 { 2437 if (useMailboxing) 2438 viewCell->Mail(); 2439 2440 viewcells.push_back(viewCell); 2441 ++ hits; 2442 } 2443 2398 // $$ JB -> always mailbox so that we have less conditions 2399 if (!viewCell->Mailed()) { 2400 viewCell->Mail(); 2401 2402 viewcells.push_back(viewCell); 2403 ++ hits; 2404 } 2405 2444 2406 // get the next node from the stack 2445 2407 if (tStack.empty()) 2446 2447 2408 break; 2409 2448 2410 entp = extp; 2449 2411 mint = maxt; -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r2003 r2015 235 235 /** @return false since it is an interior node 236 236 */ 237 bool IsLeaf() const; 237 bool IsLeaf() const { 238 return false; 239 } 240 238 241 239 242 int Type() const; 240 243 241 VspNode *GetBack(); 242 VspNode *GetFront(); 244 VspNode *GetBack() { 245 return mBack; 246 } 247 248 249 VspNode *GetFront() { 250 return mFront; 251 } 243 252 244 253 /** Returns split plane. 245 254 */ 246 AxisAlignedPlane GetPlane() const; 255 AxisAlignedPlane GetPlane() const { 256 return mPlane; 257 } 258 247 259 248 260 /** Returns position of split plane. 249 261 */ 250 float GetPosition() const; 262 float GetPosition() const { 263 return mPlane.mPosition; 264 } 251 265 252 266 /** Returns split axis. 253 267 */ 254 int GetAxis() const; 268 int GetAxis() const { 269 return mPlane.mAxis; 270 } 255 271 256 272 /** Replace front or back child with new child. … … 308 324 /** @return true since it is an interior node 309 325 */ 310 bool IsLeaf() const; 326 bool IsLeaf() const { 327 return true; 328 } 311 329 312 330 int Type() const; … … 314 332 /** Returns pointer of view cell. 315 333 */ 316 ViewCellLeaf *GetViewCell() const; 334 ViewCellLeaf *GetViewCell() const { 335 return mViewCell; 336 } 337 317 338 /** Sets pointer to view cell. 318 339 */ -
GTP/trunk/Lib/Vis/Preprocessing/src/preprocessor.pro
r2014 r2015 112 112 Mailable.cpp \ 113 113 CombinedPreprocessor.cpp Vector2.cpp GlobalLinesRenderer.cpp \ 114 RenderTexture.cpp Mutation.cpp 114 RenderTexture.cpp Mutation.cpp Timer/RDTSCTimer.cpp Timer/BenchTimer.cpp Timer/merror.cpp 115 115 116 116 SOURCES += BoostPreprocessorThread.cpp -
GTP/trunk/Lib/Vis/Preprocessing/src/run_test2
r2014 r2015 52 52 -view_cells_use_kd_pvs- -af_use_kd_pvs- \ 53 53 -preprocessor_visibility_file=$PREFIX-i-mixed-bvh-n4i.xml \ 54 -preprocessor_stats=$PREFIX-i-mixed-b 1-n4i.log \54 -preprocessor_stats=$PREFIX-i-mixed-bvh-n4i.log \ 55 55 -preprocessor_histogram_file=$PREFIX-i-mixed-bvh-n4i.hlog 56 56 57 57 58 #$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
Note: See TracChangeset
for help on using the changeset viewer.