| 410 | // tangents .. |
| 411 | template <typename T> |
| 412 | void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source, |
| 413 | const std::string& MappingInformationType, |
| 414 | const std::string& ReferenceInformationType, |
| 415 | const char* dataElementName, |
| 416 | const char* indexDataElementName, |
| 417 | size_t vertex_count, |
| 418 | const std::vector<unsigned int>& mapping_counts, |
| 419 | const std::vector<unsigned int>& mapping_offsets, |
| 420 | const std::vector<unsigned int>& mappings) |
| 421 | { |
| 422 | bool isDirect = ReferenceInformationType == "Direct"; |
| 423 | bool isIndexToDirect = ReferenceInformationType == "IndexToDirect"; |
| 424 | const bool hasDataElement = HasElement(source, dataElementName); |
| 425 | const bool hasIndexDataElement = HasElement(source, indexDataElementName); |
| 426 | |
| 427 | // fall-back to direct data if there is no index data element |
| 428 | if (isIndexToDirect && !hasIndexDataElement) { |
| 429 | isDirect = true; |
| 430 | isIndexToDirect = false; |
| 431 | } |
| 432 | |
| 433 | // handle permutations of Mapping and Reference type - it would be nice to |
| 434 | // deal with this more elegantly and with less redundancy, but right |
| 435 | // now it seems unavoidable. |
| 436 | if (MappingInformationType == "ByVertice" && isDirect) { |
| 437 | if (!hasDataElement) { |
| 438 | FBXImporter::LogWarn("missing data element: ", dataElementName); |
| 439 | return; |
| 440 | } |
| 441 | std::vector<T> tempData; |
| 442 | ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName)); |
| 443 | |
| 444 | if (tempData.size() != mapping_offsets.size()) { |
| 445 | FBXImporter::LogError("length of input data unexpected for ByVertice mapping: ", |
| 446 | tempData.size(), ", expected ", mapping_offsets.size()); |
| 447 | return; |
| 448 | } |
| 449 | |
| 450 | data_out.resize(vertex_count); |
| 451 | for (size_t i = 0, e = tempData.size(); i < e; ++i) { |
| 452 | const unsigned int istart = mapping_offsets[i], iend = istart + mapping_counts[i]; |
| 453 | for (unsigned int j = istart; j < iend; ++j) { |
| 454 | data_out[mappings[j]] = tempData[i]; |
| 455 | } |
| 456 | } |
| 457 | } |
| 458 | else if (MappingInformationType == "ByVertice" && isIndexToDirect) { |
| 459 | std::vector<T> tempData; |
| 460 | if (!hasDataElement || !hasIndexDataElement) { |
| 461 | if (!hasDataElement) |
| 462 | FBXImporter::LogWarn("missing data element: ", dataElementName); |
| 463 | if (!hasIndexDataElement) |
| 464 | FBXImporter::LogWarn("missing index data element: ", indexDataElementName); |
| 465 | return; |
| 466 | } |
| 467 | |
| 468 | ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName)); |
| 469 |
no test coverage detected