- Timestamp:
- 01/15/07 08:37:28 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r1976 r1977 87 87 newRay->mFlags |= VssRay::ReverseSample; 88 88 89 // if ray is not further processed => candelete ray89 // if ray is not further processed => delete ray 90 90 if (!HandleRay(newRay)) 91 91 { … … 111 111 const bool storeRaysForViz = GVS_DEBUG; 112 112 113 mViewCellsManager->ComputeSampleContribution(*vssRay, 114 true, 115 storeRaysForViz); 113 if (!mPerViewCell) 114 { 115 mViewCellsManager->ComputeSampleContribution(*vssRay, 116 true, 117 storeRaysForViz); 118 } 119 else 120 { 121 mViewCellsManager->ComputeSampleContribution(*vssRay, 122 true, 123 mCurrentViewCell); 124 } 116 125 117 126 // some pvs contribution for this ray? 118 if ( vssRay->mPvsContribution > 0)119 {120 // add new ray to ray queue 121 mRayQueue.push(vssRay);122 123 if (storeRaysForViz) 124 {125 VssRay *nray = new VssRay(*vssRay);126 nray->mFlags = vssRay->mFlags;127 128 // store ray in contributing view cell 129 ViewCellContainer::const_iterator vit, vit_end = vssRay->mViewCells.end();130 for (vit = vssRay->mViewCells.begin(); vit != vit_end; ++ vit)131 {132 (*vit)->GetOrCreateRays()->push_back(nray);133 }127 if (!vssRay->mPvsContribution) 128 return false; 129 130 // add new ray to ray queue 131 mRayQueue.push(vssRay); 132 133 if (storeRaysForViz) 134 { 135 VssRay *nray = new VssRay(*vssRay); 136 nray->mFlags = vssRay->mFlags; 137 138 // store ray in contributing view cell 139 ViewCellContainer::const_iterator vit, vit_end = vssRay->mViewCells.end(); 140 for (vit = vssRay->mViewCells.begin(); vit != vit_end; ++ vit) 141 { 142 (*vit)->GetOrCreateRays()->push_back(nray); 134 143 } 135 136 ++ mGvsStats.mPassContribution; 137 138 return true; 139 } 140 141 return false; 144 } 145 146 ++ mGvsStats.mPassContribution; 147 148 return true; 142 149 } 143 150 -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h
r1976 r1977 201 201 bool mPerViewCell; 202 202 bool mOnlyRandomSampling; 203 204 ViewCell *mCurrentViewCell; 203 205 }; 204 206 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj
r1968 r1977 489 489 </File> 490 490 <File 491 RelativePath=". .\src\Intersectable.h">491 RelativePath=".\Intersectable.h"> 492 492 </File> 493 493 <File -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1974 r1977 2027 2027 stat.avgPvs += pvsCost; 2028 2028 2029 const float pvsEntries = mViewCellsTree->GetPvsEntries(viewcell);2029 const float pvsEntries = (float)mViewCellsTree->GetPvsEntries(viewcell); 2030 2030 stat.avgPvsEntries += pvsEntries; 2031 2031 2032 2033 2032 if (mPerViewCellStat[i].pvsSize > 0.0f) 2034 2033 mPerViewCellStat[i].relPvsIncrease = (pvsCost - mPerViewCellStat[i].pvsSize)/mPerViewCellStat[i].pvsSize; … … 2280 2279 } 2281 2280 2281 } 2282 2283 2284 float ViewCellsManager::ComputeSampleContribution(VssRay &ray, 2285 const bool addRays, 2286 ViewCell *currentViewCell) 2287 { 2288 ray.mPvsContribution = 0; 2289 ray.mRelativePvsContribution = 0.0f; 2290 2291 if (!ray.mTerminationObject) 2292 return 0.0f; 2293 2294 static Ray hray; 2295 hray.Init(ray); 2296 2297 float tmin = 0, tmax = 1.0; 2298 2299 if (!GetViewSpaceBox().GetRaySegment(hray, tmin, tmax) || (tmin > tmax)) 2300 { 2301 // cerr<<"ray outside view space box\n"; 2302 return 0; 2303 } 2304 2305 Vector3 origin = hray.Extrap(tmin); 2306 Vector3 termination = hray.Extrap(tmax); 2307 2308 // traverse the view space subdivision 2309 if (!LineSegmentIntersects(origin, 2310 termination, 2311 currentViewCell)) 2312 { 2313 return 0; 2314 } 2315 2316 // optain pvs entry (can be different from hit object) 2317 Intersectable *terminationObj = GetIntersectable(ray, true); 2318 2319 ComputeViewCellContribution(currentViewCell, 2320 ray, 2321 terminationObj, 2322 ray.mTermination, 2323 addRays); 2324 2325 #if USE_RAY_LENGTH_AS_CONTRIBUTION 2326 float c = 0.0f; 2327 if (terminationObj) 2328 c = ray.Length(); 2329 ray.mRelativePvsContribution = ray.mPvsContribution = c; 2330 return c; 2331 #else 2332 return ABS_CONTRIBUTION_WEIGHT*ray.mPvsContribution + 2333 (1.0f - ABS_CONTRIBUTION_WEIGHT)*ray.mRelativePvsContribution; 2334 #endif 2282 2335 } 2283 2336 … … 3330 3383 3331 3384 3385 bool BspViewCellsManager::LineSegmentIntersects(const Vector3 &origin, 3386 const Vector3 &termination, 3387 ViewCell *viewCell) 3388 { 3389 return false; 3390 } 3391 3392 3332 3393 void ViewCellsManager::ExportMergedViewCells(const ObjectContainer &objects) 3333 3394 { … … 4316 4377 4317 4378 4379 bool KdViewCellsManager::LineSegmentIntersects(const Vector3 &origin, 4380 const Vector3 &termination, 4381 ViewCell *viewCell) 4382 { 4383 return false; 4384 } 4385 4386 4318 4387 void KdViewCellsManager::CreateMesh(ViewCell *vc) 4319 4388 { … … 5089 5158 { 5090 5159 return mVspBspTree->CastLineSegment(origin, termination, viewcells); 5160 } 5161 5162 5163 bool VspBspViewCellsManager::LineSegmentIntersects(const Vector3 &origin, 5164 const Vector3 &termination, 5165 ViewCell *viewCell) 5166 { 5167 return false; 5091 5168 } 5092 5169 … … 6105 6182 ViewCellContainer &viewcells) 6106 6183 { 6107 return mHierarchyManager->GetVspTree()->CastLineSegment(origin, termination, viewcells); 6184 return mHierarchyManager-> 6185 GetVspTree()->CastLineSegment(origin, termination, viewcells); 6186 } 6187 6188 6189 bool VspOspViewCellsManager::LineSegmentIntersects(const Vector3 &origin, 6190 const Vector3 &termination, 6191 ViewCell *viewCell) 6192 { 6193 return mHierarchyManager-> 6194 GetVspTree()->LineSegmentIntersects(origin, termination, viewCell); 6108 6195 } 6109 6196 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r1974 r1977 156 156 const bool storeViewCells); 157 157 158 //virtual void AddSampleContributions(VssRay &ray); 158 /** Compute sample contribution only for current view cell. 159 */ 160 virtual float ComputeSampleContribution(VssRay &ray, 161 const bool addRays, 162 ViewCell *currentViewCell); 159 163 160 164 /** Prints out statistics of the view cells. … … 251 255 by this line segment 252 256 */ 253 254 virtual int CastLineSegment(const Vector3 &origin, 257 virtual int CastLineSegment(const Vector3 &origin, 255 258 const Vector3 &termination, 256 259 ViewCellContainer &viewcells 257 260 ) = 0; 261 262 /** Tests if this line segment intersects a particular view cell. 263 */ 264 virtual bool LineSegmentIntersects(const Vector3 &origin, 265 const Vector3 &termination, 266 ViewCell *viewCell) = 0; 258 267 259 268 /** Returns a stats about the global pvs. … … 883 892 VssRayContainer *visRays = NULL); 884 893 894 bool LineSegmentIntersects(const Vector3 &origin, 895 const Vector3 &termination, 896 ViewCell *viewCell); 897 885 898 protected: 886 899 … … 964 977 VssRayContainer *visRays = NULL); 965 978 979 bool LineSegmentIntersects(const Vector3 &origin, 980 const Vector3 &termination, 981 ViewCell *viewCell); 982 966 983 protected: 967 984 … … 1051 1068 1052 1069 1070 bool LineSegmentIntersects(const Vector3 &origin, 1071 const Vector3 &termination, 1072 ViewCell *viewCell); 1073 1053 1074 protected: 1054 1075 … … 1117 1138 { 1118 1139 friend class ViewCellsParseHandlers; 1140 1119 1141 public: 1120 1142 … … 1136 1158 ViewCell *GenerateViewCell(Mesh *mesh = NULL) const; 1137 1159 1138 virtual Intersectable * 1139 GetIntersectable(const VssRay &ray, const bool isTermination) const;1160 virtual Intersectable *GetIntersectable( 1161 const VssRay &ray, const bool isTermination) const; 1140 1162 1141 1163 bool ViewCellsConstructed() const; … … 1146 1168 ViewCellContainer &viewcells); 1147 1169 1170 bool LineSegmentIntersects(const Vector3 &origin, 1171 const Vector3 &termination, 1172 ViewCell *viewCell); 1173 1148 1174 float GetProbability(ViewCell *viewCell); 1149 1175 … … 1164 1190 void Finalize(ViewCell *viewCell, const bool createMesh); 1165 1191 1166 /** Stores sample contribution for kd cells or objects. 1167 */ 1168 // virtual float ComputeSampleContribution(VssRay &ray, 1169 // const bool addRays, 1170 // const bool storeViewCells); 1171 1172 ViewCellsManager *LoadViewCells(const string &filename, 1192 ViewCellsManager *LoadViewCells(const string &filename, 1173 1193 ObjectContainer *objects, 1174 1194 const bool finalizeViewCells, -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1919 r1977 3502 3502 } 3503 3503 3504 } 3504 3505 bool VspTree::LineSegmentIntersects(const Vector3 &origin, 3506 const Vector3 &termination, 3507 ViewCell *viewCell) 3508 { 3509 /*float mint = 0.0f, maxt = 1.0f; 3510 const Vector3 dir = termination - origin; 3511 3512 stack<LineTraversalData> tStack; 3513 3514 Vector3 entp = origin; 3515 Vector3 extp = termination; 3516 3517 VspNode *node = mRoot; 3518 VspNode *farChild; 3519 3520 float position; 3521 int axis; 3522 3523 while (1) 3524 { 3525 if (!node->IsLeaf()) 3526 { 3527 VspInterior *in = dynamic_cast<VspInterior *>(node); 3528 position = in->GetPosition(); 3529 axis = in->GetAxis(); 3530 3531 if (entp[axis] <= position) 3532 { 3533 if (extp[axis] <= position) 3534 { 3535 node = in->GetBack(); 3536 // cases N1,N2,N3,P5,Z2,Z3 3537 continue; 3538 } else 3539 { 3540 // case N4 3541 node = in->GetBack(); 3542 farChild = in->GetFront(); 3543 } 3544 } 3545 else 3546 { 3547 if (position <= extp[axis]) 3548 { 3549 node = in->GetFront(); 3550 // cases P1,P2,P3,N5,Z1 3551 continue; 3552 } 3553 else 3554 { 3555 node = in->GetFront(); 3556 farChild = in->GetBack(); 3557 // case P4 3558 } 3559 } 3560 3561 // $$ modification 3.5.2004 - hints from Kamil Ghais 3562 // case N4 or P4 3563 const float tdist = (position - origin[axis]) / dir[axis]; 3564 tStack.push(LineTraversalData(farChild, extp, maxt)); //TODO 3565 3566 extp = origin + dir * tdist; 3567 maxt = tdist; 3568 } 3569 else 3570 { 3571 // compute intersection with all objects in this leaf 3572 VspLeaf *leaf = dynamic_cast<VspLeaf *>(node); 3573 ViewCell *viewCell; 3574 if (0) 3575 viewCell = mViewCellsTree->GetActiveViewCell(leaf->GetViewCell()); 3576 else 3577 viewCell = leaf->GetViewCell(); 3578 3579 if (viewCell == currentViewCell) 3580 return true; 3581 3582 // get the next node from the stack 3583 if (tStack.empty()) 3584 break; 3585 3586 entp = extp; 3587 mint = maxt; 3588 3589 LineTraversalData &s = tStack.top(); 3590 node = s.mNode; 3591 extp = s.mExitPoint; 3592 maxt = s.mMaxT; 3593 3594 tStack.pop(); 3595 } 3596 } 3597 */ 3598 return false; 3599 } 3600 3601 3602 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r1913 r1977 701 701 VspNode *SubdivideAndCopy(SplitQueue &tQueue, SubdivisionCandidate *splitCandidate); 702 702 703 bool LineSegmentIntersects(const Vector3 &origin, 704 const Vector3 &termination, 705 ViewCell *viewCell); 703 706 protected: 704 707
Note: See TracChangeset
for help on using the changeset viewer.