MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / prepRenderImage

Method prepRenderImage

Engine/source/environment/meshRoad.cpp:1191–1264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1189}
1190
1191void 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();

Callers

nothing calls this directly

Calls 11

allocSharedXformMethod · 0.80
getOverrideMaterialMethod · 0.80
isForwardLitMethod · 0.80
getLightsMethod · 0.80
allocPrimMethod · 0.80
sizeMethod · 0.45
getRenderPassMethod · 0.45
clearMethod · 0.45
initMethod · 0.45
addInstMethod · 0.45
bindMethod · 0.45

Tested by

no test coverage detected