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

Method GetBatchesForArea

trinity/Tr2SkinnedModel.cpp:32–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32void 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 );

Callers

nothing calls this directly

Calls 15

CreateGeometryBatchFunction · 0.85
GetGeometryResourceMethod · 0.80
GetMeshIndexMethod · 0.80
GetMaterialInterfaceMethod · 0.80
GetAreaDataMethod · 0.80
GetIndexMethod · 0.80
GetUserDataMethod · 0.80
GetSkinningMatrixMethod · 0.80
SetJointTransformMethod · 0.80
GetDisplayMethod · 0.45
IsGoodMethod · 0.45

Tested by

no test coverage detected