| 203 | } |
| 204 | |
| 205 | void EveInstancedMeshManager::AddMeshGroup( |
| 206 | MeshGroupHandle& handle, |
| 207 | TriGeometryRes* geometry, |
| 208 | unsigned combinedVertexDeclaration, |
| 209 | TriBatchType batchType, |
| 210 | uint32_t meshIndex, |
| 211 | uint32_t areaIndex, |
| 212 | uint32_t areaCount, |
| 213 | Tr2Effect* material, |
| 214 | uint64_t materialHash, |
| 215 | const PerObjectDataHandle& perObjectDataHandle, |
| 216 | const BoundingSphereHandle& sphereHandle, |
| 217 | const DynamicPerInstanceData* perInstanceData, |
| 218 | uint32_t count, |
| 219 | IRoot* pickingOwner, |
| 220 | uint32_t pickingOwnerIndex ) |
| 221 | { |
| 222 | CCP_ASSERT( !handle ); |
| 223 | CCP_ASSERT( perObjectDataHandle ); |
| 224 | CCP_ASSERT( sphereHandle ); |
| 225 | |
| 226 | MeshKey key = { geometry, |
| 227 | materialHash, |
| 228 | combinedVertexDeclaration, |
| 229 | batchType, |
| 230 | meshIndex, |
| 231 | areaIndex, |
| 232 | areaCount, |
| 233 | true }; |
| 234 | auto& instances = m_meshInstances[key]; |
| 235 | instances.material = material; |
| 236 | if( instances.radius == 0 ) |
| 237 | { |
| 238 | auto meshData = geometry->GetMeshData( meshIndex ); |
| 239 | auto sphere = CcpMath::Sphere( CcpMath::AxisAlignedBox( meshData->m_minBounds, meshData->m_maxBounds ) ); |
| 240 | instances.radius = sphere.radius + Length( sphere.center ); |
| 241 | } |
| 242 | if( instances.lodIndices.empty() ) |
| 243 | { |
| 244 | auto meshData = geometry->GetMeshData( meshIndex ); |
| 245 | auto lodCount = meshData->m_lods.size(); |
| 246 | instances.lodIndices.resize( lodCount ); |
| 247 | instances.screenSizeThresholds.resize( lodCount ); |
| 248 | for( uint32_t lod = 0; lod < lodCount; ++lod ) |
| 249 | { |
| 250 | instances.screenSizeThresholds[lod] = meshData->m_lods[lod]->m_maxScreenSize; |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | auto& meshGroup = instances.meshGroups.emplace_back(); |
| 255 | meshGroup.perObjectDataIndex = perObjectDataHandle.index; |
| 256 | meshGroup.sphereGroupIndex = sphereHandle.index; |
| 257 | meshGroup.dynamicInstances = perInstanceData; |
| 258 | meshGroup.count = count; |
| 259 | meshGroup.handle = &handle; |
| 260 | meshGroup.owner = pickingOwner; |
| 261 | meshGroup.ownerIndex = pickingOwnerIndex; |
| 262 | handle.owner = this; |
no test coverage detected