From 300e7bc03b80dd4bac61330817bf6d9f04d4231b Mon Sep 17 00:00:00 2001 From: salmonik Date: Mon, 26 Oct 2026 20:13:07 +0100 Subject: Use one float-precision PI constant - move PI_F into hl2h.h as constexpr 3.14159265f and remove the duplicated long-double-style literals from hl2h.cpp/esp.cpp - extra digits are compile-time only; float operations cost the same --- src/esp.cpp | 2 -- src/hl2h.cpp | 2 -- src/hl2h.h | 5 +++++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/esp.cpp b/src/esp.cpp index cd0ff36..7583f26 100644 --- a/src/esp.cpp +++ b/src/esp.cpp @@ -6,8 +6,6 @@ #include #include -static constexpr float PI_F = 3.14159265358979323846f; - // ISurface slots (binary = SDK header + 4, disassembly-confirmed) enum SurfSlot { SURF_DrawSetColor = 10, SURF_FilledRect = 12, SURF_OutlinedRect = 14, diff --git a/src/hl2h.cpp b/src/hl2h.cpp index f3aa26f..a49acc2 100644 --- a/src/hl2h.cpp +++ b/src/hl2h.cpp @@ -39,8 +39,6 @@ Vector g_cam_view{0, 0, 0}; // vector math // --------------------------------------------------------------------------- -static constexpr float PI_F = 3.14159265358979323846f; - QAngle vector_angles(const Vector &forward) { QAngle a{}; a.z = 0; diff --git a/src/hl2h.h b/src/hl2h.h index 37c849f..b86fe84 100644 --- a/src/hl2h.h +++ b/src/hl2h.h @@ -11,6 +11,11 @@ #include #include +// Shared float-precision constant. More digits than a float can hold are +// rounded at compile time and have no runtime cost; a coarse value would only +// hurt angular accuracy, never performance. +constexpr float PI_F = 3.14159265f; + // --------------------------------------------------------------------------- // logging // --------------------------------------------------------------------------- -- cgit v1.2.3