| 206 | } |
| 207 | |
| 208 | bool Tr2PrimitiveScene::RenderPicking( |
| 209 | ITriRenderBatchAccumulator* pOpaquePickingBatches, |
| 210 | ITriRenderBatchAccumulator* pPickingBatches, |
| 211 | PickComponents pass ) |
| 212 | { |
| 213 | USE_MAIN_THREAD_RENDER_CONTEXT(); |
| 214 | renderContext.m_esm.SetInvertedDepthTest( true ); |
| 215 | ON_BLOCK_EXIT( [&] { renderContext.m_esm.SetInvertedDepthTest( false ); } ); |
| 216 | |
| 217 | // Use a shader variable for identifying which components are expected. |
| 218 | // We can't use situations here because the flags might change during a single |
| 219 | // frame. |
| 220 | Vector4 componentsParam = Vector4( |
| 221 | ( pass & PICK_OBJECT ) ? 1.0f : 0.0f, |
| 222 | ( pass & PICK_AREA ) ? 1.0f : 0.0f, |
| 223 | ( pass & PICK_POSITION ) ? 1.0f : 0.0f, |
| 224 | ( pass & PICK_UV ) ? 1.0f : 0.0f ); |
| 225 | |
| 226 | GlobalStore().RegisterVariable( "PickingComponents", componentsParam ); |
| 227 | |
| 228 | // Get the pick buffer |
| 229 | Tr2PickBuffer& pickBuffer = GetPickBuffer(); |
| 230 | |
| 231 | if( !pickBuffer.BeginRendering( 0, renderContext ) ) |
| 232 | { |
| 233 | return false; |
| 234 | } |
| 235 | |
| 236 | if( pPickingBatches && RenderPickingAreasForComponents( pass ) ) |
| 237 | { |
| 238 | pPickingBatches->Finalize(); |
| 239 | |
| 240 | renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_PICKING ); |
| 241 | renderContext.RenderBatchesForPicking( pPickingBatches, DEFAULT_TECHNIQUE ); |
| 242 | } |
| 243 | |
| 244 | if( !pickBuffer.EndRendering( renderContext ) ) |
| 245 | { |
| 246 | return false; |
| 247 | } |
| 248 | |
| 249 | return true; |
| 250 | } |
| 251 | |
| 252 | const std::vector<ITr2Renderable*>& Tr2PrimitiveScene::GetPickingObjectsToRender( const Vector3& dirWorld ) |
| 253 | { |
nothing calls this directly
no test coverage detected