| 1189 | } |
| 1190 | |
| 1191 | void MeshRoad::prepRenderImage( SceneRenderState* state ) |
| 1192 | { |
| 1193 | if ( mNodes.size() <= 1 ) |
| 1194 | return; |
| 1195 | |
| 1196 | RenderPassManager *renderPass = state->getRenderPass(); |
| 1197 | |
| 1198 | // Normal Road RenderInstance |
| 1199 | // Always rendered when the editor is not open |
| 1200 | // otherwise obey the smShowRoad flag |
| 1201 | if ( smShowRoad || !smEditorOpen ) |
| 1202 | { |
| 1203 | #ifdef TORQUE_AFX_ENABLED |
| 1204 | afxZodiacMgr::renderMeshRoadZodiacs(state, this); |
| 1205 | #endif |
| 1206 | MeshRenderInst coreRI; |
| 1207 | coreRI.clear(); |
| 1208 | coreRI.objectToWorld = &MatrixF::Identity; |
| 1209 | coreRI.worldToCamera = renderPass->allocSharedXform(RenderPassManager::View); |
| 1210 | coreRI.projection = renderPass->allocSharedXform(RenderPassManager::Projection); |
| 1211 | coreRI.type = RenderPassManager::RIT_Mesh; |
| 1212 | |
| 1213 | BaseMatInstance *matInst; |
| 1214 | for ( U32 i = 0; i < SurfaceCount; i++ ) |
| 1215 | { |
| 1216 | matInst = state->getOverrideMaterial( mMatInst[i] ); |
| 1217 | if ( !matInst ) |
| 1218 | continue; |
| 1219 | |
| 1220 | // Get the lights if we haven't already. |
| 1221 | if ( matInst->isForwardLit() && !coreRI.lights[0] ) |
| 1222 | { |
| 1223 | LightQuery query; |
| 1224 | query.init( getWorldSphere() ); |
| 1225 | query.getLights( coreRI.lights, 8 ); |
| 1226 | } |
| 1227 | |
| 1228 | MeshRenderInst *ri = renderPass->allocInst<MeshRenderInst>(); |
| 1229 | *ri = coreRI; |
| 1230 | |
| 1231 | // Currently rendering whole road, fix to cull and batch |
| 1232 | // per segment. |
| 1233 | |
| 1234 | // Set the correct material for rendering. |
| 1235 | ri->matInst = matInst; |
| 1236 | ri->vertBuff = &mVB[i]; |
| 1237 | ri->primBuff = &mPB[i]; |
| 1238 | |
| 1239 | ri->prim = renderPass->allocPrim(); |
| 1240 | ri->prim->type = GFXTriangleList; |
| 1241 | ri->prim->minIndex = 0; |
| 1242 | ri->prim->startIndex = 0; |
| 1243 | ri->prim->numPrimitives = mTriangleCount[i]; |
| 1244 | ri->prim->startVertex = 0; |
| 1245 | ri->prim->numVertices = mVertCount[i]; |
| 1246 | |
| 1247 | // We sort by the material then vertex buffer. |
| 1248 | ri->defaultKey = matInst->getStateHint(); |
nothing calls this directly
no test coverage detected