MCPcopy Create free account
hub / github.com/carbonengine/trinity / RenderPlanets

Method RenderPlanets

trinity/Eve/EveSpaceScene.cpp:3837–3899  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3835}
3836
3837void EveSpaceScene::RenderPlanets( Tr2RenderContext& renderContext )
3838{
3839 // Backup current state
3840 Tr2Renderer::PushProjection();
3841 ScopeGuard guardPopProjection = MakeGuard( Tr2Renderer::PopProjection );
3842 Tr2Renderer::PushViewTransform();
3843 ScopeGuard guardPopViewTransform = MakeGuard( Tr2Renderer::PopViewTransform );
3844
3845 Matrix lastPlanetViewMatrix = CreatePlanetViewMatrix( m_viewLast );
3846 Tr2Renderer::SetViewTransform( CreatePlanetViewMatrix( Tr2Renderer::GetViewTransform() ) );
3847
3848 Matrix planetProjection = EveCamera::ModifyClipPlanes( m_projection, 0.01f, 1e5f ) * m_jitterMatrix;
3849 Matrix lastPlanetProjection = EveCamera::ModifyClipPlanes( m_projectionLast, 0.01f, 1e5f ) * m_jitterMatrix; //apply the same transformations and jitter to both so that they all cancel out.
3850
3851 Tr2Renderer::SetProjectionTransform( planetProjection );
3852
3853 std::vector<ITr2Renderable*> planetRenderables;
3854 for( EvePlanetVector::iterator it = m_planets.begin(); it != m_planets.end(); ++it )
3855 {
3856 EvePlanet* obj = *it;
3857 obj->GetRenderables( planetRenderables );
3858 }
3859
3860 if( planetRenderables.empty() )
3861 {
3862 return;
3863 }
3864
3865 // Need to populate per frame data again as view/projection matrices changed
3866 PopulatePerFramePSData( m_perFramePS, renderContext );
3867 PopulatePerFrameVSData( m_perFrameVS, renderContext );
3868 m_perFrameVS.ViewProjectionLast = Transpose( lastPlanetViewMatrix * lastPlanetProjection );
3869 ApplyPerFrameData( renderContext );
3870
3871 Tr2RenderableSortList renderablesWithTransparencies;
3872 GetAllBatchesFromRenderables( planetRenderables, renderablesWithTransparencies, false, m_secondaryBatches );
3873 PrepareTransparentBatch( renderablesWithTransparencies, m_secondaryBatches );
3874 FinalizeBatches( m_secondaryBatches );
3875
3876 renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_DEPTH_ONLY );
3877 renderContext.RenderBatches( m_secondaryBatches[TRIBATCHTYPE_DEPTH], BlueSharedString( "Depth" ) );
3878 RenderOpaqueBatches( m_secondaryBatches, renderContext );
3879
3880 auto oldReadOnlyDepth = renderContext.GetReadOnlyDepth();
3881 renderContext.SetReadOnlyDepth( true );
3882 renderContext.m_esm.PushRenderTarget( 1 );
3883 renderContext.m_esm.SetRenderTarget( 1, {} );
3884 RenderTransparentBatches( m_secondaryBatches, renderContext );
3885 renderContext.SetReadOnlyDepth( oldReadOnlyDepth );
3886 renderContext.m_esm.PopRenderTarget( 1 );
3887 ClearBatches( m_secondaryBatches );
3888
3889 // Put view/projection back to normal
3890 Tr2Renderer::PopProjection();
3891 guardPopProjection.Dismiss();
3892
3893 Tr2Renderer::PopViewTransform();
3894 guardPopViewTransform.Dismiss();

Callers

nothing calls this directly

Calls 15

SetViewTransformFunction · 0.85
GetViewTransformFunction · 0.85
PopulatePerFramePSDataFunction · 0.85
PopulatePerFrameVSDataFunction · 0.85
TransposeFunction · 0.85
emptyMethod · 0.80
ApplyStandardStatesMethod · 0.80
RenderBatchesMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
GetRenderablesMethod · 0.45
GetReadOnlyDepthMethod · 0.45

Tested by

no test coverage detected