| 491 | } |
| 492 | |
| 493 | void TerrainBlock::_renderBlock( SceneRenderState *state ) |
| 494 | { |
| 495 | PROFILE_SCOPE( TerrainBlock_RenderBlock ); |
| 496 | |
| 497 | if (!mFile) |
| 498 | return; |
| 499 | |
| 500 | // Prevent rendering shadows if feature is disabled |
| 501 | if ( !mCastShadows && state->isShadowPass() ) |
| 502 | return; |
| 503 | |
| 504 | MatrixF worldViewXfm = state->getWorldViewMatrix(); |
| 505 | worldViewXfm.mul( getRenderTransform() ); |
| 506 | |
| 507 | MatrixF worldViewProjXfm = state->getProjectionMatrix(); |
| 508 | worldViewProjXfm.mul( worldViewXfm ); |
| 509 | |
| 510 | const MatrixF &objectXfm = getRenderWorldTransform(); |
| 511 | |
| 512 | Point3F objCamPos = state->getDiffuseCameraPosition(); |
| 513 | objectXfm.mulP( objCamPos ); |
| 514 | |
| 515 | // Get the shadow material. |
| 516 | if ( !mDefaultMatInst ) |
| 517 | mDefaultMatInst = TerrainCellMaterial::getShadowMat(); |
| 518 | |
| 519 | // Make sure we have a base material. |
| 520 | if ( !mBaseMaterial ) |
| 521 | { |
| 522 | mBaseMaterial = new TerrainCellMaterial(); |
| 523 | mBaseMaterial->init( this, 0, false, false, true ); |
| 524 | } |
| 525 | |
| 526 | // Did the detail layers change? |
| 527 | if ( mDetailsDirty ) |
| 528 | { |
| 529 | _updateMaterials(); |
| 530 | mDetailsDirty = false; |
| 531 | } |
| 532 | |
| 533 | // If the layer texture has been cleared or is |
| 534 | // dirty then update it. |
| 535 | if ( mLayerTex.isNull() || mLayerTexDirty ) |
| 536 | _updateLayerTexture(); |
| 537 | |
| 538 | // If the layer texture is dirty or we lost the base |
| 539 | // texture then regenerate it. |
| 540 | if ( mLayerTexDirty || mBaseTex.isNull() ) |
| 541 | { |
| 542 | _updateBaseTexture( false ); |
| 543 | mLayerTexDirty = false; |
| 544 | } |
| 545 | |
| 546 | static Vector<TerrCell*> renderCells; |
| 547 | renderCells.clear(); |
| 548 | |
| 549 | mCell->cullCells( state, |
| 550 | objCamPos, |
nothing calls this directly
no test coverage detected