Fix fan speed-up for overhangs fails when "Only overhangs" is enabled #1198

Open
opened 2026-04-05 16:59:59 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @tome9111991 on 1/3/2026

Description

Summary

This PR fixes a bug where the "Fan speed-up time" feature (fan_speedup_time) would fail to trigger for overhangs when the restriction option "Only overhangs" (fan_speedup_overhangs) was enabled.

Additionally, it refines the logic to ensure that bridge is correctly excluded from this speed-up, applying it strictly to overhang perimeters (walls) as intended.

The Problem

When fan_speedup_overhangs is enabled, the FanMover post-processor restricts the fan speed-up behavior to extrusion roles explicitly identified as erOverhangPerimeter. However, this detection was unreliable for two main reasons:

  1. Ambiguous Role Classification: OrcaSlicer often classifies less steep overhangs as ExternalPerimeter ("Outer wall") in the G-code comments (TYPE:Outer wall), while still applying overhang-specific cooling via M106. In these cases, the FanMover would see an ExternalPerimeter role and correctly deny the speed-up, effectively disabling the feature for these overhangs.
  2. Parsing Issue: The G-code parser in FanMover extracted the role string from ;TYPE: comments but included trailing newline characters. This caused string comparisons (e.g., string_to_role) to fail, resulting in the role being unidentified.

Furthermore, bridge infill (erBridgeInfill) shares some internal logic with overhangs, leading to unwanted fan speed-ups on internal bridge structures if not properly filtered.

The Solution

This PR implements a robust, hint-based solution that aligns with OrcaSlicer's existing G-code marker architecture:

  1. Explicit Hinting in G-Code Generator:

    • Modified GCode.cpp to inject a specific hint comment (;_FAN_MOVER_HINT_OVERHANG) into the G-code stream.
    • Crucially, this hint is ONLY emitted when an overhang cooling sequence starts AND the current extrusion role is a Perimeter (is_perimeter()).
    • This ensures that overhang walls (even if labeled as "Outer wall") are detected, while bridge infill is strictly excluded.
  2. Enhanced Detection in FanMover:

    • Updated FanMover.cpp to listen for this hint. If the hint is detected, the speed-up is allowed for the subsequent fan command, bypassing the strict role check.
    • Added trimming of trailing newline/carriage return characters to fix the role string parsing bug.
    • Added a safeguard to reset the hint if the extrusion role changes to a non-perimeter type, preventing false positives.
  3. Code Quality:

    • Fixed compilation warnings related to std::move on temporary objects.
    • Improved logical grouping in boolean expressions for better readability.

Verification

  • Scenario 1: "Only overhangs" ENABLED

    • Before: Fan speed-up did not occur on most overhangs (fan ramp-up happened exactly at the start of the move).
    • After: Fan speed-up correctly occurs fan_speedup_time seconds before the overhang wall starts.
    • After: Fan speed-up does not occur for bridge or other non-overhang speed increases (e.g., layer time logic).
  • Scenario 2: "Only overhangs" DISABLED

    • Feature continues to work as before, accelerating fan speed changes globally.

Without this PR:
grafik

with PR:
grafik

Fixes:
https://github.com/OrcaSlicer/OrcaSlicer/issues/9987

*Originally created by @tome9111991 on 1/3/2026* ## Description ### Summary This PR fixes a bug where the "Fan speed-up time" feature (`fan_speedup_time`) would fail to trigger for overhangs when the restriction option "Only overhangs" (`fan_speedup_overhangs`) was enabled. Additionally, it refines the logic to ensure that bridge is correctly excluded from this speed-up, applying it strictly to overhang perimeters (walls) as intended. ### The Problem When `fan_speedup_overhangs` is enabled, the `FanMover` post-processor restricts the fan speed-up behavior to extrusion roles explicitly identified as `erOverhangPerimeter`. However, this detection was unreliable for two main reasons: 1. **Ambiguous Role Classification:** OrcaSlicer often classifies less steep overhangs as `ExternalPerimeter` ("Outer wall") in the G-code comments (`TYPE:Outer wall`), while still applying overhang-specific cooling via `M106`. In these cases, the `FanMover` would see an `ExternalPerimeter` role and correctly deny the speed-up, effectively disabling the feature for these overhangs. 2. **Parsing Issue:** The G-code parser in `FanMover` extracted the role string from `;TYPE:` comments but included trailing newline characters. This caused string comparisons (e.g., `string_to_role`) to fail, resulting in the role being unidentified. Furthermore, bridge infill (`erBridgeInfill`) shares some internal logic with overhangs, leading to unwanted fan speed-ups on internal bridge structures if not properly filtered. ### The Solution This PR implements a robust, hint-based solution that aligns with OrcaSlicer's existing G-code marker architecture: 1. **Explicit Hinting in G-Code Generator:** - Modified `GCode.cpp` to inject a specific hint comment (`;_FAN_MOVER_HINT_OVERHANG`) into the G-code stream. - **Crucially**, this hint is ONLY emitted when an overhang cooling sequence starts AND the current extrusion role is a **Perimeter** (`is_perimeter()`). - This ensures that overhang walls (even if labeled as "Outer wall") are detected, while bridge infill is strictly excluded. 2. **Enhanced Detection in FanMover:** - Updated `FanMover.cpp` to listen for this hint. If the hint is detected, the speed-up is allowed for the subsequent fan command, bypassing the strict role check. - Added trimming of trailing newline/carriage return characters to fix the role string parsing bug. - Added a safeguard to reset the hint if the extrusion role changes to a non-perimeter type, preventing false positives. 3. **Code Quality:** - Fixed compilation warnings related to `std::move` on temporary objects. - Improved logical grouping in boolean expressions for better readability. ### Verification - **Scenario 1: "Only overhangs" ENABLED** - **Before:** Fan speed-up did not occur on most overhangs (fan ramp-up happened exactly at the start of the move). - **After:** Fan speed-up correctly occurs `fan_speedup_time` seconds before the overhang wall starts. - **After:** Fan speed-up does **not** occur for bridge or other non-overhang speed increases (e.g., layer time logic). - **Scenario 2: "Only overhangs" DISABLED** - Feature continues to work as before, accelerating fan speed changes globally. Without this PR: <img width="1246" height="408" alt="grafik" src="https://github.com/user-attachments/assets/0218be32-f406-4717-b87a-edf2e5ba8f81" /> with PR: <img width="1174" height="430" alt="grafik" src="https://github.com/user-attachments/assets/8b4d9801-ba5c-4417-9db4-c6ea63f5caff" /> Fixes: https://github.com/OrcaSlicer/OrcaSlicer/issues/9987
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/OrcaSlicer#1198