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

Function CreateGeometryBatch

trinity/Tr2MeshBase.cpp:372–424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370}
371
372Tr2RenderBatch 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

Callers 9

GetBatchesForAreaMethod · 0.85
GetBatchesMethod · 0.85
GetBatchesFromMeshMethod · 0.85
GetBatchesMethod · 0.85
GetBatchesMethod · 0.85
GetShadowBatchesMethod · 0.85
GetGroupBatchesMethod · 0.85
GetBatchesMethod · 0.85

Calls 14

GetPrimitiveCountFunction · 0.85
GetMaterialInterfaceMethod · 0.80
GetIndexMethod · 0.80
GetReversedMethod · 0.80
SetGeometryMethod · 0.80
GetStartIndexMethod · 0.80
GetDisplayMethod · 0.45
GetCountMethod · 0.45
SetMaterialMethod · 0.45
SetPerObjectDataMethod · 0.45

Tested by

no test coverage detected