| 115 | } |
| 116 | |
| 117 | void RenderTerrainMgr::render( SceneRenderState *state ) |
| 118 | { |
| 119 | if ( mInstVector.empty() ) |
| 120 | return; |
| 121 | |
| 122 | // Check if bin is disabled in advanced lighting. |
| 123 | if ( MATMGR->getDeferredEnabled() && mBasicOnly ) |
| 124 | return; |
| 125 | |
| 126 | PROFILE_SCOPE( RenderTerrainMgr_Render ); |
| 127 | |
| 128 | GFXTransformSaver saver; |
| 129 | |
| 130 | // Prepare the common scene graph data. |
| 131 | SceneData sgData; |
| 132 | sgData.init( state ); |
| 133 | sgData.wireframe |= smRenderWireframe; |
| 134 | |
| 135 | // Restore transforms |
| 136 | MatrixSet &matrixSet = getRenderPass()->getMatrixSet(); |
| 137 | matrixSet.restoreSceneViewProjection(); |
| 138 | |
| 139 | GFXDEBUGEVENT_SCOPE( RenderTerrainMgr_Render, ColorI::GREEN ); |
| 140 | |
| 141 | const MatrixF worldViewXfm = matrixSet.getWorldToCamera(); |
| 142 | const MatrixF &projXfm = matrixSet.getCameraToScreen(); |
| 143 | |
| 144 | // HACKTASTIC! |
| 145 | // |
| 146 | // If this is a shadow pass then render the terrain |
| 147 | // with the first material we get. |
| 148 | // |
| 149 | // In the near future terrains will operate using regular |
| 150 | // MatInstance materials like any other mesh in which case |
| 151 | // this will all be replaced by a normal mesh render bin. |
| 152 | // |
| 153 | if ( state->isShadowPass() ) |
| 154 | { |
| 155 | PROFILE_SCOPE( RenderTerrainMgr_Render_Shadow ); |
| 156 | |
| 157 | Vector<TerrainRenderInst*>::iterator inst = mInstVector.begin(); |
| 158 | BaseMatInstance *overideMat = (*inst)->mat; |
| 159 | while ( overideMat && overideMat->setupPass( state, sgData ) ) |
| 160 | { |
| 161 | for ( ; inst != mInstVector.end(); inst++ ) |
| 162 | { |
| 163 | smOverrideCells++; |
| 164 | |
| 165 | GFX->setPrimitiveBuffer( (*inst)->primBuff ); |
| 166 | GFX->setVertexBuffer( (*inst)->vertBuff ); |
| 167 | |
| 168 | matrixSet.setWorld(*(*inst)->objectToWorldXfm); |
| 169 | |
| 170 | overideMat->setSceneInfo( state, sgData ); |
| 171 | overideMat->setTransforms( matrixSet, state ); |
| 172 | |
| 173 | GFX->drawPrimitive( (*inst)->prim ); |
| 174 | } |
nothing calls this directly
no test coverage detected