From deb96742e020be5e83314a5a28ddba3c96df6f6e Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Mon, 3 Jul 2023 18:31:12 +1000 Subject: [PATCH] Prevent particle copy, tweak debugging some more probably not too time-saving --- assets/opensb/interface.config.patch | 2 +- source/client/StarClientApplication.cpp | 18 +++++++++--------- source/game/StarUniverseClient.cpp | 8 ++++---- source/game/StarWorldClient.cpp | 9 +++++---- source/game/StarWorldRenderData.hpp | 6 +++--- source/rendering/StarWorldPainter.cpp | 9 ++++++--- 6 files changed, 28 insertions(+), 24 deletions(-) diff --git a/assets/opensb/interface.config.patch b/assets/opensb/interface.config.patch index 5df1eb5..85e81cf 100644 --- a/assets/opensb/interface.config.patch +++ b/assets/opensb/interface.config.patch @@ -16,7 +16,7 @@ "debugFont" : "mono", "debugFontSize" : 7, - "debugFontDirectives" : "?border=1;0007;0000", + "debugFontDirectives" : "?border=1;2224;0000", // Change planet name to support the new internal string formatting. "planetNameFormatString" : "- {} -", diff --git a/source/client/StarClientApplication.cpp b/source/client/StarClientApplication.cpp index 86dc0c2..de51f99 100644 --- a/source/client/StarClientApplication.cpp +++ b/source/client/StarClientApplication.cpp @@ -389,23 +389,23 @@ void ClientApplication::render() { auto start = Time::monotonicMicroseconds(); renderer->switchEffectConfig("world"); worldClient->render(m_renderData, TilePainter::BorderTileSize); - LogMap::set("render_world_client", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start)); + LogMap::set("client_render_world_client", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start)); start = Time::monotonicMicroseconds(); m_worldPainter->render(m_renderData, [&]() { worldClient->waitForLighting(); }); - LogMap::set("render_world_painter", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start)); + LogMap::set("client_render_world_painter", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start)); start = Time::monotonicMicroseconds(); m_mainInterface->renderInWorldElements(); - LogMap::set("render_world_elements", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start)); + LogMap::set("client_render_world_elements", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start)); renderer->switchEffectConfig("default"); - LogMap::set("render_world_total", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start)); + LogMap::set("client_render_world_total", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start)); } auto start = Time::monotonicMicroseconds(); m_mainInterface->render(); m_cinematicOverlay->render(); - LogMap::set("render_interface", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start)); + LogMap::set("client_render_interface", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start)); } if (!m_errorScreen->accepted()) @@ -862,14 +862,14 @@ void ClientApplication::updateRunning() { Vec2F aimPosition = m_player->aimPosition(); float fps = appController()->renderFps(); - LogMap::set("render_rate", strf("{:4.2f} FPS ({:4.2f}ms)", fps, (1.0f / appController()->renderFps()) * 1000.0f)); - LogMap::set("update_rate", strf("{:4.2f}Hz", appController()->updateRate())); + LogMap::set("client_render_rate", strf("{:4.2f} FPS ({:4.2f}ms)", fps, (1.0f / appController()->renderFps()) * 1000.0f)); + LogMap::set("client_update_rate", strf("{:4.2f}Hz", appController()->updateRate())); LogMap::set("player_pos", strf("[ ^#f45;{:4.2f}^reset;, ^#49f;{:4.2f}^reset; ]", m_player->position()[0], m_player->position()[1])); LogMap::set("player_vel", strf("[ ^#f45;{:4.2f}^reset;, ^#49f;{:4.2f}^reset; ]", m_player->velocity()[0], m_player->velocity()[1])); LogMap::set("player_aim", strf("[ ^#f45;{:4.2f}^reset;, ^#49f;{:4.2f}^reset; ]", aimPosition[0], aimPosition[1])); if (m_universeClient->worldClient()) { - LogMap::set("liquid_level", strf("{}", m_universeClient->worldClient()->liquidLevel(Vec2I::floor(aimPosition)).level)); - LogMap::set("dungeon_id", strf("{}", m_universeClient->worldClient()->dungeonId(Vec2I::floor(aimPosition)))); + LogMap::set("tile_liquid_level", strf("{}", m_universeClient->worldClient()->liquidLevel(Vec2I::floor(aimPosition)).level)); + LogMap::set("tile_dungeon_id", strf("{}", m_universeClient->worldClient()->dungeonId(Vec2I::floor(aimPosition)))); } if (m_mainInterface->currentState() == MainInterface::ReturnToTitle) diff --git a/source/game/StarUniverseClient.cpp b/source/game/StarUniverseClient.cpp index e025517..783c5d3 100644 --- a/source/game/StarUniverseClient.cpp +++ b/source/game/StarUniverseClient.cpp @@ -279,12 +279,12 @@ void UniverseClient::update() { m_celestialDatabase->cleanup(); if (auto netStats = m_connection->incomingStats()) { - LogMap::set("client_incoming_bps", netStats->bytesPerSecond); - LogMap::set("client_worst_incoming", strf("{}:{}", PacketTypeNames.getRight(netStats->worstPacketType), netStats->worstPacketSize)); + LogMap::set("net_incoming_bps", netStats->bytesPerSecond); + LogMap::set("net_worst_incoming", strf("{}:{}", PacketTypeNames.getRight(netStats->worstPacketType), netStats->worstPacketSize)); } if (auto netStats = m_connection->outgoingStats()) { - LogMap::set("client_outgoing_bps", netStats->bytesPerSecond); - LogMap::set("client_worst_outgoing", + LogMap::set("net_outgoing_bps", netStats->bytesPerSecond); + LogMap::set("net_worst_outgoing", strf("{}:{}", PacketTypeNames.getRight(netStats->worstPacketType), netStats->worstPacketSize)); } } diff --git a/source/game/StarWorldClient.cpp b/source/game/StarWorldClient.cpp index accf025..552b6e2 100644 --- a/source/game/StarWorldClient.cpp +++ b/source/game/StarWorldClient.cpp @@ -535,8 +535,8 @@ void WorldClient::render(WorldRenderData& renderData, unsigned bufferTiles) { } } - renderData.particles = m_particles->particles(); - LogMap::set("active_particles", renderData.particles.size()); + renderData.particles = &m_particles->particles(); + LogMap::set("client_render_particle_count", renderData.particles->size()); renderData.skyRenderData = m_sky->renderData(); @@ -569,9 +569,10 @@ void WorldClient::render(WorldRenderData& renderData, unsigned bufferTiles) { } } + auto functionDatabase = Root::singleton().functionDatabase(); for (auto& layer : renderData.parallaxLayers) { if (!layer.timeOfDayCorrelation.empty()) - layer.alpha *= clamp((float)Root::singleton().functionDatabase()->function(layer.timeOfDayCorrelation)->evaluate(m_sky->timeOfDay() / m_sky->dayLength()), 0.0f, 1.0f); + layer.alpha *= clamp((float)functionDatabase->function(layer.timeOfDayCorrelation)->evaluate(m_sky->timeOfDay() / m_sky->dayLength()), 0.0f, 1.0f); } stableSort(renderData.parallaxLayers, [](ParallaxLayer const& a, ParallaxLayer const& b) { @@ -1458,7 +1459,7 @@ void WorldClient::lightingMain() { m_lightingCalculator.calculate(m_renderData->lightMap); m_renderData = nullptr; - LogMap::set("render_world_async_lighting_calc_time", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start)); + LogMap::set("client_render_world_async_light_calc", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start)); } m_lightingCond.wait(m_lightingMutex); diff --git a/source/game/StarWorldRenderData.hpp b/source/game/StarWorldRenderData.hpp index b13fef5..6d8c3b1 100644 --- a/source/game/StarWorldRenderData.hpp +++ b/source/game/StarWorldRenderData.hpp @@ -30,7 +30,7 @@ struct WorldRenderData { Image tileLightMap; List entityDrawables; - List particles; + List const* particles; List overheadBars; List nametags; @@ -48,10 +48,10 @@ struct WorldRenderData { }; inline void WorldRenderData::clear() { - tiles.clear(); + tiles.resize({0, 0}); // keep reserved entityDrawables.clear(); - particles.clear(); + particles = nullptr; overheadBars.clear(); nametags.clear(); backgroundOverlays.clear(); diff --git a/source/rendering/StarWorldPainter.cpp b/source/rendering/StarWorldPainter.cpp index 9a93365..7bcbb45 100644 --- a/source/rendering/StarWorldPainter.cpp +++ b/source/rendering/StarWorldPainter.cpp @@ -72,7 +72,7 @@ void WorldPainter::render(WorldRenderData& renderData, function lightWai if (lightWaiter) { auto start = Time::monotonicMicroseconds(); lightWaiter(); - LogMap::set("render_world_async_lighting_wait_time", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start)); + LogMap::set("client_render_world_async_light_wait", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start)); } if (renderData.isFullbright) { @@ -166,7 +166,10 @@ void WorldPainter::renderParticles(WorldRenderData& renderData, Particle::Layer const int textParticleFontSize = m_assets->json("/rendering.config:textParticleFontSize").toInt(); const RectF particleRenderWindow = RectF::withSize(Vec2F(), Vec2F(m_camera.screenSize())).padded(m_assets->json("/rendering.config:particleRenderWindowPadding").toInt()); - for (Particle const& particle : renderData.particles) { + if (!renderData.particles) + return; + + for (Particle const& particle : *renderData.particles) { if (layer != particle.layer) continue; @@ -218,7 +221,7 @@ void WorldPainter::renderParticles(WorldRenderData& renderData, Particle::Layer } else if (particle.type == Particle::Type::Text) { Vec2F position = m_camera.worldToScreen(particle.position); - unsigned size = round((float)textParticleFontSize * m_camera.pixelRatio() * particle.size); + int size = min(128.0f, round((float)textParticleFontSize * m_camera.pixelRatio() * particle.size)); if (size > 0) { m_textPainter->setFontSize(size); m_textPainter->setFontColor(particle.color.toRgba());