| 149 | } |
| 150 | |
| 151 | V2fVectorDataPtr combineUVs( const FloatVectorData *u, const FloatVectorData *v, const IntVectorData *indices ) |
| 152 | { |
| 153 | const std::vector<float> &uValues = u->readable(); |
| 154 | const std::vector<float> &vValues = v->readable(); |
| 155 | V2fVectorDataPtr uvs = new V2fVectorData(); |
| 156 | uvs->setInterpretation( GeometricData::UV ); |
| 157 | |
| 158 | if( indices ) |
| 159 | { |
| 160 | const std::vector<int> &indexValues = indices->readable(); |
| 161 | int numUVs = 1 + *max_element( indexValues.begin(), indexValues.end() ); |
| 162 | std::vector<Imath::V2f> &uvValues = uvs->writable(); |
| 163 | uvValues.resize( numUVs ); |
| 164 | |
| 165 | for( size_t i = 0, e = indexValues.size(); i < e; ++i ) |
| 166 | { |
| 167 | uvValues[indexValues[i]] = Imath::V2f( uValues[i], vValues[i] ); |
| 168 | } |
| 169 | } |
| 170 | else |
| 171 | { |
| 172 | size_t numUVs = uValues.size(); |
| 173 | |
| 174 | std::vector<Imath::V2f> &uvValues = uvs->writable(); |
| 175 | uvValues.reserve( numUVs ); |
| 176 | |
| 177 | for( size_t i = 0; i < numUVs; ++i ) |
| 178 | { |
| 179 | uvValues.emplace_back( uValues[i], vValues[i] ); |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | return uvs; |
| 184 | } |
| 185 | |
| 186 | void remapToLegacyVariableNames( const IndexedIO::EntryIDList &requested, const IndexedIO::EntryIDList &existing, IndexedIO::EntryIDList &result ) |
| 187 | { |