Changeset 1595 for GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src
- Timestamp:
- 10/10/06 01:27:11 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBoundingBoxConverter.cpp
r1296 r1595 9 9 namespace Ogre 10 10 { 11 //-------------------------------------------------------------------------12 OgreBoundingBoxConverter::OgreBoundingBoxConverter(OctreeSceneManager *sm):13 mOctSceneMgr(sm), mKdSceneMgr(0)14 {15 }16 //-------------------------------------------------------------------------17 OgreBoundingBoxConverter::OgreBoundingBoxConverter(KdTreeSceneManager *sm):18 mOctSceneMgr(0), mKdSceneMgr(sm)19 {20 }21 //-------------------------------------------------------------------------22 bool OgreBoundingBoxConverter::IdentifyObjects(const GtpVisibilityPreprocessor::IndexedBoundingBoxContainer &iboxes,23 GtpVisibilityPreprocessor::ObjectContainer &objects) const24 {25 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer::26 const_iterator iit, iit_end = iboxes.end();27 28 for (iit = iboxes.begin(); iit != iit_end; ++ iit)29 {30 const GtpVisibilityPreprocessor::AxisAlignedBox3 box = (*iit).second;31 const AxisAlignedBox currentBox = OgreTypeConverter::ConvertToOgre(box);32 33 Entity *ent = FindCorrespondingObject(currentBox);34 35 // create new mesh instance36 OgreMeshInstance *omi = new OgreMeshInstance(ent);37 omi->SetId((*iit).first);38 objects.push_back(omi);39 }40 41 return true;42 }43 //-------------------------------------------------------------------------44 inline static AxisAlignedBox EnlargeBox(const AxisAlignedBox &box)45 {46 const float eps = 1e-3f;47 const Vector3 veps(eps, eps, eps);48 49 Vector3 max = box.getMaximum();50 Vector3 min = box.getMinimum();51 52 return AxisAlignedBox(min - veps, max + veps);53 }54 //-----------------------------------------------------------------------55 Entity *OgreBoundingBoxConverter::FindCorrespondingObject(const AxisAlignedBox &box) const56 {57 list<SceneNode *> sceneNodeList;58 AxisAlignedBox mybox = EnlargeBox(box);59 //AxisAlignedBox dummy(Vector3(-50000, -50000, -50000), Vector3(50000, 50000, 50000));60 61 // get intersecting scene nodes62 if (mOctSceneMgr)63 mOctSceneMgr->findNodesIn(mybox, sceneNodeList, NULL);64 else if (mKdSceneMgr)65 mKdSceneMgr->findNodesIn(mybox, sceneNodeList, NULL);66 else67 OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, "Bounding Box Converter cannot "68 "find appropriate scene manager.", "OgreBoundingBoxConverter::FindCorrespondingObject");69 70 71 list<SceneNode *>::const_iterator sit, sit_end = sceneNodeList.end();72 73 // minimal overlap74 float overlap = 0;//1e-6;75 76 Entity *bestFittingObj = NULL;77 float bestFit = overlap;78 79 // perfect fit threshold80 const float thresh = 1.0 - GtpVisibilityPreprocessor::Limits::Small;81 11 82 12 83 // find the bbox which is closest to the current bbox84 for (sit = sceneNodeList.begin(); sit != sceneNodeList.end(); ++ sit)85 {86 SceneNode *sn = *sit;87 SceneNode::ObjectIterator oit = sn->getAttachedObjectIterator();88 89 while (oit.hasMoreElements())90 {91 MovableObject *mo = oit.getNext();92 93 // we are only interested in scene entities94 if (mo->getMovableType() != "Entity")95 {96 continue;97 }98 99 const AxisAlignedBox bbox = EnlargeBox(mo->getWorldBoundingBox());100 101 102 // compute measure how much aabbs overlap103 overlap = RatioOfOverlap(OgreTypeConverter::ConvertFromOgre(mybox),104 OgreTypeConverter::ConvertFromOgre(bbox));105 106 if (overlap > bestFit)107 {108 bestFit = overlap;109 110 bestFittingObj = static_cast<Entity *>(mo);111 112 // perfect fit => object found, early exit113 if (overlap >= thresh)114 return bestFittingObj;115 }116 }117 }118 119 if (0)120 {121 std::stringstream d;122 if (bestFittingObj)123 d << "best fit: " << bestFit;124 else125 d << "warning, objects do not fit\n" << box;126 127 Ogre::LogManager::getSingleton().logMessage(d.str());128 }129 130 return bestFittingObj;131 }132 13 133 14 } -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBvHierarchySceneManager.cpp
r1593 r1595 27 27 { 28 28 29 BvHierarchySceneManager::BvHierarchySceneManager(const String& name, GtpVisibility::VisibilityManager *vm): 29 BvHierarchySceneManager::BvHierarchySceneManager(const String& name, 30 GtpVisibility::VisibilityManager *vm): 30 31 SceneManager(name), 31 32 mVisibilityManager(vm), … … 1323 1324 // converter between view cell ids and Ogre entites 1324 1325 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes; 1325 #if 0 1326 OgreBoundingBoxConverter bconverter(this); 1327 1328 // load the view cells assigning the found objects to the pvss1326 BvhBoundingBoxConverter bconverter(this); 1327 1328 // load the view cells and assigns the objects in the pvs to 1329 // the scene objects using the bounding boxes 1329 1330 mViewCellsManager = 1330 1331 GtpVisibilityPreprocessor::ViewCellsManager::LoadViewCells(filename, &mObjects, false, &bconverter); 1331 1332 1332 1333 return (mViewCellsManager != NULL); 1333 #endif1334 1334 } 1335 1335 //------------------------------------------------------------------------- 1336 1336 void BvHierarchySceneManager::applyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, 1337 1337 const bool load) 1338 { // NOTE: should not happen, rather apply view cell representing unbounded space then 1338 { // NOTE: should not happen, rather apply view cell 1339 // representing unbounded space then 1339 1340 if (!vc) 1340 { 1341 // set everything visible for savety 1341 { // set everything visible for savety 1342 1342 SetObjectsVisible(true); 1343 1344 1343 return; 1345 1344 } … … 1348 1347 oit_end = vc->GetPvs().mEntries.end(); 1349 1348 1349 ////////////// 1350 1350 //-- PVS of view cell 1351 1351 for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp
r1593 r1595 1322 1322 // converter between view cell ids and Ogre entites 1323 1323 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes; 1324 OgreBoundingBoxConverter bconverter(this);1324 KdTreeBoundingBoxConverter bconverter(this); 1325 1325 1326 1326 // load the view cells assigning the found objects to the pvss -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
r1593 r1595 593 593 // reset view cell 594 594 OGRE_DELETE(mCurrentViewCell); 595 595 596 596 if (mUseViewCells) 597 597 { … … 601 601 mElementaryViewCell = NULL; 602 602 603 // if usingview cells, all objects are set to false initially603 // if we use view cells, all objects are set to false initially 604 604 SetObjectsVisible(!mUseViewCells); 605 605 } … … 1060 1060 // converter between view cell ids and Ogre entites 1061 1061 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes; 1062 O greBoundingBoxConverter bconverter(this);1062 OctreeBoundingBoxConverter bconverter(this); 1063 1063 1064 1064 // load the view cells assigning the found objects to the pvss -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformHierarchyInterface.cpp
r1495 r1595 125 125 { 126 126 // create new query if there is no query left 127 if (mCurrentTestIdx == mOcclusionQueries.size())127 if (mCurrentTestIdx == (int)mOcclusionQueries.size()) 128 128 { 129 129 mOcclusionQueries.push_back(new PlatformOcclusionQuery(mRenderSystem)); 130 } 131 132 std::stringstream d;133 d << "resizing queries: " << (int)mOcclusionQueries.size() << std::endl;134 LogManager::getSingleton().logMessage(d.str());130 131 std::stringstream d; 132 d << "resizing queries: " << (int)mOcclusionQueries.size() << std::endl; 133 LogManager::getSingleton().logMessage(d.str()); 134 } 135 135 136 136 return mOcclusionQueries[mCurrentTestIdx ++];
Note: See TracChangeset
for help on using the changeset viewer.