| 218 | } |
| 219 | |
| 220 | void convertLegacyVariables( PrimitiveVariableMap &variables ) |
| 221 | { |
| 222 | std::set<Data *> processed; |
| 223 | std::vector<PrimitiveVariableMap::const_iterator> variablesToErase; |
| 224 | |
| 225 | for( auto it = variables.begin(); it != variables.end(); ++it ) |
| 226 | { |
| 227 | // We changed from s & t (FloatVectorData) to UVs (V2fVectorData) |
| 228 | // in version 2, so we collect our UV sets and combine them. |
| 229 | |
| 230 | // We have 2 legacy conventions for storing UVs: |
| 231 | // (a) PrimitiveVariables named "s" and "t" represent |
| 232 | // the components of the primary UV set. |
| 233 | // (b) PrimitiveVariables named "<var>_s" and "<var>_t" |
| 234 | // represent the components of an extra UV set |
| 235 | // named "<var>". |
| 236 | |
| 237 | // We also changed from storing separate indices |
| 238 | // as side-car PrimitiveVariables to storing them |
| 239 | // directly on the primary PrimitiveVariable. |
| 240 | |
| 241 | // We have 3 legacy conventions for storing indices: |
| 242 | // (a) For the primary UV set, as in (a) above, the |
| 243 | // indices were named "stIndices". |
| 244 | // (b) For the extra UV sets, as in (b) above, the |
| 245 | // indices were named "<var>Indices". |
| 246 | // (c) For non-UV PrimitiveVariables named "<var>" |
| 247 | // the indices were also named "<var>Indices". |
| 248 | |
| 249 | // the name of the uvSet if there is one |
| 250 | std::string uvSet; |
| 251 | // the u values if we find any |
| 252 | PrimitiveVariableMap::const_iterator uIt = variables.end(); |
| 253 | // the v values if we find any |
| 254 | PrimitiveVariableMap::const_iterator vIt = variables.end(); |
| 255 | // the indices if we find any |
| 256 | PrimitiveVariableMap::const_iterator indicesIt = variables.end(); |
| 257 | |
| 258 | if( it->first == "s" ) |
| 259 | { |
| 260 | uvSet = "uv"; |
| 261 | uIt = it; |
| 262 | vIt = variables.find( "t" ); |
| 263 | indicesIt = variables.find( "stIndices" ); |
| 264 | } |
| 265 | else if( it->first == "t" ) |
| 266 | { |
| 267 | uvSet = "uv"; |
| 268 | uIt = variables.find( "s" ); |
| 269 | vIt = it; |
| 270 | indicesIt = variables.find( "stIndices" ); |
| 271 | } |
| 272 | else if( boost::ends_with( it->first, "_s" ) ) |
| 273 | { |
| 274 | uvSet = it->first.substr( 0, it->first.length() - 2 ); |
| 275 | |
| 276 | uIt = it; |
| 277 | vIt = variables.find( uvSet + "_t" ); |
no test coverage detected