Changeset 489 for trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
- Timestamp:
- 01/02/06 13:42:43 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r487 r489 45 45 mViewCellsManager(NULL), 46 46 mStoreRays(false), 47 mOnlyDrivingAxis(false) 47 mOnlyDrivingAxis(false), 48 mOutOfBoundsCell(NULL) 48 49 { 49 50 bool randomize = false; … … 128 129 } 129 130 131 130 132 mSplitCandidates = new vector<SortableEntry>; 131 133 132 134 Debug << endl; 135 } 136 137 138 BspViewCell *VspBspTree::GetOrCreateOutOfBoundsCell() 139 { 140 if (!mOutOfBoundsCell) 141 mOutOfBoundsCell = new BspViewCell(); 142 143 return mOutOfBoundsCell; 133 144 } 134 145 … … 401 412 { 402 413 BspLeaf *leaf = dynamic_cast<BspLeaf *>(newNode); 414 BspViewCell *viewCell; 403 415 404 416 if (!CheckValid(tData)) … … 406 418 leaf->SetTreeValid(false); 407 419 PropagateUpValidity(leaf); 408 } 409 410 // create new view cell for this leaf 411 BspViewCell *viewCell = new BspViewCell(); 420 // view cell for invalid view space 421 viewCell = GetOrCreateOutOfBoundsCell(); 422 } 423 else 424 { 425 // create new view cell for this leaf 426 viewCell = new BspViewCell(); 427 } 428 412 429 leaf->SetViewCell(viewCell); 413 430 … … 1206 1223 { 1207 1224 BspNode *node = nodeStack.top(); 1208 1209 1225 nodeStack.pop(); 1226 1227 // this subtree is not valid view space 1228 if (!node->TreeValid()) 1229 continue; 1210 1230 1211 1231 if (node->IsLeaf()) … … 1224 1244 } 1225 1245 1246 1226 1247 AxisAlignedBox3 VspBspTree::GetBoundingBox() const 1227 1248 { … … 1229 1250 } 1230 1251 1252 1231 1253 BspNode *VspBspTree::GetRoot() const 1232 1254 { 1233 1255 return mRoot; 1234 1256 } 1257 1258 1259 BspViewCell *VspBspTree::GetOutOfBoundsCell() const 1260 { 1261 return mOutOfBoundsCell; 1262 } 1263 1235 1264 1236 1265 void VspBspTree::EvaluateLeafStats(const VspBspTraversalData &data) … … 1399 1428 BspNode *node = nodeStack.top(); 1400 1429 nodeStack.pop(); 1430 // this subtree is not valid view space 1431 if (!node->TreeValid()) 1432 continue; 1401 1433 1402 1434 if (node->IsLeaf()) … … 1635 1667 nodeStack.pop(); 1636 1668 1669 // view space not valid 1670 if (!node->TreeValid()) 1671 continue; 1672 1637 1673 if (node->IsLeaf()) 1638 1674 { … … 1687 1723 return (int)neighbors.size(); 1688 1724 } 1725 1689 1726 1690 1727 BspLeaf *VspBspTree::GetRandomLeaf(const Plane3 &halfspace) … … 2002 2039 2003 2040 BspLeaf *leaf = new BspLeaf(interior->GetParent(), vc); 2041 leaf->SetTreeValid(frontLeaf->TreeValid()); 2004 2042 2005 2043 // replace a link from node's parent … … 2170 2208 2171 2209 iit = ray->intersections.begin(); 2172 BspLeaf * prevLeaf = (*(iit ++)).mLeaf;2210 BspLeaf *leaf = (*(iit ++)).mLeaf; 2173 2211 2174 2212 // create leaf pvs (needed for post processing) 2175 if (! prevLeaf->mPvs)2176 { 2177 prevLeaf->mPvs =2178 new ObjectPvs( prevLeaf->GetViewCell()->GetPvs());2213 if (!leaf->mPvs) 2214 { 2215 leaf->mPvs = 2216 new ObjectPvs(leaf->GetViewCell()->GetPvs()); 2179 2217 2180 2218 BspMergeCandidate::sOverallCost += 2181 prevLeaf->mArea * prevLeaf->mPvs->GetSize();2219 leaf->mArea * leaf->mPvs->GetSize(); 2182 2220 2183 2221 ++ leaves; … … 2185 2223 2186 2224 // traverse intersections 2187 // consecutive leaves are neighbors => 2188 // add them to queue 2225 // consecutive leaves are neighbors => add them to queue 2189 2226 for (; iit != ray->intersections.end(); ++ iit) 2190 2227 { 2191 BspLeaf *leaf = (*iit).mLeaf; 2192 2228 // next pair 2229 BspLeaf *prevLeaf = leaf; 2230 leaf = (*iit).mLeaf; 2231 2232 // view space does not correspond to valid space 2233 if (!leaf->TreeValid() || !prevLeaf->TreeValid()) 2234 continue; 2235 2236 // create leaf pvs (needed for post processing) 2193 2237 if (!leaf->mPvs) 2194 2238 { … … 2229 2273 mMergeQueue.push(BspMergeCandidate(leaf, prevLeaf)); 2230 2274 } 2231 2232 prevLeaf = leaf;2233 2275 } 2234 2276 }
Note: See TracChangeset
for help on using the changeset viewer.