Skip to content

Commit

Permalink
Brightness slider initialised from all light colours
Browse files Browse the repository at this point in the history
Initialise the slider to the brightness of the highest RGB component in ALL
selected lights, rather than the first light entity selected. This should
ensure that no individual light is overbrightened when the slider is dragged to
maximum value.
  • Loading branch information
Matthew Mott committed Jul 13, 2021
1 parent 9f660a5 commit ff377e1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
22 changes: 16 additions & 6 deletions radiant/ui/lightinspector/LightInspector.cpp
Expand Up @@ -380,6 +380,19 @@ namespace
}
}

float LightInspector::highestComponentAllLights() const
{
float highest = 0;
for (const Entity* e: _lightEntities)
{
Vector3 col = entityColour(*e);
float entityHighest = highestComponent(col);
if (entityHighest > highest)
highest = entityHighest;
}
return highest;
}

void LightInspector::updateColourPicker()
{
// Examine colour of all entities. If they are the same, use this colour in
Expand All @@ -404,19 +417,16 @@ void LightInspector::updateColourPicker()
picker->SetColour(col);
}

void LightInspector::updateColourWidgets(const Entity& entity)
void LightInspector::updateColourWidgets()
{
Vector3 colour = entityColour(entity);

// Set colour chooser button
updateColourPicker();

// Set brightness slider based on the brightest channel. This means that
// 100% blue and 100% white will both show as maximum brightness, which
// isn't correct in terms of optics, but prevents the slider from
// overbrightening a colour and changing the hue.
float highest = highestComponent(colour);
_brightnessSlider->SetValue(highest * 100.f);
_brightnessSlider->SetValue(highestComponentAllLights() * 100.f);
}

// Get keyvals from entity and insert into text entries
Expand Down Expand Up @@ -452,7 +462,7 @@ void LightInspector::getValuesFromEntity()
}
}

updateColourWidgets(*entity);
updateColourWidgets();

// Set the texture selection from the "texture" key
_texSelector->setSelection(entity->getKeyValue("texture"));
Expand Down
5 changes: 4 additions & 1 deletion radiant/ui/lightinspector/LightInspector.h
Expand Up @@ -77,9 +77,12 @@ class LightInspector :
void adjustBrightness() const;

void updateColourPicker();
void updateColourWidgets(const Entity&);
void updateColourWidgets();
void updateLightShapeWidgets();

// Get the highest RGB component of ALL selected light colours
float highestComponentAllLights() const;

// Update the dialog widgets from keyvals on the first selected entity
void getValuesFromEntity();

Expand Down

0 comments on commit ff377e1

Please sign in to comment.