| 243 | |
| 244 | template<bool linear, bool periodic> |
| 245 | void CurvesPrimitiveEvaluator::Result::init( unsigned curveIndex, float v, const CurvesPrimitiveEvaluator *evaluator ) |
| 246 | { |
| 247 | m_curveIndex = curveIndex; |
| 248 | m_v = v; |
| 249 | |
| 250 | int numVertices = evaluator->m_verticesPerCurve[curveIndex]; |
| 251 | const CubicBasisf &basis = evaluator->m_curvesPrimitive->basis(); |
| 252 | |
| 253 | unsigned numSegments = 0; |
| 254 | if( linear ) |
| 255 | { |
| 256 | if( periodic ) |
| 257 | { |
| 258 | numSegments = numVertices; |
| 259 | } |
| 260 | else |
| 261 | { |
| 262 | numSegments = numVertices - 1; |
| 263 | } |
| 264 | } |
| 265 | else |
| 266 | { |
| 267 | if( periodic ) |
| 268 | { |
| 269 | numSegments = numVertices / basis.step; |
| 270 | } |
| 271 | else |
| 272 | { |
| 273 | numSegments = (numVertices - 4 ) / basis.step + 1; |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | float vv = v * numSegments; |
| 278 | unsigned segment = min( (unsigned)fastFloatFloor( vv ), numSegments - 1 ); |
| 279 | m_segmentV = vv - segment; |
| 280 | |
| 281 | unsigned o = evaluator->m_vertexDataOffsets[m_curveIndex]; |
| 282 | unsigned i = segment * basis.step; |
| 283 | |
| 284 | if( linear ) |
| 285 | { |
| 286 | m_coefficients[0] = 1.0f - m_segmentV; |
| 287 | m_coefficients[1] = m_segmentV; |
| 288 | m_derivativeCoefficients[0] = -1.0f; |
| 289 | m_derivativeCoefficients[1] = 1.0f; |
| 290 | m_vertexDataIndices[0] = m_varyingDataIndices[0] = o + i; |
| 291 | if( periodic ) |
| 292 | { |
| 293 | m_vertexDataIndices[1] = m_varyingDataIndices[1] = o + ( ( i + 1 ) % numVertices ); |
| 294 | } |
| 295 | else |
| 296 | { |
| 297 | m_vertexDataIndices[1] = m_varyingDataIndices[1] = m_vertexDataIndices[0] + 1; |
| 298 | } |
| 299 | } |
| 300 | else |
| 301 | { |
| 302 | basis.coefficients( m_segmentV, m_coefficients.data() ); |
no test coverage detected