Changeset 1684 for GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
- Timestamp:
- 10/26/06 19:35:43 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1680 r1684 338 338 //AssociateObjectsWithLeaf(node->GetFront()); 339 339 340 node->mRenderCostDecr += sc.GetRenderCostDecrease(); 341 node->mPvsEntriesIncr += sc.GetPvsEntriesIncr(); 342 340 node->mRenderCostDecr = sc.GetRenderCostDecrease(); 341 node->mPvsEntriesIncr = sc.GetPvsEntriesIncr(); 343 342 } 344 343 … … 370 369 AxisAlignedBox3 bbox = EvalBoundingBox(sc.mBackObjects, &parentBox); 371 370 372 BvhLeaf *back = 373 new BvhLeaf(bbox, node, (int)sc.mBackObjects.size()); 374 BvhLeaf *front = 375 new BvhLeaf(fbox, node, (int)sc.mFrontObjects.size()); 371 BvhLeaf *back = new BvhLeaf(bbox, node, (int)sc.mBackObjects.size()); 372 BvhLeaf *front = new BvhLeaf(fbox, node, (int)sc.mFrontObjects.size()); 376 373 377 374 BvhInterior *parent = leaf->GetParent(); … … 428 425 backData.mMaxCostMisses = sc.GetMaxCostMisses(); 429 426 430 // set the time stamp so the order of traversal can be reconstructed 431 node->mTimeStamp = mHierarchyManager->mTimeStamp ++; 432 //cout << "here4 " << node->mTimeStamp << endl; 433 node->mRenderCostDecr = sc.GetRenderCostDecrease(); 434 node->mPvsEntriesIncr = sc.GetPvsEntriesIncr(); 427 //node->mRenderCostDecr = sc.GetRenderCostDecrease(); 428 //node->mPvsEntriesIncr = sc.GetPvsEntriesIncr(); 435 429 436 430 // assign the objects in sorted order … … 465 459 currentNode = SubdivideNode(*sc, tFrontData, tBackData); 466 460 461 // set the time stamp so the order of traversal can be reconstructed 462 currentNode->mTimeStamp = mHierarchyManager->mTimeStamp ++; 463 //currentNode->mRenderCostDecr = sc.GetRenderCostDecrease(); 464 //currentNode->mPvsEntriesIncr = sc.GetPvsEntriesIncr(); 465 467 466 // decrease the weighted average cost of the subdivisoin 468 467 mTotalCost -= sc->GetRenderCostDecrease(); … … 1293 1292 if (useVisibilityBasedHeuristics) 1294 1293 { 1295 cout << "v";1294 //cout << "v rays: " << tData.mNumRays << " " << endl; 1296 1295 /////////// 1297 1296 //-- heuristics using objects weighted by view cells volume … … 1300 1299 } 1301 1300 else 1302 { cout << "e ";1301 { cout << "e rays: " << tData.mNumRays << " "; 1303 1302 ////////////////// 1304 1303 //-- view cells not constructed yet => use surface area heuristic … … 2124 2123 2125 2124 2126 } 2125 SubdivisionCandidate *BvHierarchy::CreateSubdivisionCandidate(BvhInterior *oldNode) 2126 { 2127 return new BvhSubdivisionCandidate(BvhTraversalData()); 2128 } 2129 2130 2131 BvhNode *BvHierarchy::SubdivideAndCopy(SplitQueue &tQueue, 2132 SubdivisionCandidate *splitCandidate, 2133 const bool globalCriteriaMet, 2134 BvhNode *originalNode) 2135 { 2136 BvhSubdivisionCandidate *sc = dynamic_cast<BvhSubdivisionCandidate *>(splitCandidate); 2137 BvhTraversalData &tData = sc->mParentData; 2138 2139 BvhNode *currentNode = tData.mNode; 2140 BvhNode *oldNode = (BvhNode *)splitCandidate->mEvaluationHack; 2141 2142 if (!oldNode->IsLeaf()) 2143 { 2144 ////////////// 2145 //-- continue subdivision 2146 2147 BvhTraversalData tFrontData; 2148 BvhTraversalData tBackData; 2149 2150 BvhInterior *oldInterior = dynamic_cast<BvhInterior *>(oldNode); 2151 //sc->SetSplitPlane(oldInterior->mSplitPlane); 2152 2153 oldInterior->GetFront()->CollectObjects(sc->mFrontObjects); 2154 oldInterior->GetBack()->CollectObjects(sc->mBackObjects); 2155 EvalSubdivisionCandidate(*sc); 2156 2157 // create new interior node and two leaf node 2158 currentNode = SubdivideNode(*sc, tFrontData, tBackData); 2159 2160 // evaluate the changes in render cost and pvs entries 2161 EvalSubdivisionCandidate(*sc, false); 2162 2163 currentNode->mRenderCostDecr = oldNode->mRenderCostDecr + sc->GetRenderCostDecrease(); 2164 currentNode->mPvsEntriesIncr = oldNode->mPvsEntriesIncr + sc->GetPvsEntriesIncr(); 2165 2166 /////////////////////////// 2167 //-- push the new split candidates on the queue 2168 2169 BvhSubdivisionCandidate *frontCandidate = new BvhSubdivisionCandidate(tFrontData); 2170 BvhSubdivisionCandidate *backCandidate = new BvhSubdivisionCandidate(tBackData); 2171 2172 frontCandidate->SetPriority((float)-oldInterior->GetFront()->mTimeStamp); 2173 backCandidate->SetPriority((float)-oldInterior->GetFront()->mTimeStamp); 2174 2175 frontCandidate->mEvaluationHack = oldInterior->GetFront(); 2176 backCandidate->mEvaluationHack = oldInterior->GetBack(); 2177 2178 // cross reference 2179 tFrontData.mNode->SetSubdivisionCandidate(frontCandidate); 2180 tBackData.mNode->SetSubdivisionCandidate(backCandidate); 2181 2182 //cout << "f: " << frontCandidate->GetPriority() << " b: " << backCandidate->GetPriority() << endl; 2183 tQueue.Push(frontCandidate); 2184 tQueue.Push(backCandidate); 2185 } 2186 2187 ///////////////////////////////// 2188 //-- node is a leaf => terminate traversal 2189 2190 if (currentNode->IsLeaf()) 2191 { 2192 // this leaf is no candidate for splitting anymore 2193 // => detach subdivision candidate 2194 tData.mNode->SetSubdivisionCandidate(NULL); 2195 // detach node so we don't delete it with the traversal data 2196 tData.mNode = NULL; 2197 } 2198 2199 return currentNode; 2200 } 2201 2202 2203 }
Note: See TracChangeset
for help on using the changeset viewer.