| 360 | |
| 361 | |
| 362 | void EveChildInstancedMeshes::AddMesh( |
| 363 | const char* geometryPath, |
| 364 | bool castsShadow, |
| 365 | EntityComponents::ReflectionMode reflectionMode, |
| 366 | uint32_t meshIndex, |
| 367 | const MeshArea* areas, |
| 368 | size_t areaCount, |
| 369 | const Matrix* instanceTransforms, |
| 370 | size_t count, |
| 371 | const BlueSharedString& sofHullName, |
| 372 | const BlueSharedString& sofLocatorSetName ) |
| 373 | { |
| 374 | if( areaCount == 0 || count == 0 ) |
| 375 | { |
| 376 | return; |
| 377 | } |
| 378 | |
| 379 | Mesh& mesh = m_meshes.emplace_back(); |
| 380 | mesh.geometryPath = geometryPath; |
| 381 | mesh.reflectionMode = reflectionMode; |
| 382 | mesh.meshIndex = meshIndex; |
| 383 | for( size_t i = 0; i < areaCount; ++i ) |
| 384 | { |
| 385 | auto& a = mesh.areas.emplace_back(); |
| 386 | a.effect = areas[i].effect; |
| 387 | a.batchType = areas[i].batchType; |
| 388 | a.areaIndex = areas[i].areaIndex; |
| 389 | a.areaCount = areas[i].areaCount; |
| 390 | a.effectHash = a.effect ? a.effect->GetHashValue() : 0; |
| 391 | } |
| 392 | mesh.instances.reserve( count ); |
| 393 | for( size_t i = 0; i < count; ++i ) |
| 394 | { |
| 395 | EveInstancedMeshManager::StaticPerInstanceData instanceData; |
| 396 | auto& mat = instanceTransforms[i]; |
| 397 | instanceData.worldTransform[0] = Vector4( mat._11, mat._21, mat._31, mat._41 ); |
| 398 | instanceData.worldTransform[1] = Vector4( mat._12, mat._22, mat._32, mat._42 ); |
| 399 | instanceData.worldTransform[2] = Vector4( mat._13, mat._23, mat._33, mat._43 ); |
| 400 | instanceData.sphereIndex = static_cast<uint32_t>( i ); |
| 401 | mesh.instances.push_back( instanceData ); |
| 402 | } |
| 403 | mesh.instanceSpheres.resize( count ); |
| 404 | BeResMan->GetResource( mesh.geometryPath, "", mesh.geometry ); |
| 405 | if( mesh.geometry ) |
| 406 | { |
| 407 | auto seenMesh = find_if( begin( m_meshes ), end( m_meshes ) - 1, [&]( const Mesh& m ) { return m.geometry == mesh.geometry; } ); |
| 408 | if( seenMesh == end( m_meshes ) - 1 ) |
| 409 | { |
| 410 | mesh.geometry->AddNotifyTarget( this ); |
| 411 | } |
| 412 | else |
| 413 | { |
| 414 | mesh.combinedVertexDeclaration = seenMesh->combinedVertexDeclaration; |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | if( castsShadow ) |
| 419 | { |
no test coverage detected