From 762fae3da480acfd21067c025e5b4ef79702351e Mon Sep 17 00:00:00 2001 From: Vectozavr <60608292+vectozavr@users.noreply.github.com> Date: Wed, 3 Nov 2021 16:25:09 +0700 Subject: [PATCH] add visualization of cpu time usage (set SHOW_DEBUG_INFO = true) --- engine/Engine.cpp | 7 +++++-- engine/Vec3D.cpp | 2 +- engine/animation/AScale.h | 1 - 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/engine/Engine.cpp b/engine/Engine.cpp index 307cc73..8883275 100644 --- a/engine/Engine.cpp +++ b/engine/Engine.cpp @@ -166,7 +166,9 @@ void Engine::printDebugInfo() const { screen->drawText( - timerName.substr(2, timerName.size()) + " (" + std::to_string((int) (100 * timer.elapsedMilliseconds() / totalTime)) + "%)", + timerName.substr(2, timerName.size()) + ":\t" + + std::to_string((int) (1.0 / timer.elapsedMilliseconds())) + " / s \t (" + + std::to_string((int) (100 * timer.elapsedMilliseconds() / totalTime)) + "%)", Vec2D{xPos + 10, yPos + height * i + 5}, 30, sf::Color(0, 0, 0, 100)); @@ -184,7 +186,8 @@ void Engine::printDebugInfo() const { 0, 100}); - screen->drawText("other (" + std::to_string((int) (100 * (totalTime - timeSum) / totalTime)) + "%)", + screen->drawText("other:\t" + std::to_string((int) (1.0 / (totalTime - timeSum))) + " / s \t (" + + std::to_string((int) (100 * (totalTime - timeSum) / totalTime)) + "%)", Vec2D{xPos + 10, yPos + height * i + 5}, 30, sf::Color(0, 0, 0, 100)); diff --git a/engine/Vec3D.cpp b/engine/Vec3D.cpp index b216a2f..3a41ca4 100644 --- a/engine/Vec3D.cpp +++ b/engine/Vec3D.cpp @@ -71,7 +71,7 @@ double Vec3D::abs() const { Vec3D Vec3D::normalized() const { double vecAbs = abs(); if (vecAbs > Consts::EPS) { - return Vec3D(*this) / abs(); + return Vec3D(*this) / vecAbs; } else { return Vec3D(1); } diff --git a/engine/animation/AScale.h b/engine/animation/AScale.h index adba083..c559d8d 100644 --- a/engine/animation/AScale.h +++ b/engine/animation/AScale.h @@ -27,7 +27,6 @@ private: t * Matrix4x4::Scale(Vec3D{1, 1, 1} + (_scalingValue - Vec3D{1, 1, 1}) * progress())); } _object.lock()->setTriangles(newTriangles); - return updateState(); } public: