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

Method Spawn

trinity/Tr2RuntimeInstanceData.cpp:558–652  ·  view source on GitHub ↗

-------------------------------------------------------------------------------------- Description: Spawns particles into the particle system. --------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

556// Spawns particles into the particle system.
557// --------------------------------------------------------------------------------------
558void 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(),

Callers

nothing calls this directly

Calls 10

emptyMethod · 0.80
GetD3DUsageMethod · 0.80
ClearParticlesMethod · 0.80
getMethod · 0.80
InsertParticleMethod · 0.80
DoneInsertingParticleMethod · 0.80
IsValidMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected