-------------------------------------------------------------------------------------- Description: Implements ITr2Scene::Render. Renders a list of primitive sets. --------------------------------------------------------------------------------------
| 48 | // Implements ITr2Scene::Render. Renders a list of primitive sets. |
| 49 | // -------------------------------------------------------------------------------------- |
| 50 | void Tr2PrimitiveScene::Render( Tr2RenderContext& renderContext ) |
| 51 | { |
| 52 | std::vector<ITr2Renderable*> visibleRenderObjects; |
| 53 | // We render everything since it is so cheap |
| 54 | visibleRenderObjects.clear(); |
| 55 | for( PrimitiveIterator it = m_primitives.begin(); it != m_primitives.end(); ++it ) |
| 56 | { |
| 57 | ( *it )->UpdateTransform(); |
| 58 | visibleRenderObjects.push_back( ( *it ) ); |
| 59 | } |
| 60 | |
| 61 | if( m_manipulator != NULL ) |
| 62 | { |
| 63 | m_manipulator->Update(); |
| 64 | std::vector<ITr2Renderable*> manipPrims = m_manipulator->GetPrimitivesToRender(); |
| 65 | for( RenderableIterator it = manipPrims.begin(); it != manipPrims.end(); ++it ) |
| 66 | { |
| 67 | visibleRenderObjects.push_back( ( *it ) ); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | // Sort the list before we render since the primitives might not write to z |
| 72 | Tr2RenderableSortList sortList; |
| 73 | for( RenderableIterator it = visibleRenderObjects.begin(); it != visibleRenderObjects.end(); ++it ) |
| 74 | { |
| 75 | ITr2RenderableEntry entry; |
| 76 | entry.m_object = ( *it ); |
| 77 | entry.m_distance = ( *it )->GetSortValue(); |
| 78 | sortList.push_back( entry ); |
| 79 | } |
| 80 | std::sort( sortList.begin(), sortList.end() ); |
| 81 | // sort the primitives back to front |
| 82 | std::reverse( sortList.begin(), sortList.end() ); |
| 83 | |
| 84 | SetupPerFrameData( renderContext ); |
| 85 | renderContext.m_esm.BeginManagedRendering(); |
| 86 | |
| 87 | for( Tr2RenderableSortList::iterator it = sortList.begin(); |
| 88 | it != sortList.end(); |
| 89 | ++it ) |
| 90 | { |
| 91 | ITr2RenderablePtr obj = ( *it ).m_object; |
| 92 | Tr2PerObjectData* perObject = obj->GetPerObjectData( m_opaqueBatches ); |
| 93 | obj->GetBatches( m_opaqueBatches, TRIBATCHTYPE_OPAQUE, perObject ); |
| 94 | } |
| 95 | |
| 96 | m_opaqueBatches->Finalize(); |
| 97 | |
| 98 | renderContext.m_esm.SetInvertedDepthTest( true ); |
| 99 | renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_OPAQUE ); |
| 100 | renderContext.RenderBatches( m_opaqueBatches ); |
| 101 | renderContext.m_esm.SetInvertedDepthTest( false ); |
| 102 | |
| 103 | m_opaqueBatches->Clear(); |
| 104 | m_allocator->Clear(); |
| 105 | |
| 106 | renderContext.m_esm.EndManagedRendering(); |
| 107 |
nothing calls this directly
no test coverage detected