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

Method ProcessMeshTriangles

trinity/Resources/TriGeometryRes.cpp:1447–1528  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1445}
1446
1447void TriGeometryRes::ProcessMeshTriangles( int meshIx, PerTriangleCallback cb, void* cbContext )
1448{
1449 CCP_STATS_ZONE( __FUNCTION__ );
1450 USE_MAIN_THREAD_RENDER_CONTEXT();
1451
1452 int i = meshIx;
1453
1454 if( m_meshes[i] == NULL )
1455 {
1456 return;
1457 }
1458
1459 auto& mesh = m_meshes[i];
1460
1461 auto& lod = mesh->m_lods[0];
1462
1463 if( !lod->m_allocationsValid )
1464 {
1465 return;
1466 }
1467
1468 const uint8_t* pVertices;
1469 const uint8_t* pIndices;
1470
1471 int vertSize = mesh->m_bytesPerVertex;
1472
1473 if( FAILED( lod->m_vertexAllocation.MapForReading( pVertices, renderContext ) ) )
1474 {
1475 return;
1476 }
1477 ON_BLOCK_EXIT( [&] { lod->m_vertexAllocation.UnmapForReading( renderContext ); } );
1478 if( FAILED( lod->m_indexAllocation.MapForReading( pIndices, renderContext ) ) )
1479 {
1480 return;
1481 }
1482 ON_BLOCK_EXIT( [&] { lod->m_indexAllocation.UnmapForReading( renderContext ); } );
1483
1484 const uint16_t* pShortIndices = (uint16_t*)pIndices;
1485 const uint32_t* pLongIndices = (uint32_t*)pIndices;
1486
1487
1488 Tr2VertexDefinition decl;
1489 if( !Tr2EffectStateManager::GetVertexDeclarationElements( mesh->m_vertexDeclarationHandle, decl ) )
1490 {
1491 return;
1492 }
1493
1494 auto foundPosition = decl.Find( Tr2VertexDefinition::POSITION, 0 );
1495 if( !foundPosition )
1496 {
1497 return;
1498 }
1499 unsigned int positionByteOffset = foundPosition->m_offset;
1500 Tr2VertexDefinition::DataType declType = foundPosition->m_dataType;
1501
1502 int numPrim = lod->m_primitiveCount;
1503 for( int j = 0; j < numPrim; j++ )
1504 {

Callers

nothing calls this directly

Calls 5

ConvertTriangleDataFunction · 0.85
FindMethod · 0.80
MapForReadingMethod · 0.45
UnmapForReadingMethod · 0.45
GetStrideMethod · 0.45

Tested by

no test coverage detected