| 370 | } |
| 371 | |
| 372 | Tr2RenderBatch CreateGeometryBatch( TriGeometryResLodData* lod, Tr2MeshArea* area, const Tr2PerObjectData* data ) |
| 373 | { |
| 374 | Tr2RenderBatch batch; |
| 375 | |
| 376 | if( !area->GetDisplay() || !lod->m_allocationsValid ) |
| 377 | { |
| 378 | return batch; |
| 379 | } |
| 380 | |
| 381 | auto shadMat = area->GetMaterialInterface(); |
| 382 | if( !shadMat || !shadMat->GetShaderStateInterface() ) |
| 383 | { |
| 384 | return batch; |
| 385 | } |
| 386 | |
| 387 | auto primCount = GetPrimitiveCount( *lod, std::max( 0, area->GetIndex() ), std::max( 0, area->GetCount() ) ); |
| 388 | |
| 389 | if( !primCount ) |
| 390 | { |
| 391 | return batch; |
| 392 | } |
| 393 | |
| 394 | auto& meshArea = lod->m_areas[std::max( 0, area->GetIndex() )]; |
| 395 | |
| 396 | if( area->GetReversed() && !lod->m_reversedIndicesValid ) |
| 397 | { |
| 398 | return batch; |
| 399 | } |
| 400 | |
| 401 | batch.SetMaterial( shadMat ); |
| 402 | batch.SetGeometry( lod->m_mesh->m_vertexDeclarationHandle, lod->m_vertexAllocation, lod->m_indexAllocation ); |
| 403 | |
| 404 | batch.SetPerObjectData( data ); |
| 405 | |
| 406 | auto& indices = area->GetReversed() ? lod->m_reversedIndexAllocation : lod->m_indexAllocation; |
| 407 | uint32_t startIndex; |
| 408 | if( area->GetReversed() ) |
| 409 | { |
| 410 | startIndex = indices.GetStartIndex() + lod->m_primitiveCount * 3 - meshArea.m_firstIndex - primCount * 3; |
| 411 | } |
| 412 | else |
| 413 | { |
| 414 | startIndex = indices.GetStartIndex() + meshArea.m_firstIndex; |
| 415 | } |
| 416 | |
| 417 | batch.SetDrawIndexedInstanced( |
| 418 | primCount * 3, |
| 419 | 1, |
| 420 | startIndex, |
| 421 | lod->m_vertexAllocation.GetOffset() / lod->m_vertexAllocation.GetStride(), |
| 422 | 0 ); |
| 423 | return batch; |
| 424 | } |
| 425 | |
| 426 | |
| 427 |
no test coverage detected