/* static */ void UsdKatanaCache::_SetMutedLayers( const UsdStageRefPtr &stage, const std::string &layerRegex) { // Trace this function to track its performance TRACE_FUNCTION(); // Unmute layers that are currently muted, but not requested to be muted SdfLayerHandleVector stageLayers = stage->GetUsedLayers(); bool regexIsEmpty = layerRegex == "" || layerRegex == "^$"; // use a better regex library? regex_t regex; regcomp(®ex, layerRegex.c_str(), REG_EXTENDED); regmatch_t* rmatch = 0; TF_FOR_ALL(stageLayer, stageLayers) { SdfLayerHandle layer = *stageLayer; if (!layer) { continue; } std::string layerPath = layer->GetRepositoryPath(); const std::string layerIdentifier = layer->GetIdentifier(); bool match = false; if (!regexIsEmpty) { if (layer && !regexec( ®ex, layerIdentifier.c_str(), 0, rmatch, 0)) { match = true; } } if (!match && stage->IsLayerMuted(layerIdentifier)) { TF_DEBUG(USDKATANA_CACHE_RENDERER).Msg("{USD RENDER CACHE} " "Unmuting Layer: '%s'\n", layerIdentifier.c_str()); stage->UnmuteLayer(layerIdentifier); } if (match && !stage->IsLayerMuted(layerIdentifier)) { TF_DEBUG(USDKATANA_CACHE_RENDERER).Msg("{USD RENDER CACHE} " "Muting Layer: '%s'\n", layerIdentifier.c_str()); stage->MuteLayer(layerIdentifier); } }