Skip to content

Commit 13c99e3

Browse files
authored
Merge branch 'gz-sim9' into default_visual_for_model
2 parents 14976e9 + 07d8905 commit 13c99e3

File tree

2 files changed

+44
-6
lines changed

2 files changed

+44
-6
lines changed

src/gui/plugins/global_illumination_civct/GlobalIlluminationCiVct.cc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,20 @@ QObject *GlobalIlluminationCiVct::AddCascade()
761761
{
762762
std::lock_guard<std::mutex> lock(this->dataPtr->serviceMutex);
763763

764-
if (this->dataPtr->gi && this->dataPtr->gi->Started())
764+
if (!this->dataPtr->gi)
765+
{
766+
gzerr << "GlobalIlluminationCiVct object is not initialized. "
767+
<< "Cannot add cascade."
768+
<< std::endl;
769+
return nullptr;
770+
}
771+
if (this->dataPtr->gi->Started())
772+
{
773+
gzerr << "GlobalIlluminationCiVct is already started. "
774+
<< "Cannot add cascade."
775+
<< std::endl;
765776
return nullptr;
777+
}
766778

767779
rendering::CiVctCascade const *ref = nullptr;
768780
if (!this->dataPtr->cascades.empty())

src/gui/plugins/global_illumination_vct/GlobalIlluminationVct.cc

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,21 @@ bool GlobalIlluminationVct::eventFilter(QObject *_obj, QEvent *_event)
499499
}
500500
else if (this->dataPtr->debugVisualizationDirty)
501501
{
502-
this->dataPtr->gi->SetDebugVisualization(
502+
if (this->dataPtr->enabled && this->dataPtr->gi->Enabled())
503+
{
504+
this->dataPtr->gi->SetDebugVisualization(
503505
static_cast<rendering::GlobalIlluminationVct::DebugVisualizationMode>(
504-
this->dataPtr->debugVisMode));
506+
this->dataPtr->debugVisMode));
507+
}
508+
else
509+
{
510+
gzerr << "Trying to set debug visualization mode while GI is "
511+
<< "disabled. Please enable GI first."
512+
<< std::endl;
513+
// Always set to none when disabled to avoid crash
514+
this->dataPtr->gi->SetDebugVisualization(
515+
rendering::GlobalIlluminationVct::DVM_None);
516+
}
505517
this->dataPtr->debugVisualizationDirty = false;
506518
}
507519
}
@@ -549,9 +561,23 @@ void GlobalIlluminationVct::UpdateOctantCount(int _axis, uint32_t _count)
549561
//////////////////////////////////////////////////
550562
void GlobalIlluminationVct::SetEnabled(const bool _enabled)
551563
{
552-
std::lock_guard<std::mutex> lock(this->dataPtr->serviceMutex);
553-
this->dataPtr->enabled = _enabled;
554-
this->dataPtr->visualDirty = true;
564+
bool needEmitDebugVisChanged = false;
565+
{
566+
std::lock_guard<std::mutex> lock(this->dataPtr->serviceMutex);
567+
if (this->dataPtr->enabled && !_enabled)
568+
{
569+
// When disabling GI, force debugVisMode to None for safety
570+
this->dataPtr->debugVisMode = rendering::GlobalIlluminationVct::DVM_None;
571+
this->dataPtr->debugVisualizationDirty = true;
572+
needEmitDebugVisChanged = true;
573+
}
574+
this->dataPtr->enabled = _enabled;
575+
this->dataPtr->visualDirty = true;
576+
}
577+
if (needEmitDebugVisChanged)
578+
{
579+
this->DebugVisualizationModeChanged();
580+
}
555581
}
556582

557583
//////////////////////////////////////////////////

0 commit comments

Comments
 (0)