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

Method RenderPicking

trinity/ITr2PickableScene.cpp:272–322  ·  view source on GitHub ↗

-------------------------------------------------------------------------------------- Description: Renders picking batches into the picking buffer. Arguments: pOpaquePickingBatches - Opaque batch accumulator pPickingBatches - Picking batch accumulator pass - union of PickComponent that are to be queried during this pass. Return value: true If the rendering succeeded false On error --------------

Source from the content-addressed store, hash-verified

270// false On error
271// --------------------------------------------------------------------------------------
272bool ITr2PickableScene::RenderPicking( ITriRenderBatchAccumulator* pOpaquePickingBatches,
273 ITriRenderBatchAccumulator* pPickingBatches,
274 PickComponents pass )
275{
276 USE_MAIN_THREAD_RENDER_CONTEXT(); //TODO
277
278 // Use a shader variable for identifying which components are expected.
279 // We can't use situations here because the flags might change during a single
280 // frame.
281 Vector4 componentsParam = Vector4(
282 ( pass & PICK_OBJECT ) ? 1.0f : 0.0f,
283 ( pass & PICK_AREA ) ? 1.0f : 0.0f,
284 ( pass & PICK_POSITION ) ? 1.0f : 0.0f,
285 ( pass & PICK_UV ) ? 1.0f : 0.0f );
286
287 GlobalStore().RegisterVariable( "PickingComponents", componentsParam );
288
289 float initialDepth = ( HUGE_NUMBER - Tr2Renderer::GetFrontClip() ) / ( Tr2Renderer::GetBackClip() - Tr2Renderer::GetFrontClip() );
290 initialDepth = std::max( 0.0f, std::min( 1.0f, initialDepth ) );
291
292 // Get the pick buffer
293 Tr2PickBuffer& pickBuffer = GetPickBuffer();
294
295 if( !pickBuffer.BeginRendering( initialDepth, renderContext ) )
296 {
297 return false;
298 }
299
300 if( pOpaquePickingBatches->GetBatchCount() )
301 {
302 pOpaquePickingBatches->Finalize();
303
304 renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_PICKING );
305 renderContext.RenderBatchesForPicking( pOpaquePickingBatches, BlueSharedString( "Picking" ) );
306 }
307
308 if( pPickingBatches && RenderPickingAreasForComponents( pass ) )
309 {
310 pPickingBatches->Finalize();
311
312 renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_PICKING );
313 renderContext.RenderBatchesForPicking( pPickingBatches, DEFAULT_TECHNIQUE );
314 }
315
316 if( !pickBuffer.EndRendering( renderContext ) )
317 {
318 return false;
319 }
320
321 return true;
322}
323
324namespace
325{

Callers

nothing calls this directly

Calls 11

GetFrontClipFunction · 0.85
GetBackClipFunction · 0.85
RegisterVariableMethod · 0.80
GetBatchCountMethod · 0.80
FinalizeMethod · 0.80
ApplyStandardStatesMethod · 0.80
EndRenderingMethod · 0.80
Vector4Class · 0.50
BeginRenderingMethod · 0.45

Tested by

no test coverage detected