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

Method AdvanceTime

trinity/Tr2TextureAnimation.cpp:135–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133}
134
135void Tr2TextureAnimation::AdvanceTime( float dt )
136{
137 if( !m_asyncState )
138 {
139 return;
140 }
141
142 if( m_asyncState->bitmapsReady && m_grids.empty() )
143 {
144 USE_MAIN_THREAD_RENDER_CONTEXT();
145
146 m_grids.resize( m_asyncState->decoders.size() );
147 for( uint32_t i = 0; i < m_asyncState->reader.GetGridCount(); ++i )
148 {
149 m_grids[i].name = BlueSharedString( m_asyncState->reader.GetGridInfo( i ).name );
150
151 auto& bitmap = m_asyncState->decoders[i].GetFrameBitmap();
152
153 Tr2SubresourceData mip0;
154 mip0.m_sysMem = bitmap.GetRawData();
155 mip0.m_sysMemSlicePitch = bitmap.GetMipSize( 0 ) / std::max( bitmap.GetMipDepth( 0 ), 1u );
156 mip0.m_sysMemPitch = bitmap.GetMipPitch( 0 );
157
158 if( FAILED( m_grids[i].frame.Create( bitmap, Tr2MsaaDesc(), Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::WRITE, &mip0, renderContext ) ) )
159 {
160 CCP_LOGERR( "Failed to create texture (%S)", m_filename.c_str() );
161 }
162 }
163 m_frame = 0;
164 m_time = 0;
165 m_restartState = NotRestarting;
166
167 AddToComputeQueue( &DecodeNextFrame, MakeRequest() );
168 }
169
170 if( m_grids.empty() )
171 {
172 return;
173 }
174
175 switch( m_restartState )
176 {
177 case WaitingToRestart:
178 if( m_asyncState->bitmapsReady )
179 {
180 AddToComputeQueue( &RestartAndDecodeFrame, MakeRequest() );
181 m_restartState = WaitingForFrame;
182 }
183 return;
184 case WaitingForFrame:
185 if( m_asyncState->bitmapsReady )
186 {
187 UpdateGrids();
188 AddToComputeQueue( &DecodeNextFrame, MakeRequest() );
189 m_frame = 0;
190 m_time = 0;
191 m_restartState = NotRestarting;
192 }

Callers 1

UpdateSyncronousMethod · 0.80

Calls 6

AddToComputeQueueFunction · 0.85
emptyMethod · 0.80
sizeMethod · 0.80
GetMipSizeMethod · 0.80
Tr2MsaaDescClass · 0.50
CreateMethod · 0.45

Tested by

no test coverage detected