Small fixes.

- [SliderWidget] Rounds current value on mouse release since it only returns integers.
- [SettingsMenuState] Renamed "Fast" AO to "Basic" and "Fancy" AO to "Lighting based" + added a FIXME.
- [ChunkMeshBuilder] Uncommented light approximation fix.
This commit is contained in:
Quentin Bazin 2021-06-12 04:53:32 +02:00
parent 4ac3ac38ee
commit d21f8bffdd
4 changed files with 10 additions and 5 deletions

View File

@ -66,6 +66,7 @@ void SliderWidget::onEvent(const SDL_Event &event) {
else if (event.type == SDL_MOUSEBUTTONUP && event.button.button == SDL_BUTTON_LEFT) {
if (m_isDragging)
m_callback(*this, event.type);
setCurrentValue(getCurrentValue());
m_isDragging = false;
}
}

View File

@ -73,6 +73,7 @@ class SliderWidget : public Widget {
int m_max = 100;
float m_percentage = 0.f;
int m_previousValue = 0;
bool m_isDragging = false;

View File

@ -231,13 +231,16 @@ void SettingsMenuState::addGraphicsButtons() {
Config::isSmoothLightingEnabled = !Config::isSmoothLightingEnabled;
button.setText(std::string("Smooth Lighting: ") + (Config::isSmoothLightingEnabled ? "ON" : "OFF"));
// FIXME: If AO is set to "lighting based" and smooth lighting is set to OFF
// it needs to set AO to Basic and update the button
World::isReloadRequested = true;
});
const std::string aoValueNames[3] = {
"OFF",
"Fast",
"Fancy"
"Basic",
"Lighting based"
};
m_menuWidget.addButton(std::string("Ambient Occlusion: ") + aoValueNames[Config::ambientOcclusion], [&, aoValueNames] (TextButton &button) {

View File

@ -430,7 +430,7 @@ inline u8 ChunkMeshBuilder::getLightForVertex(Light light, s8f x, s8f y, s8f z,
return (light == Light::Sun) ? chunk.getSunlight(x, y, z) : chunk.getTorchlight(x, y, z);
};
// Get light values for surrounding nodes
// Get light values for surrounding blocks
s8 lightValues[4] = {
getLight(chunk, surroundingBlocks[0].x, surroundingBlocks[0].y, surroundingBlocks[0].z),
getLight(chunk, surroundingBlocks[1].x, surroundingBlocks[1].y, surroundingBlocks[1].z),
@ -441,8 +441,8 @@ inline u8 ChunkMeshBuilder::getLightForVertex(Light light, s8f x, s8f y, s8f z,
u8 count = 0, total = 0;
for (u8 i = 0 ; i < 4 ; ++i) {
// Fix light approximation
// if (i == 3 && lightValues[i] > lightValues[0] && !lightValues[1] && !lightValues[2])
// continue;
if (i == 3 && lightValues[i] > lightValues[0] && !lightValues[1] && !lightValues[2])
continue;
// If the chunk is initialized, add the light value to the total
// But only add dark blocks if AO is set on Smooth Lighting