| 349 | } |
| 350 | |
| 351 | void TerrainBlock::_renderBlock( SceneRenderState *state ) |
| 352 | { |
| 353 | PROFILE_SCOPE( TerrainBlock_RenderBlock ); |
| 354 | |
| 355 | // Prevent rendering shadows if feature is disabled |
| 356 | if ( !mCastShadows && state->isShadowPass() ) |
| 357 | return; |
| 358 | |
| 359 | MatrixF worldViewXfm = state->getWorldViewMatrix(); |
| 360 | worldViewXfm.mul( getRenderTransform() ); |
| 361 | |
| 362 | MatrixF worldViewProjXfm = state->getProjectionMatrix(); |
| 363 | worldViewProjXfm.mul( worldViewXfm ); |
| 364 | |
| 365 | const MatrixF &objectXfm = getRenderWorldTransform(); |
| 366 | |
| 367 | Point3F objCamPos = state->getDiffuseCameraPosition(); |
| 368 | objectXfm.mulP( objCamPos ); |
| 369 | |
| 370 | // Get the shadow material. |
| 371 | if ( !mDefaultMatInst ) |
| 372 | mDefaultMatInst = TerrainCellMaterial::getShadowMat(); |
| 373 | |
| 374 | // Make sure we have a base material. |
| 375 | if ( !mBaseMaterial ) |
| 376 | { |
| 377 | mBaseMaterial = new TerrainCellMaterial(); |
| 378 | mBaseMaterial->init( this, 0, false, false, true ); |
| 379 | } |
| 380 | |
| 381 | // Did the detail layers change? |
| 382 | if ( mDetailsDirty ) |
| 383 | { |
| 384 | _updateMaterials(); |
| 385 | mDetailsDirty = false; |
| 386 | } |
| 387 | |
| 388 | // If the layer texture has been cleared or is |
| 389 | // dirty then update it. |
| 390 | if ( mLayerTex.isNull() || mLayerTexDirty ) |
| 391 | _updateLayerTexture(); |
| 392 | |
| 393 | // If the layer texture is dirty or we lost the base |
| 394 | // texture then regenerate it. |
| 395 | if ( mLayerTexDirty || mBaseTex.isNull() ) |
| 396 | { |
| 397 | _updateBaseTexture( false ); |
| 398 | mLayerTexDirty = false; |
| 399 | } |
| 400 | |
| 401 | static Vector<TerrCell*> renderCells; |
| 402 | renderCells.clear(); |
| 403 | |
| 404 | mCell->cullCells( state, |
| 405 | objCamPos, |
| 406 | &renderCells ); |
| 407 | |
| 408 | RenderPassManager *renderPass = state->getRenderPass(); |
nothing calls this directly
no test coverage detected