| 810 | } |
| 811 | |
| 812 | void MeshRoad::prepRenderImage( SceneRenderState* state ) |
| 813 | { |
| 814 | if ( mNodes.size() <= 1 ) |
| 815 | return; |
| 816 | |
| 817 | RenderPassManager *renderPass = state->getRenderPass(); |
| 818 | |
| 819 | // Normal Road RenderInstance |
| 820 | // Always rendered when the editor is not open |
| 821 | // otherwise obey the smShowRoad flag |
| 822 | if ( smShowRoad || !smEditorOpen ) |
| 823 | { |
| 824 | MeshRenderInst coreRI; |
| 825 | coreRI.clear(); |
| 826 | coreRI.objectToWorld = &MatrixF::Identity; |
| 827 | coreRI.worldToCamera = renderPass->allocSharedXform(RenderPassManager::View); |
| 828 | coreRI.projection = renderPass->allocSharedXform(RenderPassManager::Projection); |
| 829 | coreRI.type = RenderPassManager::RIT_Mesh; |
| 830 | |
| 831 | BaseMatInstance *matInst; |
| 832 | for ( U32 i = 0; i < SurfaceCount; i++ ) |
| 833 | { |
| 834 | matInst = state->getOverrideMaterial( mMatInst[i] ); |
| 835 | if ( !matInst ) |
| 836 | continue; |
| 837 | |
| 838 | // Get the lights if we haven't already. |
| 839 | if ( matInst->isForwardLit() && !coreRI.lights[0] ) |
| 840 | { |
| 841 | LightQuery query; |
| 842 | query.init( getWorldSphere() ); |
| 843 | query.getLights( coreRI.lights, 8 ); |
| 844 | } |
| 845 | |
| 846 | MeshRenderInst *ri = renderPass->allocInst<MeshRenderInst>(); |
| 847 | *ri = coreRI; |
| 848 | |
| 849 | // Currently rendering whole road, fix to cull and batch |
| 850 | // per segment. |
| 851 | |
| 852 | // Set the correct material for rendering. |
| 853 | ri->matInst = matInst; |
| 854 | ri->vertBuff = &mVB[i]; |
| 855 | ri->primBuff = &mPB[i]; |
| 856 | |
| 857 | ri->prim = renderPass->allocPrim(); |
| 858 | ri->prim->type = GFXTriangleList; |
| 859 | ri->prim->minIndex = 0; |
| 860 | ri->prim->startIndex = 0; |
| 861 | ri->prim->numPrimitives = mTriangleCount[i]; |
| 862 | ri->prim->startVertex = 0; |
| 863 | ri->prim->numVertices = mVertCount[i]; |
| 864 | |
| 865 | // We sort by the material then vertex buffer. |
| 866 | ri->defaultKey = matInst->getStateHint(); |
| 867 | ri->defaultKey2 = (uintptr_t)ri->vertBuff; // Not 64bit safe! |
| 868 | |
| 869 | renderPass->addInst( ri ); |
nothing calls this directly
no test coverage detected