Changeset 143
- Timestamp:
- 06/21/05 18:14:30 (20 years ago)
- Location:
- trunk/VUT
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibility/include/DummyQueryManager.h
r65 r143 25 25 InfoContainer<NodeInfo> *visibleNodes, 26 26 InfoContainer<MeshInfo> *visibleGeometry, 27 bool relativeVisibility= false27 bool projectedPixels = false 28 28 ); 29 29 … … 35 35 InfoContainer<NodeInfo> *visibleNodes, 36 36 InfoContainer<MeshInfo> *visibleGeometry, 37 bool relativeVisibility= false37 bool projectedPixels = false 38 38 ); 39 39 -
trunk/VUT/GtpVisibility/include/QueryManager.h
r130 r143 41 41 If NULL no visible meshes are not evaluated. 42 42 43 @param relativeVisibilityIf true the visibility member for43 @param projectedPixels If true the visibility member for 44 44 NodeInfo and MeshInfo represent relative visibility; i.e. the number of visible 45 45 pixels divided by the the number of projected pixels. … … 51 51 InfoContainer<NodeInfo> *visibleNodes, 52 52 InfoContainer<MeshInfo> *visibleGeometry, 53 bool relativeVisibility= false53 bool projectedPixels = false 54 54 ) = 0; 55 55 … … 62 62 InfoContainer<NodeInfo> *visibleNodes, 63 63 InfoContainer<MeshInfo> *visibleGeometry, 64 bool relativeVisibility= false64 bool projectedPixels = false 65 65 ) = 0; 66 66 -
trunk/VUT/GtpVisibility/include/VisibilityInfo.h
r141 r143 14 14 { 15 15 public: 16 NodeInfo(HierarchyNode *node,const float v): mNode(node), mVisibility(v) {} 16 NodeInfo(HierarchyNode *node, const int projectedPixels, const int visiblePixels): 17 mNode(node)//, mProjectedPixels(projectedPixels), mVisiblePixels(visiblePixels) 18 {} 17 19 18 float GetVisibility() const {return mVisibility;} 19 void SetVisibility(float vis) { mVisibility = vis;} 20 bool operator<(const NodeInfo& rhs) const {return mNode < rhs.mNode;} 21 //bool operator>(const NodeInfo& rhs) const {return mNode > rhs.mNode;} 22 //bool operator==(const NodeInfo& rhs) const {return mNode == rhs.mNode;} 20 int GetVisiblePixels() const {return mVisiblePixels;} 21 int GetProjectedPixels() const {return mProjectedPixels;} 22 23 void SetVisiblePixels(int vis) {mVisiblePixels = vis;} 24 void SetProjectedPixels(int vis) {mProjectedPixels = vis;} 25 26 void SetNode(HierarchyNode *node) {mNode = node;} 27 HierarchyNode *GetNode() const {return mNode;} 28 29 //bool operator<(const NodeInfo& rhs) const {return mNode < rhs.mNode;} 23 30 24 31 protected: … … 26 33 /** pointer to the scene node */ 27 34 HierarchyNode *mNode; 28 /** node visibility can either be a number of visible pixels or relative 29 number of visible pixels (if the hardware queries will provide the 30 total number of ratsterized pixels */ 31 float mVisibility; 35 36 int mVisiblePixels; 37 int mProjectedPixels; 32 38 }; 33 39 … … 37 43 { 38 44 public: 39 MeshInfo(Mesh *mesh, const float v): mMesh(mesh), mVisibility(v) {} 45 MeshInfo(Mesh *mesh, const int projectedPixels, const int visiblePixels): 46 mMesh(mesh), mProjectedPixels(projectedPixels), mVisiblePixels(visiblePixels) 47 {} 40 48 41 float GetVisibility() const {return mVisibility;} 42 void SetVisibility(float vis) { mVisibility = vis;} 49 int GetVisiblePixels() const {return mVisiblePixels;} 50 int GetProjectedPixels() const {return mProjectedPixels;} 51 52 void SetVisiblePixels(float vis) { mVisiblePixels = vis;} 53 void SetProjectedPixels(float vis) { mProjectedPixels = vis;} 54 55 Mesh *GetMesh() const {return mMesh;} 56 void SetMesh(Mesh *mesh) {mMesh = mesh;} 43 57 44 58 bool operator<(const MeshInfo& rhs) const {return mMesh < rhs.mMesh;} … … 51 65 */ 52 66 Mesh *mMesh; 53 /** Node visibility can either be a number of visible pixels or relative 54 number of visible pixels (if the hardware queries will provide the 55 total number of ratsterized pixels. 56 */ 57 float mVisibility; 67 68 int mVisiblePixels; 69 int mProjectedPixels; 58 70 }; 59 71 60 72 //TODO: this define shall be replaced by template typedef 61 //#define InfoContainer std::vector62 #define InfoContainer std::set73 #define InfoContainer std::vector 74 //#define InfoContainer std::set 63 75 }; 64 76 -
trunk/VUT/GtpVisibility/src/DummyQueryManager.cpp
r141 r143 11 11 InfoContainer<NodeInfo> *visibleNodes, 12 12 InfoContainer<MeshInfo> *visibleGeometry, 13 bool relativeVisibility13 bool projectedPixels 14 14 ) 15 15 { 16 visibleNodes-> insert(NodeInfo(mHierarchyInterface->GetSceneRoot(), 1.0f));16 visibleNodes->push_back(NodeInfo(mHierarchyInterface->GetSceneRoot(), 0, 0)); 17 17 18 18 // HierarchyInterface::MeshIterator *mi = … … 30 30 InfoContainer<NodeInfo> *visibleNodes, 31 31 InfoContainer<MeshInfo> *visibleGeometry, 32 bool relativeVisibility32 bool projectedPixels 33 33 ) 34 34 { 35 visibleNodes-> insert(NodeInfo(mHierarchyInterface->GetSceneRoot(), 1.0f));35 visibleNodes->push_back(NodeInfo(mHierarchyInterface->GetSceneRoot(), 0, 0)); 36 36 37 37 // HierarchyInterface::MeshIterator *mi = -
trunk/VUT/Ogre/include/OgrePlatformQueryManager.h
r140 r143 31 31 If NULL no visible meshes are not evaluated. 32 32 33 @param relativeVisibilityIf true the visibility member for33 @param projectedPixels If true the visibility member for 34 34 NodeInfo and MeshInfo represent relative visibility; i.e. the number of visible 35 35 pixels divided by the the number of projected pixels. … … 41 41 InfoContainer<GtpVisibility::NodeInfo> *visibleNodes, 42 42 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 43 bool relativeVisibility= false43 bool projectedPixels = false 44 44 ); 45 45 … … 52 52 InfoContainer<GtpVisibility::NodeInfo> *visibleNodes, 53 53 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 54 bool relativeVisibility= false54 bool projectedPixels = false 55 55 ); 56 56 -
trunk/VUT/Ogre/src/OgrePlatformQueryManager.cpp
r141 r143 23 23 InfoContainer<GtpVisibility::NodeInfo> *visibleNodes, 24 24 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 25 bool relativeVisibility)25 bool projectedPixels) 26 26 { 27 27 // we need access to the scene manager and the rendersystem … … 68 68 */ 69 69 // for relative visibility we need 2 rendering passes 70 int n = relativeVisibility? 2 : 1;70 int n = projectedPixels ? 2 : 1; 71 71 72 72 for (int i=0; i<n; ++i) … … 118 118 (*visQueryIt)->GetQueryResult(visiblePixels, true); 119 119 120 float vis = (float)visiblePixels;121 bool isVisible = visiblePixels >0;122 123 if ( relativeVisibility)120 int visiblePixels = visiblePixels; 121 int projectedPixels = 0; 122 123 if (projectedPixels) 124 124 { 125 125 (*projQueryIt)->GetQueryResult(visiblePixels, true); 126 126 127 if (visiblePixels > 0) 128 { 129 vis /= (float) visiblePixels; 130 } 127 mProjectedPixels = visiblePixels; 128 131 129 ++projQueryIt; 132 130 } … … 136 134 // nodes with visibilty 0 in queue: 137 135 // happens if node is intersected by near plane 138 if (isVisible) 139 { 140 insertNode = visibleNodes->insert(GtpVisibility::NodeInfo(*nodeIt, vis)); 141 142 if (!insertNode.second) // element already in list 143 { 144 //LogManager::getSingleton().logMessage("element already in list"); 145 (*insertNode.first).SetVisibility((*insertNode.first).GetVisibility() + vis); 146 147 if (relativeVisibility) // relative visibility between zero and one 148 { 149 (*insertNode.first).SetVisibility((*insertNode.first).GetVisibility() * 0.5); 150 } 151 } 136 if (visiblePixels > 0) 137 { 138 visibleNodes->push_back(GtpVisibility::NodeInfo(*nodeIt, visiblePixels, projectedPixels)); 152 139 } 153 140 } … … 160 147 (*visQueryIt)->GetQueryResult(visiblePixels, true); 161 148 162 163 float vis = (float)visiblePixels; 164 bool isVisible = visiblePixels > 0; 165 166 if (relativeVisibility) 149 int visiblePixels = visiblePixels; 150 int projectedPixels = 0; 151 152 if (projectedPixels) 167 153 { 168 154 (*projQueryIt)->GetQueryResult(visiblePixels, true); 169 155 170 if (visiblePixels) 171 { 172 vis /= (float) visiblePixels; 173 } 156 mProjectedPixels = visiblePixels; 157 174 158 ++projQueryIt; 175 159 } … … 181 165 if (isVisible) 182 166 { 183 insertGeom = visibleGeometry->insert(GtpVisibility::MeshInfo(*geometryIt, vis));184 if (!insertGeom.second) // element already in list185 {186 //LogManager::getSingleton().logMessage("element already in list"); 187 (*insertGeom.first).SetVisibility((*insertGeom.first).GetVisibility() + vis); 188 189 if (relativeVisibility) // relative visibility between zero and one 190 { 191 (*insertGeom.first).SetVisibility((*insertGeom.first).GetVisibility() * 0.5);192 193 } 194 } 195 } 196 167 visibleGeometry->push_back(GtpVisibility::MeshInfo(*geometryIt,visiblePixels, projectedPixels)); 168 } 169 } 170 171 } 172 //----------------------------------------------------------------------- 173 inline bool nodeinfo_eq(const GtpVisibility::NodeInfo &info1, const GtpVisibility::NodeInfo &info2) 174 { 175 return info1.GetNode() == info2.GetNode(); 176 } 177 //----------------------------------------------------------------------- 178 inline bool meshinfo_eq(const GtpVisibility::MeshInfo &info1, const GtpVisibility::MeshInfo &info2) 179 { 180 return info1.GetMesh() == info2.GetMesh(); 197 181 } 198 182 //----------------------------------------------------------------------- … … 200 184 InfoContainer<GtpVisibility::NodeInfo> *visibleNodes, 201 185 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 202 bool relativeVisibility)186 bool projectedPixels) 203 187 { 204 188 SceneManager *sm = dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface)->GetSceneManager(); … … 237 221 LogManager::getSingleton().logMessage(d.str()); 238 222 239 ComputeCameraVisibility(*cam, visibleNodes, visibleGeometry, relativeVisibility);240 223 ComputeCameraVisibility(*cam, visibleNodes, visibleGeometry, projectedPixels); 224 241 225 //mViewport->getTarget()->update(); for(int j=0; j<10000000; j++) printf("HAAHHAHAHAHAH"); 242 226 … … 248 232 } 249 233 250 251 234 // reset camera 252 235 mViewport->setCamera(savedCam); 236 237 // --- single out duplicates 238 239 // before duplicates can be deleted we have to add up visibility 240 241 // --- visible nodes 242 sort(visibleNodes->begin(), visibleNodes->end()); 243 InfoContainer<GtpVisibility::NodeInfo>::iterator visibleNodesIt, 244 visibleNodesIt_end = visibleNodes->end(); 245 246 GtpVisibility::NodeInfo *nodeInfo = NULL; 247 248 for (visibleNodesIt = visibleNodes->begin(); visibleNodesIt != visibleNodesIt_end; 249 ++visibleNodesIt); 250 { 251 if (!nodeInfo || (nodeInfo->GetNode() != (*visibleNodesIt).GetNode())) 252 { 253 nodeInfo = &(*visibleNodesIt); 254 } 255 else 256 { 257 // add visibility 258 nodeInfo->SetVisibility(nodeInfo->GetVisiblePixels() + 259 (*visibleNodesIt).GetVisiblePixels()); 260 } 261 262 } 263 264 // now delete duplicates 265 visibleNodes->erase( std::unique(visibleNodes->begin(), 266 visibleNodes->end(), nodeinfo_eq), visibleNodes->end()); 267 268 // --- visible geometry 269 sort(visibleGeometry->begin(), visibleGeometry->end()); 270 InfoContainer<GtpVisibility::MeshInfo>::iterator visibleGeomIt, 271 visibleGeomIt_end = visibleGeometry->end(); 272 273 GtpVisibility::MeshInfo *geomInfo = NULL; 274 275 for (visibleGeomIt = visibleGeometry->begin(); visibleGeomIt != visibleGeomIt_end; 276 ++visibleGeomIt); 277 { 278 if (!geomInfo || (geomInfo->GetMesh() != (*visibleGeomIt).GetMesh())) 279 { 280 geomInfo = &(*visibleGeomIt); 281 } 282 else // info points to equal mesh 283 { 284 // add visibility 285 geomInfo->SetVisibility(geomInfo->GetVisiblePixels() + 286 (*visibleGeomIt).GetVisiblePixels()); 287 } 288 } 289 290 // now delete duplicates 291 visibleGeometry->erase(std::unique(visibleGeometry->begin(), 292 visibleGeometry->end(), meshinfo_eq), visibleGeometry->end()); 293 253 294 } 254 295 //----------------------------------------------------------------------- -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
r141 r143 353 353 } 354 354 //----------------------------------------------------------------------- 355 void TerrainFrameListener::ApplyVisibilityQuery(bool fromPoint, bool relativeVisibility)355 void TerrainFrameListener::ApplyVisibilityQuery(bool fromPoint, bool projectedPixels) 356 356 { 357 357 InfoContainer<GtpVisibility::NodeInfo> visibleNodes; … … 362 362 mVisibilityManager->GetQueryManager()-> 363 363 ComputeFromPointVisibility(mCamNode->getPosition(), &visibleNodes, 364 &visibleGeometry, relativeVisibility);364 &visibleGeometry, projectedPixels); 365 365 } 366 366 else 367 367 { 368 368 mVisibilityManager->GetQueryManager()->ComputeCameraVisibility(*mCamera, 369 &visibleNodes, &visibleGeometry, relativeVisibility);369 &visibleNodes, &visibleGeometry, projectedPixels); 370 370 } 371 371 … … 377 377 for (geomIt = visibleGeometry.begin(); geomIt != geomIt_end; ++geomIt) 378 378 { 379 averageGeometryVis += (*geomIt).GetVisib ility();380 381 std::stringstream d; d << "Geometry visibility: " << (*geomIt).GetVisib ility();379 averageGeometryVis += (*geomIt).GetVisiblePixels(); 380 381 std::stringstream d; d << "Geometry visibility: " << (*geomIt).GetVisiblePixels(); 382 382 LogManager::getSingleton().logMessage(d.str()); 383 383 } … … 387 387 for (nodesIt = visibleNodes.begin(); nodesIt != nodesIt_end; ++nodesIt) 388 388 { 389 averageNodeVis += (*nodesIt).GetVisib ility();390 391 std::stringstream d; d << "Node visibility: " << (*nodesIt).GetVisib ility();389 averageNodeVis += (*nodesIt).GetVisiblePixels(); 390 391 std::stringstream d; d << "Node visibility: " << (*nodesIt).GetVisiblePixels(); 392 392 LogManager::getSingleton().logMessage(d.str()); 393 393 } … … 405 405 //-- visibility queries stats 406 406 int idx = fromPoint ? 1 : 0; 407 idx += relativeVisibility? 2 : 0;407 idx += projectedPixels ? 2 : 0; 408 408 409 409 sprintf(str, ": %s", queryTypeCaptions[idx].c_str()); -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h
r139 r143 117 117 and their visibility information. 118 118 @param fromnPoint if query should be from point or from camera 119 @param relativeVisibilityif query should return number of visible pixels or the ratio119 @param projectedPixels if query should return number of visible pixels or the ratio 120 120 visible pixels / projected pixels. 121 121 */ 122 void ApplyVisibilityQuery(bool fromPoint, bool relativeVisibility);122 void ApplyVisibilityQuery(bool fromPoint, bool projectedPixels); 123 123 124 124 void toggleShowQueryStats();
Note: See TracChangeset
for help on using the changeset viewer.