@@ -255,6 +255,16 @@ static float4x4 GetUpAxisTransform(const pxr::TfToken UpAxis)
255
255
}
256
256
}
257
257
258
+ static bool HasDomeLight (pxr::UsdStage& Stage)
259
+ {
260
+ for (const auto & Prim : Stage.Traverse ())
261
+ {
262
+ if (Prim.IsA <pxr::UsdLuxDomeLight>())
263
+ return true ;
264
+ }
265
+ return false ;
266
+ }
267
+
258
268
void USDViewer::LoadStage ()
259
269
{
260
270
{
@@ -348,6 +358,7 @@ void USDViewer::LoadStage()
348
358
AddDirectionalLight (" _HnDirectionalLight3_" , 5000 .f , pxr::GfRotation{pxr::GfVec3d{1 , 0.0 , 0.5 }, -40 }, 1024 );
349
359
350
360
// Environment map
361
+ if (!HasDomeLight (*m_Stage.Stage ))
351
362
{
352
363
m_Stage.DomeLightId = SceneDelegateId.AppendChild (pxr::TfToken{" _HnDomeLight_" });
353
364
pxr::UsdLuxDomeLight DomeLight = pxr::UsdLuxDomeLight::Define (m_Stage.Stage , m_Stage.DomeLightId );
@@ -657,14 +668,17 @@ void USDViewer::UpdateUI()
657
668
}
658
669
}
659
670
660
- if (ImGui::Button ( " Load Environment Map " ))
671
+ if (!m_Stage. DomeLightId . IsEmpty ( ))
661
672
{
662
- FileDialogAttribs OpenDialogAttribs{FILE_DIALOG_TYPE_OPEN};
663
- OpenDialogAttribs.Title = " Select HDR file" ;
664
- OpenDialogAttribs.Filter = " HDR files (*.hdr)\0 *.hdr;\0 All files\0 *.*\0\0 " ;
665
- auto FileName = FileSystem::FileDialog (OpenDialogAttribs);
666
- if (!FileName.empty ())
667
- LoadEnvironmentMap (FileName.data ());
673
+ if (ImGui::Button (" Load Environment Map" ))
674
+ {
675
+ FileDialogAttribs OpenDialogAttribs{FILE_DIALOG_TYPE_OPEN};
676
+ OpenDialogAttribs.Title = " Select HDR file" ;
677
+ OpenDialogAttribs.Filter = " HDR files (*.hdr)\0 *.hdr;\0 All files\0 *.*\0\0 " ;
678
+ auto FileName = FileSystem::FileDialog (OpenDialogAttribs);
679
+ if (!FileName.empty ())
680
+ LoadEnvironmentMap (FileName.data ());
681
+ }
668
682
}
669
683
670
684
if (ImGui::Button (" Open directory" ))
0 commit comments