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

Method prepRenderImage

Engine/source/environment/meshRoad.cpp:812–882  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

810}
811
812void 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 );

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