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

Method DoSpawn

trinity/Particle/Tr2StaticEmitter.cpp:96–265  ·  view source on GitHub ↗

-------------------------------------------------------------------------------------- Description: Spawns particles from geometry resource if resource is loaded. --------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

94// Spawns particles from geometry resource if resource is loaded.
95// --------------------------------------------------------------------------------------
96void Tr2StaticEmitter::DoSpawn()
97{
98 CCP_STATS_ZONE( __FUNCTION__ );
99
100 auto createDeclarationMap = []( const Tr2VertexDefinition& elements, const Tr2ParticleElementDataMap& particleElements, const std::string& geometryResourcePath, std::vector<DeclarationMapping>& geometryDeclarationMap ) -> bool {
101 geometryDeclarationMap.clear();
102 for( auto i = particleElements.begin(); i != particleElements.end(); ++i )
103 {
104 bool found = false;
105 for( const auto& item : elements.m_items )
106 {
107 unsigned usageIndex = 0;
108 if( i->first.m_type == Tr2ParticleElementDeclarationName::CUSTOM )
109 {
110 usageIndex = i->second.m_usageIndex;
111 }
112 if( item.m_usage == i->first.GetD3DUsage() && item.m_usageIndex == usageIndex )
113 {
114 DeclarationMapping mapping;
115 mapping.inOffset = item.m_offset;
116 mapping.buffer = i->second.m_bufferType;
117 mapping.offset = i->second.m_offset;
118 mapping.length = i->second.m_dimension;
119 mapping.isEmpty = false;
120
121 if( ( item.m_dataType & elements.DT_TYPE_MASK ) == elements.DT_FLOAT32 )
122 {
123 mapping.isFloat16 = false;
124 }
125 else if( ( item.m_dataType & elements.DT_TYPE_MASK ) == elements.DT_FLOAT16 )
126 {
127 mapping.isFloat16 = true;
128 }
129 else
130 {
131 CCP_LOGERR( "Incompatible type for particle elements \"%s\" in Tr2StaticEmitter geometry %s",
132 i->first.GetName().c_str(),
133 geometryResourcePath.c_str() );
134 return false;
135 }
136 geometryDeclarationMap.push_back( mapping );
137 found = true;
138 break;
139 }
140 }
141 if( !found )
142 {
143 DeclarationMapping mapping;
144 mapping.inOffset = 0;
145 mapping.buffer = i->second.m_bufferType;
146 mapping.offset = i->second.m_offset;
147 mapping.length = i->second.m_dimension;
148 mapping.isEmpty = true;
149 mapping.isFloat16 = false;
150 geometryDeclarationMap.push_back( mapping );
151 CCP_LOG( "No data for particle elements \"%s\" in Tr2StaticEmitter geometry %s - filling with zeroes",
152 i->first.GetName().c_str(),
153 geometryResourcePath.c_str() );

Callers

nothing calls this directly

Calls 15

BuildFromCMFVertexDeclFunction · 0.85
GetD3DUsageMethod · 0.80
InsertParticleMethod · 0.80
DoneInsertingParticleMethod · 0.80
ClearParticlesMethod · 0.80
GetCMFViewDataMethod · 0.80
GetGrannyMeshMethod · 0.80
GetGrannyVertexTypeMethod · 0.80
GetVertexSizeMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected