MCPcopy Create free account
hub / github.com/Autodesk/Aurora / CreateIdentifierFromURI

Method CreateIdentifierFromURI

Libraries/ImageProcessingResolver/Resolver.cpp:326–390  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324}
325
326std::string ImageProcessingResolverPlugin::CreateIdentifierFromURI(
327 const std::string& assetPath, const ArResolvedPath& anchorAssetPath) const
328{
329 // Parse the asset path as a URI.
330 UriUriA uri;
331 const char* pErrStr;
332 if (uriParseSingleUriA(&uri, assetPath.c_str(), &pErrStr) == URI_SUCCESS)
333 {
334 // If URI parsing succeeds get the URI scheme.
335 std::string scheme(
336 uri.scheme.first, (size_t)uri.scheme.afterLast - (size_t)uri.scheme.first);
337
338 // If this is not an imageProcessing URI return empty string.
339 if (scheme.compare("imageProcessing") != 0)
340 return "";
341
342 // Create an cache entry for this path.
343 AssetCacheEntry cacheEntry = AssetCacheEntry();
344
345 // Set the host which defines which processing function to run.
346 cacheEntry.host = std::string(
347 uri.hostText.first, (size_t)uri.hostText.afterLast - (size_t)uri.hostText.first);
348
349 // Build a query dictionary which defines the function parameters.
350 UriQueryListA* queryList;
351 int itemCount;
352 if (uriDissectQueryMallocA(&queryList, &itemCount, uri.query.first, uri.query.afterLast) ==
353 URI_SUCCESS)
354 {
355 while (queryList)
356 {
357 cacheEntry.queries[queryList->key] = queryList->value;
358 queryList = queryList->next;
359 }
360
361 // Set the source file name from the file query parameter (Which is
362 // common to all functions)
363 cacheEntry.sourceFilename = ArDefaultResolver::_CreateIdentifier(
364 cacheEntry.queries["filename"], anchorAssetPath);
365 }
366
367 // Create a hash from original URI.
368 std::size_t assetHash = std::hash<std::string> {}(assetPath.c_str());
369
370 // All images are assigned .exr extension currently.
371 string ext = ".exr";
372
373 // Create generated asset path from hash.
374 ArResolvedPath generatedAssetPath =
375 ArResolvedPath(assetPathPrefix + Aurora::Foundation::sHash(assetHash) + ext);
376 cacheEntry.assetPath = generatedAssetPath;
377
378 // If there is no cacheEntry for this path, or the sourceFilename has changed
379 // (due to anchor changing) then add to cache.
380 auto& assetCache = const_cast<ImageProcessingResolverPlugin*>(this)->_assetCache;
381 auto recordIter = assetCache.find(generatedAssetPath);
382 if (recordIter == assetCache.end() ||
383 recordIter->second.sourceFilename.compare(cacheEntry.sourceFilename) != 0)

Callers

nothing calls this directly

Calls 4

AssetCacheEntryClass · 0.85
sHashFunction · 0.85
compareMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected