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

Method GetShadowBatches

trinity/Eve/SpaceObject/EveSpaceObject2.cpp:1143–1184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1141
1142
1143void EveSpaceObject2::GetShadowBatches( ITriRenderBatchAccumulator* batches, const Tr2PerObjectData* perObjectData, float shadowPixelSize )
1144{
1145 if( !m_mesh || !m_mesh->GetDisplay() )
1146 {
1147 return;
1148 }
1149
1150 TriGeometryRes* geomRes = m_mesh->GetGeometryResource();
1151 if( !geomRes || !geomRes->IsGood() )
1152 {
1153 return;
1154 }
1155 int meshIx = m_mesh->GetMeshIndex();
1156 auto lod = geomRes->GetMeshLod( meshIx, shadowPixelSize );
1157 if( !lod || !lod->m_allocationsValid )
1158 {
1159 return;
1160 }
1161
1162 for( TriRenderBatchAreaBlocksWithSharedMaterial& shadowMeshArea : m_shadowMeshOpaqueAreas )
1163 {
1164 auto& shadowAreas = shadowMeshArea.m_areaBlockVector;
1165 Tr2Material* shadowShader = shadowMeshArea.m_shaderMaterial;
1166 for( auto& areaBlock : shadowAreas )
1167 {
1168 if( auto primCount = GetPrimitiveCount( *lod, areaBlock.m_startIndex, areaBlock.m_count ) )
1169 {
1170 Tr2RenderBatch batch;
1171 batch.SetMaterial( shadowShader );
1172 batch.SetGeometry( lod->m_mesh->m_vertexDeclarationHandle, lod->m_vertexAllocation, lod->m_indexAllocation );
1173 batch.SetPerObjectData( perObjectData );
1174 batch.SetDrawIndexedInstanced(
1175 primCount * 3,
1176 1,
1177 lod->m_indexAllocation.GetStartIndex() + lod->m_areas[areaBlock.m_startIndex].m_firstIndex,
1178 lod->m_vertexAllocation.GetOffset() / lod->m_vertexAllocation.GetStride(),
1179 0 );
1180 batches->Commit( batch );
1181 }
1182 }
1183 }
1184}
1185
1186Tr2PerObjectData* EveSpaceObject2::GetShadowPerObjectData( ITriRenderBatchAccumulator* accumulator )
1187{

Callers

nothing calls this directly

Calls 14

GetPrimitiveCountFunction · 0.85
GetGeometryResourceMethod · 0.80
GetMeshIndexMethod · 0.80
SetGeometryMethod · 0.80
GetStartIndexMethod · 0.80
GetDisplayMethod · 0.45
IsGoodMethod · 0.45
GetMeshLodMethod · 0.45
SetMaterialMethod · 0.45
SetPerObjectDataMethod · 0.45
GetOffsetMethod · 0.45

Tested by

no test coverage detected