| 461 | { |
| 462 | |
| 463 | void resamplePrimitiveVariable( const CurvesPrimitive *curves, PrimitiveVariable &primitiveVariable, PrimitiveVariable::Interpolation interpolation, const Canceller *canceller ) |
| 464 | { |
| 465 | |
| 466 | if ( interpolation == primitiveVariable.interpolation) |
| 467 | { |
| 468 | return; |
| 469 | } |
| 470 | |
| 471 | DataPtr dstData = nullptr; |
| 472 | DataPtr srcData = nullptr; |
| 473 | |
| 474 | if( primitiveVariable.indices ) |
| 475 | { |
| 476 | if( primitiveVariable.interpolation == PrimitiveVariable::Vertex && ( interpolation == PrimitiveVariable::Varying || interpolation == PrimitiveVariable::FaceVarying ) ) |
| 477 | { |
| 478 | // \todo: fix CurvesVertexToVarying so it works with arbitrary PrimitiveVariables |
| 479 | // rather than requiring the variables exist on the input CurvesPrimitive. |
| 480 | throw InvalidArgumentException( "CurvesAlgo::resamplePrimitiveVariable : Resampling indexed Vertex variables to FaceVarying/Varying is not currently supported. Expand indices first." ); |
| 481 | } |
| 482 | else if( ( primitiveVariable.interpolation == PrimitiveVariable::Varying || primitiveVariable.interpolation == PrimitiveVariable::FaceVarying ) && interpolation == PrimitiveVariable::Vertex ) |
| 483 | { |
| 484 | // \todo: fix CurvesVaryingToVertex so it works with arbitrary PrimitiveVariables |
| 485 | // rather than requiring the variables exist on the input CurvesPrimitive. |
| 486 | throw InvalidArgumentException( "CurvesAlgo::resamplePrimitiveVariable : Resampling indexed FaceVarying/Varying variables to Vertex is not currently supported. Expand indices first." ); |
| 487 | } |
| 488 | else if( primitiveVariable.interpolation < interpolation ) |
| 489 | { |
| 490 | // upsampling can be a resampling of indices |
| 491 | srcData = primitiveVariable.indices; |
| 492 | } |
| 493 | else if( primitiveVariable.interpolation == PrimitiveVariable::FaceVarying && interpolation == PrimitiveVariable::Varying ) |
| 494 | { |
| 495 | // FaceVarying and Varying are the same for CurvesPrimitives |
| 496 | srcData = primitiveVariable.indices; |
| 497 | } |
| 498 | else |
| 499 | { |
| 500 | // downsampling forces index expansion to |
| 501 | // simplify the algorithms. |
| 502 | // \todo: allow indices to be maintained. |
| 503 | srcData = primitiveVariable.expandedData(); |
| 504 | primitiveVariable.indices = nullptr; |
| 505 | } |
| 506 | } |
| 507 | else |
| 508 | { |
| 509 | // with no indices we can just resample the data |
| 510 | srcData = primitiveVariable.data; |
| 511 | } |
| 512 | |
| 513 | if ( interpolation == PrimitiveVariable::Constant ) |
| 514 | { |
| 515 | Detail::AverageValueFromVector fn; |
| 516 | dstData = dispatch( srcData.get(), fn ); |
| 517 | } |
| 518 | else if ( primitiveVariable.interpolation == PrimitiveVariable::Constant ) |
| 519 | { |
| 520 | Detail::FillVectorFromValue fn( curves->variableSize( interpolation ) ); |
no test coverage detected