Changeset 880 for GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
- Timestamp:
- 05/03/06 01:13:24 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreVisibilityOctreeSceneManager.h
r870 r880 196 196 GtpVisibilityPreprocessor::ViewCellsManager *mViewCellsManager; 197 197 198 /** Used to assign Ogre meshes to view cell entries. 199 */ 198 /// Used to assign Ogre meshes to view cell entries. 200 199 GtpVisibilityPreprocessor::ObjectContainer mObjects; 201 200 202 GtpVisibilityPreprocessor::ViewCell *m OldViewCell;201 GtpVisibilityPreprocessor::ViewCell *mElementaryViewCell; 203 202 GtpVisibilityPreprocessor::ViewCell *mCurrentViewCell; 204 203 205 /** If view cells are used. 206 */ 204 /// If view cells are used. 207 205 bool mUseViewCells; 206 207 /// if the view cells are filtered 208 bool mUseVisibilityFilter; 208 209 }; 209 210 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOctreeHierarchyInterface.cpp
r868 r880 144 144 { 145 145 mSavedNode = node; 146 // dynamic_cast<Octree *>(node)->_getCullBounds(&mBox);146 //static_cast<Octree *>(node)->_getCullBounds(&mBox); 147 147 mBox = static_cast<Octree *>(node)->_getWorldAABB(); 148 148 } -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityOctreeSceneManager.cpp
r870 r880 45 45 mIsHierarchicalCulling(false), 46 46 mViewCellsLoaded(false), 47 mUseViewCells(false), 48 mUseVisibilityFilter(false), 47 49 mCurrentViewCell(NULL), 48 mOldViewCell(NULL), 49 mUseViewCells(false) 50 mElementaryViewCell(NULL) 50 51 { 51 52 mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); … … 91 92 OGRE_DELETE(mHierarchyInterface); 92 93 CLEAR_CONTAINER(mObjects); 94 OGRE_DELETE(mCurrentViewCell); 93 95 } 94 96 //----------------------------------------------------------------------- … … 514 516 if (key == "UseViewCells") 515 517 { 516 if (mViewCellsLoaded) 517 { 518 mUseViewCells = *static_cast<const bool *>(val); 519 520 if (mUseViewCells) 521 { 522 SetObjectsVisible(false); 523 mCurrentViewCell = mOldViewCell = NULL; 524 } 525 else 526 { 527 SetObjectsVisible(true); 528 } 529 } 530 531 return true; 532 } 518 mUseViewCells = *static_cast<const bool *>(val); 519 520 // reset view cell 521 OGRE_DELETE(mCurrentViewCell); 522 if (mUseViewCells) 523 mCurrentViewCell = mViewCellsManager->GenerateViewCell(); 524 mElementaryViewCell = NULL; 525 // if using view cells, all objects are set to false initially 526 SetObjectsVisible(!mUseViewCells); 527 528 return true; 529 } 530 if (key == "UseVisibilityFilter") 531 { 532 mUseVisibilityFilter = *static_cast<const bool *>(val); 533 // set null =>recomputation of the pvs 534 mElementaryViewCell = NULL; 535 return true; 536 } 537 533 538 return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 534 539 setOption(key, val) || OctreeSceneManager::setOption(key, val); … … 864 869 // Also render any objects which have receive shadows disabled 865 870 OctreeSceneManager::renderObjects(pPriorityGrp->_getSolidPassesNoShadow(), true); 866 867 /*std::stringstream d;871 #if 0 872 std::stringstream d; 868 873 d << " solid size: " << (int)pPriorityGrp->_getSolidPasses().size() 869 874 << " solid no shadow size: " << (int)pPriorityGrp->_getSolidPassesNoShadow().size() 870 875 << "difspec size: " << (int)pPriorityGrp->_getSolidPassesDiffuseSpecular().size() 871 876 << " decal size: " << (int)pPriorityGrp->_getSolidPassesDecal().size(); 872 LogManager::getSingleton().logMessage(d.str());*/ 877 LogManager::getSingleton().logMessage(d.str()); 878 #endif 873 879 } 874 880 } … … 1027 1033 void VisibilityOctreeSceneManager::applyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, 1028 1034 const bool load) 1029 { GtpVisibilityPreprocessor::Debug << "here9 " << endl; 1030 // NOTE: should not happen, rather apply view cell representing unbounded space then 1031 if (!vc) return; 1035 { // NOTE: should not happen, rather apply view cell representing unbounded space then 1036 if (!vc) 1037 { 1038 // set everything visible for savety 1039 SetObjectsVisible(true); 1040 1041 return; 1042 } 1032 1043 1033 1044 GtpVisibilityPreprocessor::ObjectPvsMap::const_iterator oit, … … 1041 1052 OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance*>((*oit).first); 1042 1053 omi->GetMesh()->setVisible(load); 1043 GtpVisibilityPreprocessor::Debug << "here45 " << omi->GetId() << endl;1054 //GtpVisibilityPreprocessor::Debug << "here45 " << omi->GetId() << endl; 1044 1055 } 1045 1056 } … … 1048 1059 { 1049 1060 // for OGRE 1.2 1050 #ifdef OGRE121051 MovableObjectIterator mit = getMovableObjectIterator("Entity");1052 # else1061 //#ifdef OGRE12 1062 //MovableObjectIterator mit = getMovableObjectIterator("Entity"); 1063 #if 0 1053 1064 EntityIterator eit = getEntityIterator(); 1054 1065 … … 1060 1071 } 1061 1072 1073 #else 1074 GtpVisibilityPreprocessor::ObjectContainer::iterator it, it_end = mObjects.end(); 1075 1076 for (it = mObjects.begin(); it != it_end; ++ it) 1077 { 1078 OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(*it); 1079 Entity *ent = omi->GetMesh(); 1080 ent->setVisible(visible); 1081 } 1062 1082 #endif 1063 1083 } … … 1089 1109 void VisibilityOctreeSceneManager::updatePvs(Camera *cam) 1090 1110 { 1091 Ogre::LogManager::getSingleton().logMessage("here196");1092 1111 if (mViewCellsLoaded && mUseViewCells) 1093 1112 { 1094 GtpVisibilityPreprocessor::ViewCell *vc = 1095 mViewCellsManager->GetViewCell(OgreTypeConverter::ConvertFromOgre(cam->getDerivedPosition())); 1096 1097 std::stringstream d; d << "pos " << cam->getDerivedPosition() << "vc: " << vc; 1098 Ogre::LogManager::getSingleton().logMessage(d.str()); 1099 1100 // view cell changed => unload old objects and load new objects 1101 if (vc != mCurrentViewCell) 1102 { 1103 //-- unload old pvs 1104 if (mOldViewCell) 1105 { 1106 const bool load = false; 1107 1108 applyViewCellPvs(mOldViewCell, load); 1109 Ogre::LogManager::getSingleton().logMessage("here16"); 1110 } 1111 1112 mOldViewCell = mCurrentViewCell; 1113 1114 //-- load new pvs 1115 mCurrentViewCell = vc; 1116 const bool load = true; 1117 1118 applyViewCellPvs(mCurrentViewCell, load); 1119 Ogre::LogManager::getSingleton().logMessage("here106"); 1120 } 1113 const GtpVisibilityPreprocessor::Vector3 viewPoint = 1114 OgreTypeConverter::ConvertFromOgre(cam->getDerivedPosition()); 1115 1116 GtpVisibilityPreprocessor::ViewCell *newElementary = 1117 mViewCellsManager->GetViewCell(viewPoint); 1118 1119 // elementary view cell did not change => apply same pvs 1120 if (mElementaryViewCell == newElementary) 1121 return; 1122 1123 mElementaryViewCell = newElementary; 1124 1125 //-- unload old pvs 1126 applyViewCellPvs(mCurrentViewCell, false); 1127 1128 1129 //-- the new view cell 1130 1131 GtpVisibilityPreprocessor::ViewCell *viewCell; 1132 1133 1134 if (mUseVisibilityFilter) 1135 { 1136 //-- compute new filtered cell 1137 GtpVisibilityPreprocessor::PrVs prvs; 1138 mViewCellsManager->GetPrVS(viewPoint, prvs); 1139 viewCell = prvs.mViewCell; 1140 } 1141 else 1142 { 1143 viewCell = newElementary; 1144 } 1145 1146 //-- load new pvs 1147 applyViewCellPvs(viewCell, true); 1148 1149 // store pvs 1150 mCurrentViewCell->SetPvs(viewCell->GetPvs()); 1151 1152 // delete merge tree of filtered view cell 1153 if (mUseVisibilityFilter) 1154 mViewCellsManager->DeleteLocalMergeTree(viewCell); 1121 1155 } 1122 1156 }
Note: See TracChangeset
for help on using the changeset viewer.