Changeset 1183 for GTP/trunk/Lib/Vis
- Timestamp:
- 08/04/06 17:38:52 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTree.h
r1182 r1183 211 211 //virtual void cbInsert(KdTree * caller, KdRenderable * rend) = 0; 212 212 213 WireBoundingBox * getWireBoundingBox( )213 WireBoundingBox * getWireBoundingBox(bool node = true) 214 214 { 215 215 if (mWBB == 0) 216 216 mWBB = new WireBoundingBox(); 217 217 218 mWBB->setupBoundingBox(mAABB); 218 if (node) 219 mWBB->setupBoundingBox(mAABB); 220 else 221 mWBB->setupBoundingBox(mWorldAABB); 219 222 220 223 #ifdef KDTREE_DEBUG 224 SceneManager * sceneManager = Root::getSingleton()._getCurrentSceneManager(); 221 225 int level = -1; 222 226 bool boxes = false; 223 if ( Root::getSingleton()._getCurrentSceneManager()->getOption("HighlightLevel",&level))227 if (sceneManager->getOption("HighlightLevel",&level)) 224 228 { 225 229 if (mLevel == level) … … 232 236 { 233 237 mWBB->setMaterial("BaseWhiteNoLighting"); 234 if ( Root::getSingleton()._getCurrentSceneManager()->getOption("ShowAllBoxes", &boxes))238 if (sceneManager->getOption("ShowAllBoxes", &boxes)) 235 239 { 236 240 if (boxes) … … 279 283 /** Updates bound of the real aabb of kdtree 280 284 */ 281 virtual void _updateBounds() = 0; 282 285 virtual void _updateBounds(bool recurse = true) = 0; 283 286 284 287 Branch * mParent; … … 325 328 326 329 // branches do not posses geometry => just merge child aabbs 327 virtual void _updateBounds( )330 virtual void _updateBounds(bool recurse = true) 328 331 { 329 332 // reset box … … 336 339 337 340 // update parent recursively 338 if ( mParent)339 mParent->_updateBounds( );341 if (recurse && mParent) 342 mParent->_updateBounds(recurse); 340 343 } 341 344 … … 365 368 366 369 // update the world aabb based on the contained geometry 367 virtual void _updateBounds( );370 virtual void _updateBounds(bool recurse = true); 368 371 369 372 virtual void remove(KdRenderable * rend) … … 464 467 void dump(void); 465 468 Real calcCost(void); 469 470 /** Switches between displaying the bounding box of the node and 471 the box of the contained scene nodes 472 */ 473 inline void setShowNodeAABB(bool show = true) { mShowNodeAABB = show; }; 474 inline bool getShowNodeAABB(void) { return mShowNodeAABB; }; 466 475 467 476 NodePtr getRoot(void) const { return mKdRoot; }; … … 523 532 Stats mStats; 524 533 534 // show node or object aabb 535 bool mShowNodeAABB; 536 537 525 538 // DEBUG 526 539 void KdTree::dump(KdTree::Node * node); -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTree.cpp
r1182 r1183 329 329 //---------------------------------------------------------------------------- 330 330 331 KdTree::KdTree(int maxdepth): mMaxDepth(maxdepth), mKdRoot(0), mBuildMethod(KDBM_RECURSIVE), mBuildLog(0) 331 KdTree::KdTree(int maxdepth): 332 mMaxDepth(maxdepth), 333 mKdRoot(0), 334 mBuildMethod(KDBM_RECURSIVE), 335 mBuildLog(0), 336 mShowNodeAABB(true) 332 337 { 333 338 #ifdef KDTREE_DEBUG … … 340 345 mp->setDiffuse(cv); 341 346 } 342 //try343 //{344 // ColourValue cv(0.0, 1.0, 0.0);345 // MaterialPtr mp = MaterialManager::getSingleton().create("aabbHiLite","General");346 // mp->setSelfIllumination(cv);347 // mp->setDiffuse(cv);348 //}349 //catch (Ogre::Exception&)350 //{351 // // SO FUCKING DON'T CARE !!!352 //}353 347 #endif 354 348 try … … 871 865 ++ mStats.mNumNodes; 872 866 ++ mStats.mNumLeaves; 867 // update bounding box 868 leaf->_updateBounds(false); 873 869 return leaf; 874 870 } … … 957 953 // update stats 958 954 ++ mStats.mNumNodes; 955 956 // update bounding box 957 branch->_updateBounds(false); 958 959 959 960 960 //assert(branch->mRight || branch->mLeft); … … 1261 1261 } 1262 1262 1263 // update bounding boxes when geometry (leaf) was added 1264 if (newNode->isLeaf()) 1265 newNode->_updateBounds(); 1266 1263 1267 //cleanup 1264 1268 OGRE_DELETE(sc.events); … … 1336 1340 WireBoundingBox * wbb = 0; 1337 1341 if (showBoxes) 1338 wbb = node->getWireBoundingBox( );1342 wbb = node->getWireBoundingBox(mShowNodeAABB); 1339 1343 #endif 1340 1344 … … 1357 1361 #else 1358 1362 if (showBoxes) 1359 queue->addRenderable(leaf->getWireBoundingBox( ));1363 queue->addRenderable(leaf->getWireBoundingBox(mShowNodeAABB)); 1360 1364 #endif 1361 1365 } … … 1368 1372 #else 1369 1373 if (showBoxes) 1370 queue->addRenderable(branch->getWireBoundingBox( ));1374 queue->addRenderable(branch->getWireBoundingBox(mShowNodeAABB)); 1371 1375 #endif 1372 1376 … … 1469 1473 1470 1474 // update the world aabb based on the contained geometry 1471 void KdTree::Leaf::_updateBounds( )1475 void KdTree::Leaf::_updateBounds(bool recurse) 1472 1476 { 1473 1477 // reset box … … 1479 1483 while (it != end) 1480 1484 { 1485 //(*it)->_updateBounds(); 1481 1486 mWorldAABB.merge((*it)->getBoundingBox()); 1482 1487 it++; … … 1484 1489 1485 1490 // update parent recursively 1486 if ( mParent)1487 mParent->_updateBounds( );1491 if (recurse && mParent) 1492 mParent->_updateBounds(recurse); 1488 1493 } 1489 1494 } // namespace Ogre -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp
r1182 r1183 59 59 60 60 mHierarchyInterface = new KdTreeHierarchyInterface(this, mDestRenderSystem); 61 62 // test 63 //String chc = "CHC"; 64 //setOption("RenderMethod", &chc); 61 65 } 62 66 … … 240 244 return true; 241 245 } 246 else if (strKey == "ShowNodeAABB") 247 { 248 bool sn = *static_cast<const bool *>(pValue); 249 if (mKdTree) 250 mKdTree->setShowNodeAABB(sn); 251 return true; 252 } 253 // options for CHC 254 if (strKey == "UseDepthPass") 255 { 256 mUseDepthPass = (*static_cast<const bool *>(pValue)); 257 return true; 258 } 259 if (strKey == "PrepareVisualization") 260 { 261 mShowVisualization = (*static_cast<const bool *>(pValue)); 262 return true; 263 } 264 if (strKey == "RenderNodesForViz") 265 { 266 mRenderNodesForViz = (*static_cast<const bool *>(pValue)); 267 return true; 268 } 269 if (strKey == "RenderNodesContentForViz") 270 { 271 mRenderNodesContentForViz = (*static_cast<const bool *>(pValue)); 272 return true; 273 } 274 if (strKey == "SkyBoxEnabled") 275 { 276 mSkyBoxEnabled = (*static_cast<const bool *>(pValue)); 277 return true; 278 } 279 if (strKey == "SkyPlaneEnabled") 280 { 281 mSkyPlaneEnabled = (*static_cast<const bool *>(pValue)); 282 return true; 283 } 284 if (strKey == "SkyDomeEnabled") 285 { 286 mSkyDomeEnabled = (*static_cast<const bool *>(pValue)); 287 return true; 288 } 289 if (strKey == "VisualizeCulledNodes") 290 { 291 mVisualizeCulledNodes = (*static_cast<const bool *>(pValue)); 292 return true; 293 } 294 if (strKey == "DelayRenderTransparents") 295 { 296 mDelayRenderTransparents = (*static_cast<const bool *>(pValue)); 297 return true; 298 } 299 300 if (strKey == "DepthWrite") 301 { 302 mEnableDepthWrite = (*static_cast<const bool *>(pValue)); 303 return true; 304 } 305 if (strKey == "UseItemBuffer") 306 { 307 mUseItemBuffer = (*static_cast<const bool *>(pValue)); 308 return true; 309 } 310 if (strKey == "ExecuteVertexProgramForAllPasses") 311 { 312 mExecuteVertexProgramForAllPasses = (*static_cast<const bool *>(pValue)); 313 return true; 314 } 315 if (strKey == "RenderTransparentsForItemBuffer") 316 { 317 mRenderTransparentsForItemBuffer = (*static_cast<const bool *>(pValue)); 318 return true; 319 } 320 242 321 243 322 return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface) … … 270 349 else if (strKey == "ShowAllBoxes") 271 350 { 272 *static_cast<bool *>(pDestValue) = mShowAllBoxes; 351 if (mRenderMethod == KdTree::KDRM_INTERNAL) 352 *static_cast<bool *>(pDestValue) = mShowAllBoxes; 353 else 354 *static_cast<bool *>(pDestValue) = mVisualizeCulledNodes; 273 355 return true; 274 356 } … … 308 390 return false; 309 391 } 392 return true; 393 } 394 else if (strKey == "ShowKdTree") 395 { 396 *static_cast<bool *>(pDestValue) = mShowBoxes; 397 return true; 398 } 399 else if (strKey == "ShowNodeAABB") 400 { 401 if (mKdTree) 402 *static_cast<bool *>(pDestValue) = mKdTree->getShowNodeAABB(); 403 else 404 *static_cast<bool *>(pDestValue) = false; 310 405 return true; 311 406 } … … 331 426 refKeys.push_back("RenderMethod"); 332 427 refKeys.push_back("ShowKdTree"); 428 refKeys.push_back("ShowNodeAABB"); 333 429 refKeys.push_back("TreeBox"); 334 430 #ifdef KDTREE_DEBUG … … 639 735 while (it != end) 640 736 { 641 (*it)->queueObjects(cam, getRenderQueue(), onlyShadowCasters); 737 if (!(*it)->isQueued(mHierarchyInterface->GetFrameId(), cam)) 738 { 739 (*it)->queueObjects(cam, getRenderQueue(), onlyShadowCasters); 740 } 642 741 it++; 643 742 } … … 841 940 } 842 941 // add bounding boxes of rendered objects 843 if (0)942 //if (0) 844 943 //for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) 845 944 //{ -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneNode.cpp
r1182 r1183 12 12 13 13 #include <OgreStringConverter.h> 14 #include <OgreLogManager.h> 14 15 15 16 namespace Ogre … … 140 141 } 141 142 143 // recalculate the world aabb 142 144 AxisAlignedBox KdTreeSceneNode::getBoundingBox() const 143 145 { 146 #if 0 147 AxisAlignedBox box; 148 149 // Update bounds from own attached objects 150 ObjectMap::const_iterator it = mObjectsByName.begin(); 151 ObjectMap::const_iterator end = mObjectsByName.end(); 152 for ( ; it != end ; ++it) 153 { 154 // Merge world bounds of each object 155 box.merge(it->second->getWorldBoundingBox(true)); 156 } 157 158 if (box.getMinimum() != mWorldAABB.getMinimum() ||box.getMaximum() != mWorldAABB.getMaximum()) 159 { 160 try 161 { 162 Log * log = LogManager::getSingleton().getLog("KdTreeBuild.log"); 163 log->logMessage("mWorldAABB was not up to date"); 164 } 165 catch (Exception) 166 { 167 // F.U. 168 } 169 } 170 171 return box; 172 #else 144 173 return mWorldAABB; 174 #endif 145 175 } 146 176
Note: See TracChangeset
for help on using the changeset viewer.