Changeset 1686 for GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
- Timestamp:
- 10/27/06 03:05:49 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1684 r1686 721 721 tBackData.mMaxCostMisses = maxCostMisses; 722 722 723 newNode->mRenderCostDecr = sc->GetRenderCostDecrease(); 724 newNode->mPvsEntriesIncr = sc->GetPvsEntriesIncr(); 725 723 //newNode->mRenderCostDecr = sc->GetRenderCostDecrease(); 724 //newNode->mPvsEntriesIncr = sc->GetPvsEntriesIncr(); 725 726 // set the time stamp so the order of traversal can be reconstructed 727 newNode->mTimeStamp = mHierarchyManager->mTimeStamp ++; 728 726 729 mTotalCost -= sc->GetRenderCostDecrease(); 727 730 mTotalPvsSize += tFrontData.mPvs + tBackData.mPvs - tData.mPvs; … … 978 981 #endif 979 982 980 // set the time stamp so the order of traversal can be reconstructed981 interior->mTimeStamp = mHierarchyManager->mTimeStamp ++;982 983 983 return interior; 984 }985 986 void VspTree::UpdateNode(const AxisAlignedPlane &splitPlane,987 VspTraversalData &tData,988 VspTraversalData &frontData,989 VspTraversalData &backData)990 {991 VspLeaf *leaf = dynamic_cast<VspLeaf *>(tData.mNode);992 /*993 // replace a link from node's parent994 if (parent)995 {996 parent->ReplaceChildLink(leaf, interior);997 interior->SetParent(parent);998 }999 else // new root1000 {1001 mRoot = interior;1002 }1003 1004 VspLeaf *frontLeaf = new VspLeaf(interior);1005 VspLeaf *backLeaf = new VspLeaf(interior);1006 1007 // and setup child links1008 interior->SetupChildLinks(frontLeaf, backLeaf);1009 1010 // add bounding box1011 interior->SetBoundingBox(tData.mBoundingBox);1012 1013 // set front and back leaf1014 frontData.mNode = frontLeaf;1015 backData.mNode = backLeaf;1016 1017 // explicitely create front and back view cell1018 CreateViewCell(frontData, false);1019 CreateViewCell(backData, false);1020 */1021 984 } 1022 985 … … 3321 3284 3322 3285 3323 SubdivisionCandidate *VspTree::CreateSubdivisionCandidate(VspInterior *oldNode) 3324 { 3325 return new VspSubdivisionCandidate(oldNode->GetPlane(), VspTraversalData()); 3326 } 3327 3328 } 3286 VspNode *VspTree::SubdivideAndCopy(SplitQueue &tQueue, 3287 SubdivisionCandidate *splitCandidate) 3288 { 3289 // todo remove dynamic cast 3290 VspSubdivisionCandidate *sc = dynamic_cast<VspSubdivisionCandidate *>(splitCandidate); 3291 3292 VspTraversalData &tData = sc->mParentData; 3293 VspNode *newNode = tData.mNode; 3294 VspNode *oldNode = (VspNode *)splitCandidate->mEvaluationHack; 3295 3296 if (!oldNode->IsLeaf()) 3297 { 3298 /////////// 3299 //-- continue subdivision 3300 3301 VspTraversalData tFrontData; 3302 VspTraversalData tBackData; 3303 3304 VspInterior *oldInterior = dynamic_cast<VspInterior *>(oldNode); 3305 3306 // create new interior node and two leaf node 3307 const AxisAlignedPlane splitPlane = oldInterior->GetPlane(); 3308 const int maxCostMisses = sc->GetMaxCostMisses(); 3309 3310 newNode = SubdivideNode(splitPlane, tData, tFrontData, tBackData); 3311 3312 // how often was max cost ratio missed in this branch? 3313 tFrontData.mMaxCostMisses = maxCostMisses; 3314 tBackData.mMaxCostMisses = maxCostMisses; 3315 3316 newNode->mRenderCostDecr = oldNode->mRenderCostDecr + sc->GetRenderCostDecrease(); 3317 newNode->mPvsEntriesIncr = oldNode->mPvsEntriesIncr + sc->GetPvsEntriesIncr(); 3318 3319 ///////////// 3320 //-- evaluate new split candidates for global greedy cost heuristics 3321 3322 VspSubdivisionCandidate *frontCandidate = new VspSubdivisionCandidate(tFrontData); 3323 VspSubdivisionCandidate *backCandidate = new VspSubdivisionCandidate(tBackData); 3324 3325 frontCandidate->SetPriority((float)-oldInterior->GetFront()->mTimeStamp); 3326 backCandidate->SetPriority((float)-oldInterior->GetFront()->mTimeStamp); 3327 3328 frontCandidate->mEvaluationHack = oldInterior->GetFront(); 3329 backCandidate->mEvaluationHack = oldInterior->GetBack(); 3330 3331 // cross reference 3332 tFrontData.mNode->SetSubdivisionCandidate(frontCandidate); 3333 tBackData.mNode->SetSubdivisionCandidate(backCandidate); 3334 3335 tQueue.Push(frontCandidate); 3336 tQueue.Push(backCandidate); 3337 3338 // note: leaf is not destroyed because it is needed to collect 3339 // dirty candidates in hierarchy manager 3340 } 3341 3342 if (newNode->IsLeaf()) // subdivision terminated 3343 { 3344 // view cell is created during subdivision 3345 VspLeaf *leaf = dynamic_cast<VspLeaf *>(newNode); 3346 ViewCell *viewCell = leaf->GetViewCell(); 3347 3348 int conSamp = 0; 3349 float sampCon = 0.0f; 3350 3351 #if 0 3352 ///////////// 3353 //-- store pvs optained from rays 3354 3355 AddSamplesToPvs(leaf, *tData.mRays, sampCon, conSamp); 3356 3357 // update scalar pvs size value 3358 ObjectPvs &pvs = viewCell->GetPvs(); 3359 mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.CountObjectsInPvs(), pvs.GetSize()); 3360 3361 mVspStats.contributingSamples += conSamp; 3362 mVspStats.sampleContributions += (int)sampCon; 3363 #endif 3364 if (mStoreRays) 3365 { 3366 ////////// 3367 //-- store rays piercing this view cell 3368 RayInfoContainer::const_iterator it, it_end = tData.mRays->end(); 3369 for (it = tData.mRays->begin(); it != it_end; ++ it) 3370 { 3371 (*it).mRay->Ref(); 3372 leaf->mVssRays.push_back((*it).mRay); 3373 //leaf->mVssRays.push_back(new VssRay(*(*it).mRay)); 3374 } 3375 } 3376 3377 // finally evaluate statistics for this leaf 3378 EvaluateLeafStats(tData); 3379 // detach subdivision candidate: this leaf is no candidate for 3380 // splitting anymore 3381 tData.mNode->SetSubdivisionCandidate(NULL); 3382 // detach node so it won't get deleted 3383 tData.mNode = NULL; 3384 } 3385 3386 return newNode; 3387 } 3388 3389 }
Note: See TracChangeset
for help on using the changeset viewer.