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

Method ExtractAudioGeometry

trinity/Resources/TriGeometryRes.cpp:2427–2465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2425}
2426
2427void TriGeometryRes::ExtractAudioGeometry( TriGeometryResMeshData* mesh, granny_mesh* grannyMesh )
2428{
2429 auto audioGeometry = std::make_unique<AudioGeometryResData>();
2430
2431 unsigned int positionOffset;
2432 Tr2VertexDefinition::DataType positionType;
2433 GetVertexPositionOffsetAndType( grannyMesh, positionOffset, positionType );
2434
2435 const int vertexCount = grannyMesh->PrimaryVertexData->VertexCount;
2436 Tr2VertexDefinition audioVertexDef = BuildFromGrannyVertexDecl( grannyMesh->PrimaryVertexData->VertexType );
2437 const unsigned int bytesPerVertex = audioVertexDef.m_nextOffset[0];
2438
2439 // Read original indices from granny mesh
2440 int indexCount = grannyMesh->PrimaryTopology->Index16Count;
2441 if( indexCount == 0 )
2442 {
2443 indexCount = grannyMesh->PrimaryTopology->IndexCount;
2444 }
2445
2446 if( indexCount == 0 || indexCount % 3 != 0 )
2447 {
2448 return;
2449 }
2450
2451
2452 audioGeometry->m_vertices.resize( vertexCount );
2453 for( int v = 0; v < vertexCount; ++v )
2454 {
2455 GetMeshVertexPosition( grannyMesh, static_cast<uint32_t>( v ), audioGeometry->m_vertices[v], bytesPerVertex, positionOffset, positionType );
2456 }
2457
2458 audioGeometry->m_indices.resize( indexCount );
2459 GrannyCopyMeshIndices( grannyMesh, sizeof( uint32_t ), audioGeometry->m_indices.data() );
2460
2461 audioGeometry->m_minBounds = mesh->m_minBounds;
2462 audioGeometry->m_maxBounds = mesh->m_maxBounds;
2463
2464 mesh->m_audioGeometry = std::move( audioGeometry );
2465}
2466#endif
2467
2468Be::Result<std::string> TriGeometryRes::SaveMesh( const char* filename, uint32_t meshIndex ) const

Callers

nothing calls this directly

Calls 3

GetMeshVertexPositionFunction · 0.85

Tested by

no test coverage detected