Changeset 1177 for GTP/trunk/Lib
- Timestamp:
- 08/02/06 15:22:19 (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
r1173 r1177 429 429 enum RenderMethod 430 430 { 431 KDRM_RECURSE, 432 KDRM_STACK, 433 KDRM_SAW, 434 KDRM_CHC 431 KDRM_INTERNAL, 432 KDRM_GTP_VFC, 433 KDRM_GTP_SWC, 434 KDRM_GTP_CHC 435 435 436 }; 436 437 … … 488 489 void recQueueVisibleObjects(KdTree::Node * node, unsigned long currentFrame, 489 490 Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes); 490 // stack based rendering function491 void stackQueueVisibleObjects(KdTree::Node * root, unsigned long currentFrame,492 Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes);493 491 494 492 // the root node of the kdtree -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTreeSceneManager.h
r1175 r1177 32 32 virtual const String& getTypeName(void) const; 33 33 34 /** Override from SceneManager to create SceneNodes as instance of KdTreeSceneNode 35 */ 34 36 virtual SceneNode* createSceneNode(void); 37 /** Override from SceneManager to create SceneNodes as instance of KdTreeSceneNode 38 */ 35 39 virtual SceneNode* createSceneNode(const String& name); 40 36 41 /** Override from SceneManager so that sub entities can be assigned an id for item buffer. 37 42 */ … … 42 47 virtual void _updateNode(KdTreeSceneNode *node); // TODO: 43 48 44 //virtual void _updateSceneGraph(Camera* cam); 49 /** Override from scene manager to st up culling manager 50 */ 51 virtual void _updateSceneGraph(Camera* cam); 52 /** Override from Scenemanager, employ kd-tree based culling 53 or CHC 54 */ 45 55 virtual void _findVisibleObjects(Camera *cam, bool onlyShadowCasters); 46 56 //virtual void _renderVisibleObjects(); 47 57 58 /** Render a list of scenenodes 59 */ 48 60 virtual void _renderNodes(const KdRenderableList& nodelist, Camera * cam, 49 61 bool onlyShadowCasters, int leavePassesInQueue); -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTree.cpp
r1173 r1177 1278 1278 if (mKdRoot) 1279 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 //} 1280 recQueueVisibleObjects(mKdRoot, Root::getSingleton().getCurrentFrameNumber(), 1281 cam, queue, onlyShadowCasters, showBoxes); 1290 1282 } 1291 1283 } … … 1343 1335 } 1344 1336 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 visibility1359 if (cam->isVisible(node->mAABB))1360 {1361 #ifdef KDTREE_DEBUG1362 WireBoundingBox * wbb = 0;1363 if (showBoxes)1364 wbb = node->getWireBoundingBox();1365 #endif1366 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_DEBUG1381 if (wbb)1382 queue->addRenderable(wbb);1383 #else1384 if (showBoxes)1385 queue->addRenderable(leaf->getWireBoundingBox());1386 #endif1387 }1388 else1389 {1390 KdTree::Branch * branch = KDBRANCHPTR_CAST(node);1391 #ifdef KDTREE_DEBUG1392 if (wbb)1393 queue->addRenderable(wbb);1394 #else1395 if (showBoxes)1396 queue->addRenderable(branch->getWireBoundingBox());1397 #endif1398 1399 if (branch->mLeft)1400 nodestack.push(branch->mLeft);1401 if (branch->mRight)1402 nodestack.push(branch->mRight);1403 }1404 }1405 }1406 }1407 1408 1337 void KdTree::dump() 1409 1338 { -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp
r1175 r1177 14 14 #include "OgreKdTree.h" 15 15 #include "OgreVisibilityOptionsManager.h" 16 #include <VisibilityEnvironment.h> 16 17 17 18 #include <OgreLogManager.h> … … 31 32 #endif 32 33 mBuildMethod(KdTree::KDBM_PRIORITYQUEUE), 33 mRenderMethod(KdTree::KDRM_ RECURSE),34 mRenderMethod(KdTree::KDRM_INTERNAL), 34 35 mLeavePassesInQueue(0), 35 36 mCurrentEntityId(1) … … 164 165 { 165 166 String rm = *static_cast<const String *>(pValue); 166 if (rm == "Recursive") 167 { 168 mRenderMethod = KdTree::KDRM_RECURSE; 169 return true; 170 } 171 else if (rm == "Stack") 172 { 173 mRenderMethod = KdTree::KDRM_STACK; 174 return true; 175 } 176 else if (rm == "StopAndWait") 177 { 178 mRenderMethod = KdTree::KDRM_SAW; 179 return true; 167 if (rm == "INT") 168 { 169 mRenderMethod = KdTree::KDRM_INTERNAL; 170 return true; 171 } 172 else if (rm == "VFC") 173 { 174 mRenderMethod = KdTree::KDRM_GTP_VFC; 175 int cmt = GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING; 176 return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface) 177 .setOption("Algorithm", &cmt); 178 } 179 else if (rm == "SWC") 180 { 181 mRenderMethod = KdTree::KDRM_GTP_SWC; 182 int cmt = GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING; 183 return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface) 184 .setOption("Algorithm", &cmt); 180 185 } 181 186 else if (rm == "CHC") 182 187 { 183 mRenderMethod = KdTree::KDRM_CHC; 184 return true; 185 } 186 else 187 { 188 return false; 189 } 188 mRenderMethod = KdTree::KDRM_GTP_CHC; 189 int cmt = GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING; 190 return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface) 191 .setOption("Algorithm", &cmt); 192 } 193 else 194 { 195 return false; 196 } 197 } 198 // little hack in case someone uses "Algorithm" option from VisOptMan directly 199 else if (strKey == "Algorithm") 200 { 201 bool success = VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface) 202 .setOption(strKey, pValue); 203 // change setting only if change in VisOptMan was successful 204 if (success) 205 { 206 int val = *static_cast<const int *>(pValue); 207 if (val == GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING) 208 mRenderMethod = KdTree::KDRM_GTP_VFC; 209 else if (val == GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING) 210 mRenderMethod = KdTree::KDRM_GTP_SWC; 211 else if (val == GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING) 212 mRenderMethod = KdTree::KDRM_GTP_CHC; 213 // default, should never happen 214 else 215 mRenderMethod = KdTree::KDRM_INTERNAL; 216 } 217 return success; 190 218 } 191 219 else if (strKey == "ShowKdTree") … … 243 271 else if (strKey == "RenderMethod") 244 272 { 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"; 273 if (mRenderMethod == KdTree::KDRM_INTERNAL) 274 { 275 *static_cast<String *>(pDestValue) = "INT"; 276 } 277 else if (mRenderMethod == KdTree::KDRM_GTP_VFC) 278 { 279 *static_cast<String *>(pDestValue) = "VFC"; 280 } 281 else if (mRenderMethod == KdTree::KDRM_GTP_SWC) 282 { 283 *static_cast<String *>(pDestValue) = "SWC"; 284 } 285 else if (mRenderMethod == KdTree::KDRM_GTP_CHC) 286 { 287 *static_cast<String *>(pDestValue) = "CHC"; 288 } 289 else 290 { 291 return false; 260 292 } 261 293 return true; … … 343 375 { 344 376 Entity *ent = SceneManager::createEntity(entityName, meshName); 345 377 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 346 378 for (int i = 0; i < (int)ent->getNumSubEntities(); ++i) 347 379 { … … 351 383 // increase counter of entity id values 352 384 ++ mCurrentEntityId; 353 385 #endif 354 386 return ent; 355 387 } … … 398 430 } 399 431 432 void KdTreeSceneManager::_updateSceneGraph(Camera* cam) 433 { 434 mVisibilityManager->GetCullingManager()->SetHierarchyInterface(mHierarchyInterface); 435 mHierarchyInterface->SetRenderSystem(mDestRenderSystem); 436 437 SceneManager::_updateSceneGraph(cam); 438 } 439 400 440 void KdTreeSceneManager::_findVisibleObjects(Camera *cam, bool onlyShadowCasters) 401 441 {
Note: See TracChangeset
for help on using the changeset viewer.