------------------------------
| 22 | |
| 23 | //------------------------------ |
| 24 | int validate( const AnimationCurve* animationCurve, bool verbose ) |
| 25 | { |
| 26 | int failure_count = 0; |
| 27 | if ( !animationCurve ) |
| 28 | return 1; |
| 29 | |
| 30 | size_t keyCount = animationCurve->getKeyCount(); |
| 31 | size_t dimension = animationCurve->getOutDimension(); |
| 32 | |
| 33 | // We do not allow animations without keys |
| 34 | if ( keyCount == 0 ){ |
| 35 | if (verbose) |
| 36 | printf("ERROR: [%s] Animation curve has no keys.\n", |
| 37 | animationCurve->getName().c_str()); |
| 38 | failure_count +=1; |
| 39 | } |
| 40 | |
| 41 | // We do not allow animations with no out dimensions |
| 42 | if ( dimension == 0 ) { |
| 43 | if (verbose) |
| 44 | printf("ERROR: [%s] Animation curve has no dimension.\n", |
| 45 | animationCurve->getName().c_str()); |
| 46 | failure_count +=1; |
| 47 | } |
| 48 | |
| 49 | // Subsequent checks only make sense when above checks passed. |
| 50 | // Hence return now, if errors occured until here. |
| 51 | if (failure_count > 0) |
| 52 | return failure_count; |
| 53 | |
| 54 | // for each key we need an input value |
| 55 | if ( animationCurve->getInputValues().getValuesCount() != keyCount ) { |
| 56 | if (verbose) |
| 57 | printf("ERROR: [%s] Found %d input values for %d keys\n", |
| 58 | animationCurve->getName().c_str(), |
| 59 | (int)animationCurve->getInputValues().getValuesCount(), |
| 60 | (int)keyCount); |
| 61 | failure_count +=1; |
| 62 | } |
| 63 | |
| 64 | size_t outValuesCount = dimension * keyCount; |
| 65 | |
| 66 | // Check output values count |
| 67 | if ( animationCurve->getOutputValues().getValuesCount() != outValuesCount ) |
| 68 | failure_count +=1; |
| 69 | |
| 70 | bool needsTangents = ( animationCurve->getInterpolationType() == AnimationCurve::INTERPOLATION_BEZIER ) || |
| 71 | ( animationCurve->getInterpolationType() == AnimationCurve::INTERPOLATION_HERMITE ); |
| 72 | |
| 73 | if ( animationCurve->getInterpolationType() == AnimationCurve::INTERPOLATION_MIXED ) |
| 74 | { |
| 75 | // Check interpolations count |
| 76 | if ( animationCurve->getInterpolationTypes().getCount() != keyCount ) { |
| 77 | if (verbose) |
| 78 | printf("ERROR: [%s] Found %d interpolation types for %d keys\n", |
| 79 | animationCurve->getName().c_str(), |
| 80 | (int)animationCurve->getInterpolationTypes().getCount(), |
| 81 | (int)keyCount); |
no test coverage detected