@@ -42,6 +42,8 @@ TF_DEFINE_PRIVATE_TOKENS(
4242 (UsdMaya)
4343 (ShadingModePlugin)
4444 (JobContextPlugin)
45+ (ImportChaserPlugin)
46+ (ExportChaserPlugin)
4547);
4648// clang-format on
4749
@@ -140,6 +142,42 @@ static bool _HasMayaPlugin(
140142 return true ;
141143}
142144
145+ static void _FindAndLoadUsdMayaPlugins (const TfToken& pluginKey)
146+ {
147+ const std::vector<TfToken> scope { _tokens->UsdMaya , pluginKey };
148+
149+ for (const auto & plug : PlugRegistry::GetInstance ().GetAllPlugins ()) {
150+ std::string mayaPlugin;
151+ if (_HasMayaPlugin (plug, scope, &mayaPlugin)) {
152+ if (!mayaPlugin.empty ()) {
153+ TF_DEBUG (PXRUSDMAYA_REGISTRY )
154+ .Msg (
155+ " Found %s %s: Loading via Maya API %s.\n " ,
156+ pluginKey.GetText (),
157+ plug->GetName ().c_str (),
158+ mayaPlugin.c_str ());
159+ std::string loadPluginCmd
160+ = TfStringPrintf (" loadPlugin -quiet %s" , mayaPlugin.c_str ());
161+ if (MGlobal::executeCommand (loadPluginCmd.c_str ())) {
162+ // Need to ensure Python script modules are loaded
163+ // properly for this library (Maya's loadPlugin will not
164+ // load script modules like TfDlopen would).
165+ TfScriptModuleLoader::GetInstance ().LoadModules ();
166+ } else {
167+ TF_CODING_ERROR (" Unable to load mayaplugin %s\n " , mayaPlugin.c_str ());
168+ }
169+ } else {
170+ TF_DEBUG (PXRUSDMAYA_REGISTRY )
171+ .Msg (
172+ " Found %s %s: Loading via USD API.\n " ,
173+ pluginKey.GetText (),
174+ plug->GetName ().c_str ());
175+ plug->Load ();
176+ }
177+ }
178+ }
179+ }
180+
143181/* static */
144182std::string _PluginDictScopeToDebugString (const std::vector<TfToken>& scope)
145183{
@@ -202,81 +240,29 @@ void UsdMaya_RegistryHelper::FindAndLoadMayaPlug(
202240/* static */
203241void UsdMaya_RegistryHelper::LoadShadingModePlugins ()
204242{
205- static std::once_flag _shadingModesLoaded;
206- static std::vector<TfToken> scope = { _tokens->UsdMaya , _tokens->ShadingModePlugin };
207- std::call_once (_shadingModesLoaded, []() {
208- PlugPluginPtrVector plugins = PlugRegistry::GetInstance ().GetAllPlugins ();
209- std::string mayaPlugin;
210- TF_FOR_ALL (plugIter, plugins)
211- {
212- PlugPluginPtr plug = *plugIter;
213- if (_HasMayaPlugin (plug, scope, &mayaPlugin)) {
214- if (!mayaPlugin.empty ()) {
215- TF_DEBUG (PXRUSDMAYA_REGISTRY )
216- .Msg (
217- " Found shading mode plugin %s: Loading via Maya API %s.\n " ,
218- plug->GetName ().c_str (),
219- mayaPlugin.c_str ());
220- std::string loadPluginCmd
221- = TfStringPrintf (" loadPlugin -quiet %s" , mayaPlugin.c_str ());
222- if (MGlobal::executeCommand (loadPluginCmd.c_str ())) {
223- // Need to ensure Python script modules are loaded
224- // properly for this library (Maya's loadPlugin will not
225- // load script modules like TfDlopen would).
226- TfScriptModuleLoader::GetInstance ().LoadModules ();
227- } else {
228- TF_CODING_ERROR (" Unable to load mayaplugin %s\n " , mayaPlugin.c_str ());
229- }
230- } else {
231- TF_DEBUG (PXRUSDMAYA_REGISTRY )
232- .Msg (
233- " Found shading mode plugin %s: Loading via USD API.\n " ,
234- plug->GetName ().c_str ());
235- plug->Load ();
236- }
237- }
238- }
239- });
243+ static std::once_flag _loaded;
244+ std::call_once (_loaded, []() { _FindAndLoadUsdMayaPlugins (_tokens->ShadingModePlugin ); });
240245}
241246
242247/* static */
243248void UsdMaya_RegistryHelper::LoadJobContextPlugins ()
244249{
245- static std::once_flag _jobContextsLoaded;
246- static std::vector<TfToken> scope = { _tokens->UsdMaya , _tokens->JobContextPlugin };
247- std::call_once (_jobContextsLoaded, []() {
248- PlugPluginPtrVector plugins = PlugRegistry::GetInstance ().GetAllPlugins ();
249- std::string mayaPlugin;
250- TF_FOR_ALL (plugIter, plugins)
251- {
252- PlugPluginPtr plug = *plugIter;
253- if (_HasMayaPlugin (plug, scope, &mayaPlugin)) {
254- if (!mayaPlugin.empty ()) {
255- TF_DEBUG (PXRUSDMAYA_REGISTRY )
256- .Msg (
257- " Found job context plugin %s: Loading via Maya API %s.\n " ,
258- plug->GetName ().c_str (),
259- mayaPlugin.c_str ());
260- std::string loadPluginCmd
261- = TfStringPrintf (" loadPlugin -quiet %s" , mayaPlugin.c_str ());
262- if (MGlobal::executeCommand (loadPluginCmd.c_str ())) {
263- // Need to ensure Python script modules are loaded
264- // properly for this library (Maya's loadPlugin will not
265- // load script modules like TfDlopen would).
266- TfScriptModuleLoader::GetInstance ().LoadModules ();
267- } else {
268- TF_CODING_ERROR (" Unable to load mayaplugin %s\n " , mayaPlugin.c_str ());
269- }
270- } else {
271- TF_DEBUG (PXRUSDMAYA_REGISTRY )
272- .Msg (
273- " Found job context plugin %s: Loading via USD API.\n " ,
274- plug->GetName ().c_str ());
275- plug->Load ();
276- }
277- }
278- }
279- });
250+ static std::once_flag _loaded;
251+ std::call_once (_loaded, []() { _FindAndLoadUsdMayaPlugins (_tokens->JobContextPlugin ); });
252+ }
253+
254+ /* static */
255+ void UsdMaya_RegistryHelper::LoadImportChaserPlugins ()
256+ {
257+ static std::once_flag _loaded;
258+ std::call_once (_loaded, []() { _FindAndLoadUsdMayaPlugins (_tokens->ImportChaserPlugin ); });
259+ }
260+
261+ /* static */
262+ void UsdMaya_RegistryHelper::LoadExportChaserPlugins ()
263+ {
264+ static std::once_flag _loaded;
265+ std::call_once (_loaded, []() { _FindAndLoadUsdMayaPlugins (_tokens->ExportChaserPlugin ); });
280266}
281267
282268/* static */
0 commit comments