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.
This commit is contained in:
Gorgious56
2026-06-30 15:36:03 +02:00
parent 301dae103c
commit c95c1905ed
@@ -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