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

Method WriteParticleVerticesToBuffer

trinity/Tr2CurveLineSet.cpp:282–349  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------------ Description: Populate vertex buffer with particle line data. Attributes: pos1 - start position of line segment col1 - color at start of line segment length1 - how far along the line does this segment start pos2 - end position of segment col2 - end color of segment length2 - ow far along the line

Source from the content-addressed store, hash-verified

280// buffer - the vertex buffer
281// ------------------------------------------------------------------------------------------------------
282void Tr2CurveLineSet::WriteParticleVerticesToBuffer(
283 const Vector3& pos1,
284 const Color& col1,
285 float length1,
286 const Vector3& pos2,
287 const Color& col2,
288 float length2,
289 unsigned int lineID,
290 LineVertex* buffer )
291{
292 // line info
293 const LineData* lineData = &m_lines[lineID];
294
295 // direction position hint for the vertexshader
296 Vector3 dirOffset = pos2 - pos1;
297
298 // random
299 float randomVal = (float)rand() / (float)RAND_MAX;
300
301 // tri0 - v0
302 buffer[0].position = pos1;
303 buffer[0].lineDir = Vector4( dirOffset, -1.f * m_lineWidthFactor * lineData->width );
304 buffer[0].beginEnd = Vector4( -1.f * m_lineWidthFactor * lineData->width, length1, randomVal, length2 - length1 );
305 buffer[0].color = SwizzleColor( col1 );
306 buffer[0].overrideColor = SwizzleColor( lineData->multiColor );
307 buffer[0].overlayColor = SwizzleColor( lineData->overlayColor );
308 buffer[0].animationData = lineData->intermediatePosition;
309 // tri0 - v1
310 buffer[1].position = pos1;
311 buffer[1].lineDir = Vector4( dirOffset, m_lineWidthFactor * lineData->width );
312 buffer[1].beginEnd = Vector4( -1.f * m_lineWidthFactor * lineData->width, length1, randomVal, length2 - length1 );
313 buffer[1].color = SwizzleColor( col1 );
314 buffer[1].overrideColor = SwizzleColor( lineData->multiColor );
315 buffer[1].overlayColor = SwizzleColor( lineData->overlayColor );
316 buffer[1].animationData = lineData->intermediatePosition;
317 // tri0 - v2
318 buffer[2].position = pos1;
319 buffer[2].lineDir = Vector4( dirOffset, -1.f * m_lineWidthFactor * lineData->width );
320 buffer[2].beginEnd = Vector4( m_lineWidthFactor * lineData->width, length2, randomVal, length2 - length1 );
321 buffer[2].color = SwizzleColor( col2 );
322 buffer[2].overrideColor = SwizzleColor( lineData->multiColor );
323 buffer[2].overlayColor = SwizzleColor( lineData->overlayColor );
324 buffer[2].animationData = lineData->intermediatePosition;
325 // tri1 - v0
326 buffer[3].position = pos1;
327 buffer[3].lineDir = Vector4( dirOffset, m_lineWidthFactor * lineData->width );
328 buffer[3].beginEnd = Vector4( -1.f * m_lineWidthFactor * lineData->width, length1, randomVal, length2 - length1 );
329 buffer[3].color = col1;
330 buffer[3].overrideColor = SwizzleColor( lineData->multiColor );
331 buffer[3].overlayColor = SwizzleColor( lineData->overlayColor );
332 buffer[3].animationData = lineData->intermediatePosition;
333 // tri2 - v1
334 buffer[4].position = pos1;
335 buffer[4].lineDir = Vector4( dirOffset, m_lineWidthFactor * lineData->width );
336 buffer[4].beginEnd = Vector4( m_lineWidthFactor * lineData->width, length2, randomVal, length2 - length1 );
337 buffer[4].color = SwizzleColor( col2 );
338 buffer[4].overrideColor = SwizzleColor( lineData->multiColor );
339 buffer[4].overlayColor = SwizzleColor( lineData->overlayColor );

Callers

nothing calls this directly

Calls 2

SwizzleColorFunction · 0.70
Vector4Class · 0.50

Tested by

no test coverage detected