Fix: internal bridge angle calculation for rotated objects #995

Closed
opened 2026-04-05 16:40:43 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @tome9111991 on 1/22/2026

Description

This PR addresses issues where the automatic internal_bridge_angle calculation (when set to 0) failed to find the
optimal angle, particularly when the object is rotated in Z or when align_infill_direction_to_model is enabled.

Changes

  1. Fixed Sliding Window Logic:
    In PrintObject::bridge_over_infill -> determine_bridging_angle, there was a logic error in the sliding window
    algorithm. The condition to handle the wrap-around at the end of the angle range (1.5 * PI) checked window_start_angle
    instead of window_end_angle. This made the code unreachable, causing poor angle detection for bridges oriented near
    the boundary angles. This is now fixed.

  2. Improved CrossHatch & 3D Honeycomb Logic:
    Previously, these patterns returned a fixed angle based solely on the configured infill_direction, ignoring the
    actual object orientation. This caused bridges to align parallel to infill lines if the object was rotated.

    The new logic:

    • Removes the hardcoded early return.
    • Allows the geometry detection to run on the actual underlying anchors (infill lines).
    • Adds a 45-degree (0.25 * PI) offset to the detected angle.

    This ensures the internal bridge is always diagonal to the underlying grid, regardless of Z-rotation or
    align_infill_direction_to_model.

Related Issues
Fixes #12002

Before PR:
grafik
grafik

After PR:
grafik
grafik

Test file:

cubes.zip

*Originally created by @tome9111991 on 1/22/2026* # Description This PR addresses issues where the automatic internal_bridge_angle calculation (when set to 0) failed to find the optimal angle, particularly when the object is rotated in Z or when align_infill_direction_to_model is enabled. Changes 1. Fixed Sliding Window Logic: In PrintObject::bridge_over_infill -> determine_bridging_angle, there was a logic error in the sliding window algorithm. The condition to handle the wrap-around at the end of the angle range (1.5 * PI) checked window_start_angle instead of window_end_angle. This made the code unreachable, causing poor angle detection for bridges oriented near the boundary angles. This is now fixed. 2. Improved CrossHatch & 3D Honeycomb Logic: Previously, these patterns returned a fixed angle based solely on the configured infill_direction, ignoring the actual object orientation. This caused bridges to align parallel to infill lines if the object was rotated. The new logic: - Removes the hardcoded early return. - Allows the geometry detection to run on the actual underlying anchors (infill lines). - Adds a 45-degree (0.25 * PI) offset to the detected angle. This ensures the internal bridge is always diagonal to the underlying grid, regardless of Z-rotation or align_infill_direction_to_model. Related Issues Fixes #12002 Before PR: <img width="1082" height="567" alt="grafik" src="https://github.com/user-attachments/assets/b338234e-b736-4191-ba75-39b2fe2c1738" /> <img width="1110" height="590" alt="grafik" src="https://github.com/user-attachments/assets/6c3115ca-6a70-471e-b2c1-1ee1efdd8ea6" /> After PR: <img width="784" height="524" alt="grafik" src="https://github.com/user-attachments/assets/908adc1c-b26d-4cd4-99c0-75cbd1a4ec9e" /> <img width="860" height="502" alt="grafik" src="https://github.com/user-attachments/assets/7a1b340c-4cf7-457f-90a7-7e556d4b3618" /> Test file: [cubes.zip](https://github.com/user-attachments/files/24809242/cubes.zip)
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/OrcaSlicer#995