Share One Build Plate Tilt Up-Direction Helper Across the GUI

The bed gravity arrow, volume rendering and the painter/support gizmos each rebuilt
the tilt up-vector from build_plate_tilt_x/y; use one helper that also tolerates
presets without the keys.
This commit is contained in:
Hanif Koh
2026-09-14 17:27:33 +08:00
parent 5cd6661280
commit a8a45439db
7 changed files with 23 additions and 46 deletions
+1 -11
View File
@@ -1155,17 +1155,7 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type,
// Compute up direction accounting for build plate tilt. This is frame-invariant
// (config cannot change mid-render), so compute it once before the volume loop.
Vec3f up_direction = Vec3f::UnitZ();
{
const DynamicPrintConfig& prt_cfg = GUI::wxGetApp().preset_bundle->printers.get_edited_preset().config;
double tilt_x_deg = prt_cfg.opt_float("build_plate_tilt_x");
double tilt_y_deg = prt_cfg.opt_float("build_plate_tilt_y");
if (tilt_x_deg != 0. || tilt_y_deg != 0.) {
double tilt_x_rad = Geometry::deg2rad(tilt_x_deg);
double tilt_y_rad = Geometry::deg2rad(tilt_y_deg);
up_direction = Vec3f(float(tan(tilt_y_rad)), float(tan(tilt_x_rad)), 1.f).normalized();
}
}
const Vec3f up_direction = GUI::build_plate_tilt_up_direction().cast<float>();
for (GLVolumeWithIdAndZ& volume : to_render) {
#if ENABLE_MODIFIERS_ALWAYS_TRANSPARENT