From 920f0bd1263d5813b8e4ce2a584d63fb04ff3e13 Mon Sep 17 00:00:00 2001 From: Tommaso Bianchi Date: Fri, 14 Aug 2026 21:30:27 +0200 Subject: [PATCH] CAD: keep the pick trace, stop paying for it when it is off (snaporca-txp8) Ported from snaporca 3710d34568. See that commit for the full rationale. Co-Authored-By: Claude Opus 5 (1M context) --- src/slic3r/GUI/DesignSketchTool.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/DesignSketchTool.cpp b/src/slic3r/GUI/DesignSketchTool.cpp index f80d34cac3..aeb70dfb79 100644 --- a/src/slic3r/GUI/DesignSketchTool.cpp +++ b/src/slic3r/GUI/DesignSketchTool.cpp @@ -2807,12 +2807,18 @@ DesignSketchTool::region_entity_indices_with_holes(const std::vector loops = region_loops(d.entities); - { // TEMPORARY DIAGNOSTIC: what did the sketch decompose into, and what is under the click? + // What did the sketch decompose into, and what is under the click? This is the trace that + // settled snaporca-txp8 — it prints the loop table with each loop's hole count, so + // "containment is wrong" and "the click landed elsewhere" stop being indistinguishable. + // Guarded rather than merely silent: hit_display_sketch runs on every pick, and the message + // costs a string build and a heap allocation per loop even when nothing consumes it. + if (dp_pick_trace_on()) { std::string h; for (size_t r = 0; r < loops.size(); ++r) { h += " loop" + std::to_string(r) + "(ents=" + std::to_string(loops[r].ents.size()) @@ -2949,10 +2955,15 @@ void DesignSketchTool::select_body(int body) // event that never arrived rather than a ray that missed, and the two look identical from // the UI. Set SNAPORCA_PICK_TRACE=1 and the whole press->release->ray path narrates itself // on stderr. Off by default: no cost, no noise. -static void dp_pick_trace(const char* fmt, ...) +static bool dp_pick_trace_on() { static const bool on = ::getenv("SNAPORCA_PICK_TRACE") != nullptr; - if (!on) return; + return on; +} + +static void dp_pick_trace(const char* fmt, ...) +{ + if (!dp_pick_trace_on()) return; va_list ap; va_start(ap, fmt); std::fputs("[pick] ", stderr); std::vfprintf(stderr, fmt, ap);