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

Method WriteLineVerticesToBuffer

trinity/Tr2CurveLineSet.cpp:182–267  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------------ Description: Populate vertex buffer with 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 does this

Source from the content-addressed store, hash-verified

180// buffer - the vertex buffer
181// ------------------------------------------------------------------------------------------------------
182void Tr2CurveLineSet::WriteLineVerticesToBuffer(
183 const Vector3& pos1,
184 const Color& col1,
185 float length1,
186 const Vector3& pos2,
187 const Color& col2,
188 float length2,
189 const Vector3& posPrev,
190 const Vector3& posNext,
191 unsigned int lineID,
192 LineVertex* buffer )
193{
194 // line info
195 const LineData* lineData = &m_lines[lineID];
196
197 // direction position hint for the vertexshader
198 Vector3 dirOffset = pos2 - pos1;
199
200 uint32_t col1Swizzled = SwizzleColor( col1 );
201 uint32_t col2Swizzled = SwizzleColor( col2 );
202 uint32_t multiColorSwizzled = SwizzleColor( lineData->multiColor );
203 uint32_t overlayColorSwizzled = SwizzleColor( lineData->overlayColor );
204
205 Vector3 animationData( lineData->animationSpeed, lineData->animationScale, (float)lineID );
206
207 // tri0 - v0
208 LineVertex& v0 = buffer[0];
209 v0.position = pos1;
210 v0.lineDir = Vector4( dirOffset, -1.f * m_lineWidthFactor * lineData->width );
211 v0.beginEnd = Vector4( 0.f, length1, lineData->multiColorBorder, length2 - length1 );
212 v0.nextLineDir = posPrev;
213 v0.color = col1Swizzled;
214 v0.overrideColor = multiColorSwizzled;
215 v0.overlayColor = overlayColorSwizzled;
216 v0.animationData = animationData;
217 // tri0 - v1
218 LineVertex& v1 = buffer[1];
219 v1.position = pos1;
220 v1.lineDir = Vector4( dirOffset, m_lineWidthFactor * lineData->width );
221 v1.beginEnd = Vector4( 0.f, length1, lineData->multiColorBorder, length2 - length1 );
222 v1.nextLineDir = posPrev;
223 v1.color = col1Swizzled;
224 v1.overrideColor = multiColorSwizzled;
225 v1.overlayColor = overlayColorSwizzled;
226 v1.animationData = animationData;
227 // tri0 - v2
228 LineVertex& v2 = buffer[2];
229 v2.position = pos2;
230 v2.lineDir = Vector4( -1.f * dirOffset, -1.f * m_lineWidthFactor * lineData->width );
231 v2.beginEnd = Vector4( 1.f, length2, lineData->multiColorBorder, length2 - length1 );
232 v2.nextLineDir = posNext;
233 v2.color = col2Swizzled;
234 v2.overrideColor = multiColorSwizzled;
235 v2.overlayColor = overlayColorSwizzled;
236 v2.animationData = animationData;
237 // tri1 - v0
238 LineVertex& v3 = buffer[3];
239 v3.position = pos1;

Callers

nothing calls this directly

Calls 2

SwizzleColorFunction · 0.70
Vector4Class · 0.50

Tested by

no test coverage detected