| 30 | } |
| 31 | |
| 32 | void Tr2SkinnedModel::GetBatchesForArea( Tr2MeshAreaVector* areas, Tr2Mesh* mesh, ITriRenderBatchAccumulator* batches, const Matrix* pm, Tr2PerObjectDataSkinned* skinnedData ) |
| 33 | { |
| 34 | if( !mesh->GetDisplay() ) |
| 35 | { |
| 36 | return; |
| 37 | } |
| 38 | |
| 39 | TriGeometryRes* geomRes = mesh->GetGeometryResource(); |
| 40 | if( !geomRes || !geomRes->IsGood() ) |
| 41 | { |
| 42 | return; |
| 43 | } |
| 44 | int meshIx = mesh->GetMeshIndex(); |
| 45 | |
| 46 | TriGeometryResLodData* lod = geomRes->GetMeshLod( meshIx, 0 ); |
| 47 | if( !lod || !lod->m_allocationsValid ) |
| 48 | { |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | for( auto& area : *areas ) |
| 53 | { |
| 54 | auto shader = area->GetMaterialInterface(); |
| 55 | if( !area->GetDisplay() || ( !shader ) ) |
| 56 | { |
| 57 | continue; |
| 58 | } |
| 59 | Tr2PerAreaDataSkinned* areaData = batches->Allocate<Tr2PerAreaDataSkinned>(); |
| 60 | |
| 61 | // Note that this can fail if the accumulator can't add more batches! |
| 62 | if( areaData ) |
| 63 | { |
| 64 | // if we have bone-remapping, get jointbindings from area |
| 65 | TriGeometryResAreaData* areaRes = geomRes->GetAreaData( meshIx, area->GetIndex() ); |
| 66 | |
| 67 | unsigned int n = area->GetJointCount(); |
| 68 | |
| 69 | // Much more than this would trash the per-frame data |
| 70 | if( n > TR2_MAX_BONES_PER_MESHAREA ) |
| 71 | { |
| 72 | continue; |
| 73 | } |
| 74 | |
| 75 | areaData->SetUserData( skinnedData->GetUserData() ); |
| 76 | unsigned int* animMapping = area->GetJointMappingAnimRig(); |
| 77 | if( ( m_skeletonIx != NO_SKELETON ) && ( animMapping != NULL ) ) |
| 78 | { |
| 79 | areaData->SetJointCount( n ); |
| 80 | |
| 81 | for( unsigned int joint = 0; joint < n; ++joint ) |
| 82 | { |
| 83 | float* m = skinnedData->GetSkinningMatrix( animMapping[joint] ); |
| 84 | areaData->SetJointTransform( joint, m ); |
| 85 | } |
| 86 | } |
| 87 | else |
| 88 | { |
| 89 | areaData->SetJointCount( TR2_MAX_BONES_PER_MESHAREA ); |
nothing calls this directly
no test coverage detected