Skip to content

Commit

Permalink
USD fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
darbyjohnston committed Feb 15, 2024
1 parent 23f4528 commit 4486b68
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions lib/tlIO/USDRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,16 @@ namespace tl
const UsdStageRefPtr& stage,
const std::string& name = std::string())
{
const TfToken primaryCameraName = UsdUtilsGetPrimaryCameraName();
UsdGeomCamera out = UsdAppUtilsGetCameraAtPath(
stage,
SdfPath(!name.empty() ? name : primaryCameraName));
UsdGeomCamera out;
if (!name.empty())
{
out = UsdAppUtilsGetCameraAtPath(stage, SdfPath(name));
}
if (!out)
{
const TfToken primaryCameraName = UsdUtilsGetPrimaryCameraName();
out = UsdAppUtilsGetCameraAtPath(stage, SdfPath(primaryCameraName));
}
if (!out)
{
for (const auto& prim : stage->Traverse())
Expand Down Expand Up @@ -511,7 +517,7 @@ namespace tl
}
if (infoRequest)
{
const std::string fileName = infoRequest->path.get();
const std::string fileName = infoRequest->path.get(-1, file::PathType::Path);
Private::StageCacheItem stageCacheItem;
if (!p.thread.stageCache.get(fileName, stageCacheItem))
{
Expand Down Expand Up @@ -557,8 +563,8 @@ namespace tl
io::VideoData videoData;
if (request && p.cache)
{
const std::string cacheKey = io::Cache::getVideoKey(
request->path.get(),
const std::string cacheKey = io::getCacheKey(
request->path,
request->time,
ioOptions);
if (p.cache->getVideo(cacheKey, videoData))
Expand All @@ -571,10 +577,13 @@ namespace tl
// Check the disk cache.
if (request)
{
const std::string fileName = request->path.get();
std::shared_ptr<Private::DiskCacheItem> diskCacheItem;
const std::string cacheKey = io::getCacheKey(
request->path,
request->time,
ioOptions);
if (diskCacheByteCount > 0 &&
p.thread.diskCache.get(io::Cache::getVideoKey(fileName, request->time, ioOptions), diskCacheItem))
p.thread.diskCache.get(cacheKey, diskCacheItem))
{
std::shared_ptr<image::Image> image;
try
Expand Down Expand Up @@ -608,10 +617,6 @@ namespace tl

if (p.cache)
{
const std::string cacheKey = io::Cache::getVideoKey(
fileName,
request->time,
ioOptions);
p.cache->addVideo(cacheKey, videoData);
}

Expand All @@ -622,11 +627,15 @@ namespace tl
// Handle requests.
if (request)
{
const std::string fileName = request->path.get();
std::shared_ptr<image::Image> image;
const std::string cacheKey = io::getCacheKey(
request->path,
request->time,
ioOptions);
try
{
// Check the stage cache for a previously opened stage.
const std::string fileName = request->path.get(-1, file::PathType::Path);
Private::StageCacheItem stageCacheItem;
if (!p.thread.stageCache.get(fileName, stageCacheItem))
{
Expand Down Expand Up @@ -811,10 +820,7 @@ namespace tl
tempFile->writeU32(static_cast<uint32_t>(image->getPixelType()));
const size_t byteCount = image->getDataByteCount();
tempFile->write(image->getData(), byteCount);
p.thread.diskCache.add(
io::Cache::getVideoKey(fileName, request->time, ioOptions),
diskCacheItem,
byteCount);
p.thread.diskCache.add(cacheKey, diskCacheItem, byteCount);
}
}
}
Expand All @@ -836,10 +842,6 @@ namespace tl

if (p.cache)
{
const std::string cacheKey = io::Cache::getVideoKey(
fileName,
request->time,
ioOptions);
p.cache->addVideo(cacheKey, videoData);
}
}
Expand Down

0 comments on commit 4486b68

Please sign in to comment.