-------------------------------------------------------------------------------------- Description: Spawns particles into the particle system. --------------------------------------------------------------------------------------
| 556 | // Spawns particles into the particle system. |
| 557 | // -------------------------------------------------------------------------------------- |
| 558 | void Tr2RuntimeInstanceData::Spawn() |
| 559 | { |
| 560 | CCP_STATS_ZONE( __FUNCTION__ ); |
| 561 | |
| 562 | if( m_particleSystem && m_particleSystem->IsValid() && |
| 563 | !m_layout.m_items.empty() && m_data ) |
| 564 | { |
| 565 | // Validate geometry vertex declaration against particle system element declaration |
| 566 | const Tr2ParticleElementDataMap& particleElements = m_particleSystem->GetElementDeclaration(); |
| 567 | std::vector<DeclarationMapping> geometryDeclarationMap; |
| 568 | for( auto i = particleElements.begin(); i != particleElements.end(); ++i ) |
| 569 | { |
| 570 | bool found = false; |
| 571 | for( const auto& item : m_layout.m_items ) |
| 572 | { |
| 573 | unsigned usageIndex = 0; |
| 574 | if( i->first.m_type == Tr2ParticleElementDeclarationName::CUSTOM ) |
| 575 | { |
| 576 | usageIndex = i->second.m_usageIndex; |
| 577 | } |
| 578 | if( item.m_usage == i->first.GetD3DUsage() && item.m_usageIndex == usageIndex ) |
| 579 | { |
| 580 | DeclarationMapping mapping; |
| 581 | mapping.inOffset = item.m_offset; |
| 582 | mapping.buffer = i->second.m_bufferType; |
| 583 | mapping.offset = i->second.m_offset; |
| 584 | mapping.length = i->second.m_dimension; |
| 585 | |
| 586 | if( item.m_dataType >= m_layout.FLOAT32_1 + int( i->second.m_dimension ) - 1 && |
| 587 | item.m_dataType <= m_layout.FLOAT32_4 ) |
| 588 | { |
| 589 | mapping.isFloat16 = false; |
| 590 | } |
| 591 | else if( ( item.m_dataType == m_layout.FLOAT16_2 && i->second.m_dimension <= 2 ) || |
| 592 | item.m_dataType == m_layout.FLOAT16_4 ) |
| 593 | { |
| 594 | CCP_LOGWARN( |
| 595 | "Particle elements \"%s\" has FLOAT16 type in Tr2RuntimeInstanceData \"%s\", this degrades emitter performance", |
| 596 | i->first.GetName().c_str(), |
| 597 | m_name.c_str() ); |
| 598 | mapping.isFloat16 = true; |
| 599 | } |
| 600 | else |
| 601 | { |
| 602 | CCP_LOGERR( "Incompatible type for particle elements \"%s\" in Tr2RuntimeInstanceData \"%s\"", |
| 603 | i->first.GetName().c_str(), |
| 604 | m_name.c_str() ); |
| 605 | return; |
| 606 | } |
| 607 | geometryDeclarationMap.push_back( mapping ); |
| 608 | found = true; |
| 609 | break; |
| 610 | } |
| 611 | } |
| 612 | if( !found ) |
| 613 | { |
| 614 | CCP_LOGERR( "No data for particle elements \"%s\" in Tr2RuntimeInstanceData \"%s\"", |
| 615 | i->first.GetName().c_str(), |
nothing calls this directly
no test coverage detected