static*/
| 527 | } |
| 528 | |
| 529 | /*static*/ Future<GltfReaderResult> GltfReader::resolveExternalData( |
| 530 | const AsyncSystem& asyncSystem, |
| 531 | const std::string& baseUrl, |
| 532 | const HttpHeaders& headers, |
| 533 | const std::shared_ptr<IAssetAccessor>& pAssetAccessor, |
| 534 | const GltfReaderOptions& options, |
| 535 | GltfReaderResult&& result) { |
| 536 | |
| 537 | // TODO: Can we avoid this copy conversion? |
| 538 | std::vector<IAssetAccessor::THeader> tHeaders(headers.begin(), headers.end()); |
| 539 | |
| 540 | if (!result.model) { |
| 541 | return asyncSystem.createResolvedFuture(std::move(result)); |
| 542 | } |
| 543 | |
| 544 | // Get a rough count of how many external buffers we may have. |
| 545 | // Some of these may be data uris though. |
| 546 | size_t uriBuffersCount = 0; |
| 547 | for (const Buffer& buffer : result.model->buffers) { |
| 548 | if (buffer.uri) { |
| 549 | ++uriBuffersCount; |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | for (const Image& image : result.model->images) { |
| 554 | if (image.uri) { |
| 555 | ++uriBuffersCount; |
| 556 | } |
| 557 | } |
| 558 | |
| 559 | { |
| 560 | // We need to obtain the extension to find out if we have another buffer we |
| 561 | // need to resolve. We can't use this pointer later since the result is |
| 562 | // moved, so we'll do it twice. |
| 563 | ExtensionModelExtStructuralMetadata* pStructuralMetadataTemp = |
| 564 | result.model->getExtension<ExtensionModelExtStructuralMetadata>(); |
| 565 | |
| 566 | if (pStructuralMetadataTemp && |
| 567 | pStructuralMetadataTemp->schemaUri.has_value()) { |
| 568 | ++uriBuffersCount; |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | if (uriBuffersCount == 0) { |
| 573 | return asyncSystem.createResolvedFuture(std::move(result)); |
| 574 | } |
| 575 | |
| 576 | auto pResult = std::make_unique<GltfReaderResult>(std::move(result)); |
| 577 | |
| 578 | struct ExternalBufferLoadResult { |
| 579 | bool success = false; |
| 580 | std::string bufferUri; |
| 581 | ErrorList warningsAndErrors; |
| 582 | }; |
| 583 | |
| 584 | std::vector<Future<ExternalBufferLoadResult>> resolvedBuffers; |
| 585 | resolvedBuffers.reserve(uriBuffersCount); |
| 586 |
nothing calls this directly
no test coverage detected