wire interface: fetch render vars on init instead of every wire (wtf?)

This commit is contained in:
Kae 2024-03-29 02:54:17 +11:00
parent 8fee64013e
commit 55cc6d793d
3 changed files with 22 additions and 23 deletions

View File

@ -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) {

View File

@ -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<float>(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);

View File

@ -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;
};
}