| 182 | extern int g_maxClothLod; |
| 183 | |
| 184 | void 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 | } |
no test coverage detected