| 680 | } |
| 681 | |
| 682 | void DecalRoad::prepRenderImage( SceneRenderState* state ) |
| 683 | { |
| 684 | PROFILE_SCOPE( DecalRoad_prepRenderImage ); |
| 685 | |
| 686 | if ( mNodes.size() <= 1 || |
| 687 | mBatches.size() == 0 || |
| 688 | !mMaterialInst || |
| 689 | state->isShadowPass() ) |
| 690 | return; |
| 691 | |
| 692 | // If we don't have a material instance after the override then |
| 693 | // we can skip rendering all together. |
| 694 | BaseMatInstance *matInst = state->getOverrideMaterial(mMaterialInst); |
| 695 | if ( !matInst ) |
| 696 | return; |
| 697 | |
| 698 | RenderPassManager *renderPass = state->getRenderPass(); |
| 699 | |
| 700 | // Debug RenderInstance |
| 701 | // Only when editor is open. |
| 702 | if ( smEditorOpen ) |
| 703 | { |
| 704 | ObjectRenderInst *ri = renderPass->allocInst<ObjectRenderInst>(); |
| 705 | ri->type = RenderPassManager::RIT_Editor; |
| 706 | ri->renderDelegate.bind( this, &DecalRoad::_debugRender ); |
| 707 | state->getRenderPass()->addInst( ri ); |
| 708 | } |
| 709 | |
| 710 | // Normal Road RenderInstance |
| 711 | // Always rendered when the editor is not open |
| 712 | // otherwise obey the smShowRoad flag |
| 713 | if ( !smShowRoad && smEditorOpen ) |
| 714 | return; |
| 715 | |
| 716 | const Frustum &frustum = state->getCameraFrustum(); |
| 717 | |
| 718 | MeshRenderInst coreRI; |
| 719 | coreRI.clear(); |
| 720 | coreRI.objectToWorld = &MatrixF::Identity; |
| 721 | coreRI.worldToCamera = renderPass->allocSharedXform(RenderPassManager::View); |
| 722 | |
| 723 | MatrixF *tempMat = renderPass->allocUniqueXform( MatrixF( true ) ); |
| 724 | MathUtils::getZBiasProjectionMatrix( gDecalBias, frustum, tempMat ); |
| 725 | coreRI.projection = tempMat; |
| 726 | |
| 727 | coreRI.type = RenderPassManager::RIT_DecalRoad; |
| 728 | coreRI.vertBuff = &mVB; |
| 729 | coreRI.primBuff = &mPB; |
| 730 | coreRI.matInst = matInst; |
| 731 | |
| 732 | // Make it the sort distance the max distance so that |
| 733 | // it renders after all the other opaque geometry in |
| 734 | // the deferred bin. |
| 735 | coreRI.sortDistSq = F32_MAX; |
| 736 | |
| 737 | // If we need lights then set them up. |
| 738 | if ( matInst->isForwardLit() && !coreRI.lights[0]) |
| 739 | { |
nothing calls this directly
no test coverage detected