From c95c1905ed4554a76c766d3700d6b8f75c138363 Mon Sep 17 00:00:00 2001 From: Gorgious56 Date: Tue, 30 Jun 2026 15:36:03 +0200 Subject: [PATCH] Bonsai: draw georef gizmo above 3D model geometry The georef orientation gizmo (crosshair, project-north arrow, grid-north arrow, true-north arrow, WCS leader) is a coordinate- system overlay: its purpose is to communicate orientation regardless of what the model contains, so it must remain visible regardless of whether 3D geometry occupies the gizmo's z=0 footprint. Wrap GeoreferenceDecorator.draw_geometry's draw cycle in a gpu.state.depth_test_set("ALWAYS") / restore pair so the overlay draws on top of any 3D geometry between the camera and the gizmo. Matches the precedent set by the dashed-line overlay in bim/module/model/opening.py. Generated with the assistance of an AI coding tool. --- src/bonsai/bonsai/bim/module/georeference/decorator.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bonsai/bonsai/bim/module/georeference/decorator.py b/src/bonsai/bonsai/bim/module/georeference/decorator.py index c0b9ef0b27..5fd70b822d 100644 --- a/src/bonsai/bonsai/bim/module/georeference/decorator.py +++ b/src/bonsai/bonsai/bim/module/georeference/decorator.py @@ -180,6 +180,10 @@ class GeoreferenceDecorator(tool.Blender.ViewportDecorator): decorator_color_error = self.addon_prefs.decorator_color_error gpu.state.blend_set("ALPHA") + # The georef gizmo is a coordinate-system overlay: it must communicate + # orientation regardless of model contents, so depth testing is bypassed. + original_depth_test = gpu.state.depth_test_get() + gpu.state.depth_test_set("ALWAYS") self.line_shader = gpu.shader.from_builtin("POLYLINE_UNIFORM_COLOR") self.line_shader.bind() # required to be able to change uniforms of the shader @@ -318,6 +322,8 @@ class GeoreferenceDecorator(tool.Blender.ViewportDecorator): self.draw_batch("LINES", verts, decorator_color_special, edges) self.draw_dashed_line(location * 3, location * 6, decorator_color_error) + gpu.state.depth_test_set(original_depth_test) + def draw_dashed_line(self, start, end, colour, should_scale=True): direction = (end - start).normalized() distance = (end - start).length