| 85 | } |
| 86 | |
| 87 | void TransformOp::modifyPrimitive( Primitive * primitive, const CompoundObject * operands ) |
| 88 | { |
| 89 | const std::vector<std::string> &pv = m_primVarsParameter->getTypedValue(); |
| 90 | for ( std::vector<std::string>::const_iterator it = pv.begin(); it != pv.end(); ++it ) |
| 91 | { |
| 92 | PrimitiveVariableMap::iterator pIt = primitive->variables.find( *it ); |
| 93 | if ( pIt == primitive->variables.end() || !pIt->second.data ) |
| 94 | { |
| 95 | continue; |
| 96 | } |
| 97 | |
| 98 | // We need to take a copy of the data in case other |
| 99 | // primitive variables were referencing the same data, |
| 100 | // and are not in the list of variables to modify. |
| 101 | pIt->second.data = pIt->second.data->copy(); |
| 102 | |
| 103 | Data *data = pIt->second.data.get(); |
| 104 | |
| 105 | // fix for old files that don't store Interpretation properly |
| 106 | V3fVectorData *v3fData = runTimeCast<V3fVectorData>( data ); |
| 107 | if ( v3fData ) |
| 108 | { |
| 109 | GeometricData::Interpretation interp = v3fData->getInterpretation(); |
| 110 | |
| 111 | if ( interp == GeometricData::None ) |
| 112 | { |
| 113 | if ( *it == "P" ) |
| 114 | { |
| 115 | IECore::msg( IECore::MessageHandler::Warning, "TransformOp", "Primitive contains data named P with no interpretation. Converting to Point data." ); |
| 116 | v3fData->setInterpretation( GeometricData::Point ); |
| 117 | } |
| 118 | else if ( *it == "N" ) |
| 119 | { |
| 120 | IECore::msg( IECore::MessageHandler::Warning, "TransformOp", "Primitive contains data named N with no interpretation. Converting to Normal data." ); |
| 121 | v3fData->setInterpretation( GeometricData::Normal ); |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | m_multiplyOp->inputParameter()->setValue( pIt->second.data ); |
| 127 | m_multiplyOp->operate(); |
| 128 | } |
| 129 | } |