Changeset 143 for trunk/VUT/Ogre/src
- Timestamp:
- 06/21/05 18:14:30 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 //-----------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.