Changeset 1170 for GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src
- Timestamp:
- 07/28/06 17:06:01 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTree.cpp
r1163 r1170 465 465 else 466 466 { 467 KdTree::Branch * branch = static_cast<KdTree::Branch *>(node);467 KdTree::Branch * branch = KDBRANCHPTR_CAST(node); 468 468 AxisAlignedBox aabb = rend->getBoundingBox(); 469 469 Plane::Side smin = branch->mSplitPlane->getSide(aabb.getMinimum()); … … 576 576 else 577 577 { 578 KdTree::Branch * parent = static_cast<KdTree::Branch *>(node->mParent);578 KdTree::Branch * parent = KDBRANCHPTR_CAST(node->mParent); 579 579 580 580 if (node == parent->mLeft) … … 619 619 if (node->isLeaf()) 620 620 { 621 KdTree::Leaf * leaf = static_cast<KdTree::Leaf *>(node);621 KdTree::Leaf * leaf = KDLEAFPTR_CAST(node); 622 622 KdRenderableList::iterator it = leaf->mKdRenderables.begin(); 623 623 KdRenderableList::iterator end = leaf->mKdRenderables.end(); … … 630 630 else 631 631 { 632 KdTree::Branch * branch = static_cast<KdTree::Branch *>(node);632 KdTree::Branch * branch = KDBRANCHPTR_CAST(node); 633 633 if (branch->mLeft) 634 634 addRendToList(branch->mLeft, nodelist); … … 1272 1272 } 1273 1273 1274 void KdTree::queueVisibleObjects(Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes) 1275 { 1274 void KdTree::queueVisibleObjects(Camera* cam, RenderQueue* queue, bool onlyShadowCasters, 1275 KdTree::RenderMethod renderMethod, bool showBoxes) 1276 { 1277 // for now only recurse or stack render methods 1276 1278 if (mKdRoot) 1277 recQueueVisibleObjects(mKdRoot, Root::getSingleton().getCurrentFrameNumber(), cam, queue, onlyShadowCasters, showBoxes); 1278 } 1279 1280 void KdTree::recQueueVisibleObjects(KdTree::Node * node, unsigned long currentFrame, Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes) 1279 { 1280 //if (renderMethod == KdTree::KDRM_STACK) 1281 //{ 1282 // stackQueueVisibleObjects(mKdRoot, Root::getSingleton().getCurrentFrameNumber(), 1283 // cam, queue, onlyShadowCasters, showBoxes); 1284 //} 1285 //else 1286 //{ 1287 recQueueVisibleObjects(mKdRoot, Root::getSingleton().getCurrentFrameNumber(), 1288 cam, queue, onlyShadowCasters, showBoxes); 1289 //} 1290 } 1291 } 1292 1293 void KdTree::recQueueVisibleObjects(KdTree::Node * node, unsigned long currentFrame, 1294 Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes) 1281 1295 { 1282 1296 // test visibility … … 1291 1305 if (node->isLeaf()) 1292 1306 { 1293 KdTree::Leaf * leaf = static_cast<KdTree::Leaf *>(node);1307 KdTree::Leaf * leaf = KDLEAFPTR_CAST(node); 1294 1308 KdRenderableList::iterator it = leaf->mKdRenderables.begin(); 1295 1309 KdRenderableList::iterator end = leaf->mKdRenderables.end(); … … 1312 1326 else 1313 1327 { 1314 KdTree::Branch * branch = static_cast<KdTree::Branch *>(node);1328 KdTree::Branch * branch = KDBRANCHPTR_CAST(node); 1315 1329 #ifdef KDTREE_DEBUG 1316 1330 if (wbb) … … 1325 1339 if (branch->mRight) 1326 1340 recQueueVisibleObjects(branch->mRight, currentFrame, cam, queue, onlyShadowCasters, showBoxes); 1341 } 1342 } 1343 } 1344 1345 void KdTree::stackQueueVisibleObjects(KdTree::Node * root, unsigned long currentFrame, Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes) 1346 { 1347 static NodeStack nodestack; 1348 if (!nodestack.empty()) OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 1349 "Stuff left in stack from previos frame", "KdTree::stackQueueVisibleObjects"); 1350 1351 nodestack.push(root); 1352 1353 while (!nodestack.empty()) 1354 { 1355 KdTree::Node * node = nodestack.top(); 1356 nodestack.pop(); 1357 1358 // test visibility 1359 if (cam->isVisible(node->mAABB)) 1360 { 1361 #ifdef KDTREE_DEBUG 1362 WireBoundingBox * wbb = 0; 1363 if (showBoxes) 1364 wbb = node->getWireBoundingBox(); 1365 #endif 1366 1367 if (node->isLeaf()) 1368 { 1369 KdTree::Leaf * leaf = KDLEAFPTR_CAST(node); 1370 KdRenderableList::iterator it = leaf->mKdRenderables.begin(); 1371 KdRenderableList::iterator end = leaf->mKdRenderables.end(); 1372 while (it != end) 1373 { 1374 if (!(*it)->isQueued(currentFrame, cam)) 1375 { 1376 (*it)->queueObjects(cam, queue, onlyShadowCasters); 1377 } 1378 it++; 1379 } 1380 #ifdef KDTREE_DEBUG 1381 if (wbb) 1382 queue->addRenderable(wbb); 1383 #else 1384 if (showBoxes) 1385 queue->addRenderable(leaf->getWireBoundingBox()); 1386 #endif 1387 } 1388 else 1389 { 1390 KdTree::Branch * branch = KDBRANCHPTR_CAST(node); 1391 #ifdef KDTREE_DEBUG 1392 if (wbb) 1393 queue->addRenderable(wbb); 1394 #else 1395 if (showBoxes) 1396 queue->addRenderable(branch->getWireBoundingBox()); 1397 #endif 1398 1399 if (branch->mLeft) 1400 nodestack.push(branch->mLeft); 1401 if (branch->mRight) 1402 nodestack.push(branch->mRight); 1403 } 1327 1404 } 1328 1405 } … … 1351 1428 if (node->isLeaf()) 1352 1429 { 1353 KdTree::Leaf * leaf = static_cast<KdTree::Leaf *>(node);1430 KdTree::Leaf * leaf = KDLEAFPTR_CAST(node); 1354 1431 KdRenderableList::iterator it = leaf->mKdRenderables.begin(); 1355 1432 KdRenderableList::iterator end = leaf->mKdRenderables.end(); … … 1365 1442 else 1366 1443 { 1367 KdTree::Branch * branch = static_cast<KdTree::Branch *>(node);1444 KdTree::Branch * branch = KDBRANCHPTR_CAST(node); 1368 1445 if (branch->mLeft) 1369 1446 { … … 1396 1473 if (node->isLeaf()) 1397 1474 { 1398 KdTree::Leaf * leaf = static_cast<KdTree::Leaf *>(node);1475 KdTree::Leaf * leaf = KDLEAFPTR_CAST(node); 1399 1476 return (PlaneEvent::surfaceArea(node->mAABB)/vs)*PlaneEvent::KI*leaf->mKdRenderables.size(); 1400 1477 } 1401 1478 else 1402 1479 { 1403 KdTree::Branch * branch = static_cast<KdTree::Branch *>(node);1480 KdTree::Branch * branch = KDBRANCHPTR_CAST(node); 1404 1481 return (PlaneEvent::surfaceArea(node->mAABB)/vs)*PlaneEvent::KT + calcCost(branch->mLeft, vs) + calcCost(branch->mRight, vs); 1405 1482 } -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeHierarchyInterface.cpp
r1165 r1170 15 15 16 16 KdTreeHierarchyInterface::KdTreeHierarchyInterface(KdTreeSceneManager *sm, RenderSystem *rsys): 17 SceneNodeHierarchyInterface(sm, rsys)17 PlatformHierarchyInterface(sm, rsys) 18 18 { 19 19 … … 22 22 bool KdTreeHierarchyInterface::IsLeaf(GtpVisibility::HierarchyNode *node) const 23 23 { 24 KdTree::Node * kdnode = static_cast<KdTree::Node *>(node); 25 return kdnode->isLeaf(); 24 return KDNODEPTR_CAST(node)->isLeaf(); 26 25 } 27 26 27 void KdTreeHierarchyInterface::TraverseNode(GtpVisibility::HierarchyNode *node) 28 { 29 ++ mNumTraversedNodes; 28 30 31 KdTree::Node * kdnode = KDNODEPTR_CAST(node); 32 33 // if the node is a leaf and has geometry => render it 34 if (kdnode->isLeaf()) 35 { 36 if (!kdnode->isEmpty()) 37 { 38 RenderNode(node); 39 } 40 } 41 else 42 { 43 KdTree::Branch * kdbranch = KDBRANCHPTR_CAST(node); 44 if (kdbranch->mLeft) 45 mDistanceQueue->push(kdbranch->mLeft); 46 if (kdbranch->mRight) 47 mDistanceQueue->push(kdbranch->mRight); 48 } 29 49 } 50 51 void KdTreeHierarchyInterface::RenderNode(GtpVisibility::HierarchyNode *node) 52 { 53 /*** TODO ***/ 54 } 55 56 void KdTreeHierarchyInterface::PullUpVisibility(GtpVisibility::HierarchyNode *node) const 57 { 58 /*** TODO ***/ 59 } 60 61 float KdTreeHierarchyInterface::GetSquaredDistance(GtpVisibility::HierarchyNode *node) const 62 { 63 /*** TODO ***/ 64 return 0.0; 65 } 66 67 AxisAlignedBox * KdTreeHierarchyInterface::GetBoundingBox(GtpVisibility::HierarchyNode *node) 68 { 69 /*** TODO ***/ 70 return new AxisAlignedBox(); 71 } 72 73 bool KdTreeHierarchyInterface::HasGeometry(GtpVisibility::HierarchyNode *node) const 74 { 75 return KDNODEPTR_CAST(node)->hasGeometry(); 76 } 77 78 void KdTreeHierarchyInterface::SetNodeVisible(GtpVisibility::HierarchyNode *node, const bool visible) const 79 { 80 /*** TODO ***/ 81 } 82 83 bool KdTreeHierarchyInterface::IsNodeVisible(GtpVisibility::HierarchyNode *node) const 84 { 85 /*** TODO ***/ 86 return true; 87 } 88 89 void KdTreeHierarchyInterface::SetLastVisited(GtpVisibility::HierarchyNode *node, const unsigned int frameId) const 90 { 91 /*** TODO ***/ 92 } 93 94 unsigned int KdTreeHierarchyInterface::LastVisited(GtpVisibility::HierarchyNode *node) const 95 { 96 /*** TODO ***/ 97 return 0; 98 } 99 100 void KdTreeHierarchyInterface::VisualizeCulledNode(GtpVisibility::HierarchyNode *node, 101 GtpVisibility::CullingType type) const 102 { 103 /*** TODO ***/ 104 } 105 106 void KdTreeHierarchyInterface::GetNodeGeometryList(GtpVisibility::HierarchyNode *node, 107 GtpVisibility::GeometryVector *geometryList, 108 bool includeChildren) 109 { 110 /*** TODO ***/ 111 } 112 113 } // namespace Ogre -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp
r1165 r1170 32 32 // kill the old kd-tree if exists 33 33 OGRE_DELETE(mKdTree); 34 35 mRenderMethod = KdTree::KDRM_RECURSE; 34 36 35 37 //mBuildMethod = KdTree::KDBM_RECURSIVE; … … 160 162 } 161 163 } 164 else if (strKey == "RenderMethod") 165 { 166 String rm = *static_cast<const String *>(pValue); 167 if (rm == "Recursive") 168 { 169 mRenderMethod = KdTree::KDRM_RECURSE; 170 return true; 171 } 172 else if (rm == "Stack") 173 { 174 mRenderMethod = KdTree::KDRM_STACK; 175 return true; 176 } 177 else if (rm == "StopAndWait") 178 { 179 mRenderMethod = KdTree::KDRM_SAW; 180 return true; 181 } 182 else if (rm == "CHC") 183 { 184 mRenderMethod = KdTree::KDRM_CHC; 185 return true; 186 } 187 else 188 { 189 return false; 190 } 191 } 162 192 else if (strKey == "ShowKdTree") 163 193 { … … 208 238 { 209 239 *static_cast<String *>(pDestValue) = "Recursive"; 240 } 241 return true; 242 } 243 else if (strKey == "RenderMethod") 244 { 245 if (mRenderMethod == KdTree::KDRM_RECURSE) 246 { 247 *static_cast<String *>(pDestValue) = "Recursive"; 248 } 249 else if (mRenderMethod == KdTree::KDRM_STACK) 250 { 251 *static_cast<String *>(pDestValue) = "Stack"; 252 } 253 else if (mRenderMethod == KdTree::KDRM_SAW) 254 { 255 *static_cast<String *>(pDestValue) = "StopAndWait"; 256 } 257 else if (mRenderMethod == KdTree::KDRM_CHC) 258 { 259 *static_cast<String *>(pDestValue) = "CHC"; 210 260 } 211 261 return true; … … 278 328 // inserting single nodes yields sub-optimal results 279 329 // rebuilding tree takes too long 280 // "What now ", spoke Zeus ...330 // "What now?", spoke Zeus ... 281 331 282 332 //mKdTree->insert(node); … … 293 343 getRenderQueue()->clear(); 294 344 if (mKdTree) 295 mKdTree->queueVisibleObjects(cam, getRenderQueue(), onlyShadowCasters, m ShowBoxes);345 mKdTree->queueVisibleObjects(cam, getRenderQueue(), onlyShadowCasters, mRenderMethod, mShowBoxes); 296 346 //SceneManager::_findVisibleObjects(cam, onlyShadowCasters); 297 347 }
Note: See TracChangeset
for help on using the changeset viewer.