From 55cc6d793da04e2e5803748fbe339c997bd5f9a1 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Fri, 29 Mar 2024 02:54:17 +1100 Subject: [PATCH] wire interface: fetch render vars on init instead of every wire (wtf?) --- source/base/StarCellularLighting.cpp | 2 +- source/frontend/StarWireInterface.cpp | 33 +++++++++------------------ source/frontend/StarWireInterface.hpp | 10 ++++++++ 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/source/base/StarCellularLighting.cpp b/source/base/StarCellularLighting.cpp index cefd751..ebca0ad 100644 --- a/source/base/StarCellularLighting.cpp +++ b/source/base/StarCellularLighting.cpp @@ -154,7 +154,7 @@ void CellularLightingCalculator::calculate(Lightmap& output) { output = Lightmap(arrayMax[0] - arrayMin[0], arrayMax[1] - arrayMin[1]); - float brightnessLimit = m_config.getFloat("brightnessLimit", 1.5f); + float brightnessLimit = m_config.getFloat("brightnessLimit"); if (m_monochrome) { for (size_t x = arrayMin[0]; x < arrayMax[0]; ++x) { diff --git a/source/frontend/StarWireInterface.cpp b/source/frontend/StarWireInterface.cpp index 7238218..5382cbb 100644 --- a/source/frontend/StarWireInterface.cpp +++ b/source/frontend/StarWireInterface.cpp @@ -26,6 +26,17 @@ WirePane::WirePane(WorldClientPtr worldClient, PlayerPtr player, WorldPainterPtr m_outSize = Vec2F(context()->textureSize("/interface/wires/outbound.png")) / TilePixels; m_nodeSize = Vec2F(1.8f, 1.8f); + JsonObject config = assets->json("/player.config:wireConfig").toObject(); + m_minBeamWidth = config.get("minWireWidth").toFloat(); + m_maxBeamWidth = config.get("maxWireWidth").toFloat(); + m_beamWidthDev = config.value("wireWidthDev", (m_maxBeamWidth - m_minBeamWidth) / 3).toFloat(); + m_minBeamTrans = config.get("minWireTrans").toFloat(); + m_maxBeamTrans = config.get("maxWireTrans").toFloat(); + m_beamTransDev = config.value("wireTransDev", (m_maxBeamTrans - m_minBeamTrans) / 3).toFloat(); + m_innerBrightnessScale = config.get("innerBrightnessScale").toFloat(); + m_firstStripeThickness = config.get("firstStripeThickness").toFloat(); + m_secondStripeThickness = config.get("secondStripeThickness").toFloat(); + setTitle({}, "", "Wire you looking at me like that?"); disableScissoring(); markAsContainer(); @@ -65,28 +76,6 @@ void WirePane::renderWire(Vec2F from, Vec2F to, Color baseColor) { return clamp(Random::nrandf(dev, max), min, max); }; - float m_beamWidthDev; - float m_minBeamWidth; - float m_maxBeamWidth; - float m_beamTransDev; - float m_minBeamTrans; - float m_maxBeamTrans; - float m_innerBrightnessScale; - float m_firstStripeThickness; - float m_secondStripeThickness; - - auto assets = Root::singleton().assets(); - JsonObject config = assets->json("/player.config:wireConfig").toObject(); - m_minBeamWidth = config.get("minWireWidth").toFloat(); - m_maxBeamWidth = config.get("maxWireWidth").toFloat(); - m_beamWidthDev = config.value("wireWidthDev", (m_maxBeamWidth - m_minBeamWidth) / 3).toFloat(); - m_minBeamTrans = config.get("minWireTrans").toFloat(); - m_maxBeamTrans = config.get("maxWireTrans").toFloat(); - m_beamTransDev = config.value("wireTransDev", (m_maxBeamTrans - m_minBeamTrans) / 3).toFloat(); - m_innerBrightnessScale = config.get("innerBrightnessScale").toFloat(); - m_firstStripeThickness = config.get("firstStripeThickness").toFloat(); - m_secondStripeThickness = config.get("secondStripeThickness").toFloat(); - float lineThickness = m_worldPainter->camera().pixelRatio() * rangeRand(m_beamWidthDev, m_minBeamWidth, m_maxBeamWidth); float beamTransparency = rangeRand(m_beamTransDev, m_minBeamTrans, m_maxBeamTrans); baseColor.setAlphaF(baseColor.alphaF() * beamTransparency); diff --git a/source/frontend/StarWireInterface.hpp b/source/frontend/StarWireInterface.hpp index 04a0f64..8f27b3f 100644 --- a/source/frontend/StarWireInterface.hpp +++ b/source/frontend/StarWireInterface.hpp @@ -40,6 +40,16 @@ private: Vec2F m_inSize; Vec2F m_outSize; Vec2F m_nodeSize; + + float m_beamWidthDev; + float m_minBeamWidth; + float m_maxBeamWidth; + float m_beamTransDev; + float m_minBeamTrans; + float m_maxBeamTrans; + float m_innerBrightnessScale; + float m_firstStripeThickness; + float m_secondStripeThickness; }; }