| 263 | |
| 264 | |
| 265 | void Forest::_renderCellBounds( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat ) |
| 266 | { |
| 267 | PROFILE_SCOPE( Forest_RenderCellBounds ); |
| 268 | |
| 269 | if ( overrideMat ) |
| 270 | return; |
| 271 | |
| 272 | GFXTransformSaver saver; |
| 273 | |
| 274 | MatrixF projBias(true); |
| 275 | const Frustum frustum = GFX->getFrustum(); |
| 276 | MathUtils::getZBiasProjectionMatrix( 0.001f, frustum, &projBias ); |
| 277 | GFX->setProjectionMatrix( projBias ); |
| 278 | |
| 279 | VectorF extents; |
| 280 | Point3F pos; |
| 281 | |
| 282 | // Get top level cells |
| 283 | Vector<ForestCell*> cellStack; |
| 284 | mData->getCells( &cellStack ); |
| 285 | |
| 286 | // Holds child cells we need to render as we encounter them. |
| 287 | Vector<ForestCell*> frontier; |
| 288 | |
| 289 | GFXDrawUtil *drawer = GFX->getDrawUtil(); |
| 290 | |
| 291 | GFXStateBlockDesc desc; |
| 292 | desc.setZReadWrite( true, false ); |
| 293 | desc.setBlend( true ); |
| 294 | desc.setFillModeWireframe(); |
| 295 | |
| 296 | while ( !cellStack.empty() ) |
| 297 | { |
| 298 | while ( !cellStack.empty() ) |
| 299 | { |
| 300 | const ForestCell *cell = cellStack.last(); |
| 301 | cellStack.pop_back(); |
| 302 | |
| 303 | Box3F box = cell->getBounds(); |
| 304 | |
| 305 | drawer->drawCube( desc, box, ColorI( 0, 255, 0 ) ); |
| 306 | |
| 307 | RectF rect = cell->getRect(); |
| 308 | |
| 309 | box.minExtents.set( rect.point.x, rect.point.y, box.minExtents.z ); |
| 310 | box.maxExtents.set( rect.point.x + rect.extent.x, rect.point.y + rect.extent.y, box.minExtents.z ); |
| 311 | |
| 312 | drawer->drawCube( desc, box, ColorI::RED ); |
| 313 | |
| 314 | // If this cell has children, add them to the frontier. |
| 315 | if ( !cell->isLeaf() ) |
| 316 | cell->getChildren( &frontier ); |
| 317 | } |
| 318 | |
| 319 | // Now the frontier becomes the cellStack and we empty the frontier. |
| 320 | cellStack = frontier; |
| 321 | frontier.clear(); |
| 322 | } |
nothing calls this directly
no test coverage detected