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

Method GetBatches

trinity/Interior/Tr2IntSkinnedObject.cpp:184–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182extern int g_maxClothLod;
183
184void Tr2IntSkinnedObject::GetBatches( ITriRenderBatchAccumulator* batches,
185 TriBatchType batchType,
186 const Tr2PerObjectData* perObjectData,
187 Tr2RenderReason reason )
188{
189 if( !DoDisplay() )
190 {
191 return;
192 }
193 unsigned int depth = 0xFFFFFFFF;
194 if( batchType == TRIBATCHTYPE_TRANSPARENT )
195 {
196 float maxDepth = Tr2Renderer::GetFrustumRadius();
197 Matrix instanceTransform = m_transform;
198
199 // Compute the depth
200 Vector3 bbMin, bbMax;
201 GetLocalBoundingBox( bbMin, bbMax );
202 Vector3 center = TransformCoord( 0.5f * ( bbMin + bbMax ), instanceTransform );
203 center -= Tr2Renderer::GetViewPosition();
204 float z = std::min( std::max( ( Length( center ) + m_depthOffset ) / maxDepth, 0.f ), 1.f );
205
206 depth = (unsigned int)( (float)0xFFFFFFF * ( 1.0f - z ) );
207 }
208 Matrix* pm = batches->Allocate<Matrix>();
209
210 CCP_ASSERT_M( pm, "No memory available for allocation of batches." );
211 if( pm == NULL )
212 {
213 return;
214 }
215 *pm = GetSkinningTransform();
216
217 const Tr2PerObjectDataSkinned* skinnedData = static_cast<const Tr2PerObjectDataSkinned*>( perObjectData );
218
219 for( auto mesh : m_visualModel->GetMeshes() )
220 {
221 if( !mesh || !mesh->GetDisplay() )
222 {
223 continue;
224 }
225 Tr2MeshAreaVector* areas = mesh->GetAreas( batchType );
226 if( !areas )
227 {
228 continue;
229 }
230
231 TriGeometryRes* geomRes = mesh->GetGeometryResource();
232 if( !geomRes || !geomRes->IsGood() )
233 {
234 continue;
235 }
236
237 int meshIx = mesh->GetMeshIndex();
238 if( meshIx < 0 || meshIx >= int( geomRes->GetMeshCount() ) )
239 {
240 continue;
241 }

Callers 1

RenderFullForwardMethod · 0.45

Calls 15

GetViewPositionFunction · 0.85
LengthFunction · 0.85
CreateGeometryBatchFunction · 0.85
GetAreasMethod · 0.80
GetGeometryResourceMethod · 0.80
GetMeshIndexMethod · 0.80
GetMaterialInterfaceMethod · 0.80
GetAreaDataMethod · 0.80
GetIndexMethod · 0.80
GetUserDataMethod · 0.80
GetSkinningMatrixMethod · 0.80

Tested by

no test coverage detected