From 3c8ab262747392ecf3a3cfa76a75cca7fef1218b Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 13 Jan 2026 09:30:31 +1100 Subject: [PATCH] Do not scale georef WCS decorator if it is <1km (i.e. small site definition) Previously it was scaled which misled users into thinking the point was in the wrong location. --- .../bim/module/georeference/decorator.py | 28 +++++++++++-------- .../bonsai/bim/module/georeference/prop.py | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/georeference/decorator.py b/src/bonsai/bonsai/bim/module/georeference/decorator.py index 55fcbc1d64..01818e9805 100644 --- a/src/bonsai/bonsai/bim/module/georeference/decorator.py +++ b/src/bonsai/bonsai/bim/module/georeference/decorator.py @@ -53,12 +53,13 @@ class GeoreferenceDecorator: pass cls.is_installed = False - def draw_batch(self, shader_type, content_pos, color, indices=None): + def draw_batch(self, shader_type, content_pos, color, indices=None, should_scale=True): if not tool.Blender.validate_shader_batch_data(content_pos, indices): return props = tool.Georeference.get_georeference_props() - self.scale = props.visualization_scale - content_pos = [v * self.scale for v in content_pos] + if should_scale: + scale = tool.Georeference.get_georeference_props().visualization_scale + content_pos = [v * scale for v in content_pos] shader = self.line_shader if shader_type == "LINES" else self.shader batch = batch_for_shader(shader, shader_type, {"pos": content_pos}, indices=indices) shader.uniform_float("color", color) @@ -141,12 +142,13 @@ class GeoreferenceDecorator: if wcs["blender_location"].length < 1000: position = wcs["blender_location"].copy() + position -= Vector((0, 0.1, 0)) + self.draw_text_at_position(context, text, position, should_scale=False) else: position = wcs["blender_location"].normalized() * 3 text += "\n(Warning: Actual XYZ Not Shown)" - position -= Vector((0, 0.1, 0)) - - self.draw_text_at_position(context, text, position) + position -= Vector((0, 0.1, 0)) + self.draw_text_at_position(context, text, position) if props.has_blender_offset: text = "IFC Local Origin" @@ -165,8 +167,10 @@ class GeoreferenceDecorator: self.draw_text_at_position(context, text, location) blf.disable(self.font_id, blf.SHADOW) - def draw_text_at_position(self, context, text, position): - position = [v * self.scale for v in position] + def draw_text_at_position(self, context, text, position, should_scale=True): + if should_scale: + scale = tool.Georeference.get_georeference_props().visualization_scale + position = [v * scale for v in position] coords_2d = location_3d_to_region_2d(context.region, context.region_data, position) if not coords_2d: return @@ -309,8 +313,8 @@ class GeoreferenceDecorator: if wcs["blender_location"].length < 1000: verts = [Vector((0, 0, 0)), wcs["blender_location"]] edges = [[0, 1]] - self.draw_batch("LINES", verts, decorator_color_special, edges) - self.draw_batch("POINTS", verts[1:], decorator_color_special) + self.draw_batch("LINES", verts, decorator_color_special, edges, should_scale=False) + self.draw_batch("POINTS", verts[1:], decorator_color_special, should_scale=False) else: location = wcs["blender_location"].normalized() edges = [[0, 1]] @@ -332,7 +336,7 @@ class GeoreferenceDecorator: self.draw_batch("LINES", verts, decorator_color_special, edges) self.draw_dashed_line(location * 3, location * 6, decorator_color_error) - def draw_dashed_line(self, start, end, colour): + def draw_dashed_line(self, start, end, colour, should_scale=True): direction = (end - start).normalized() distance = (end - start).length current_distance = Vector((0, 0, 0)) @@ -347,7 +351,7 @@ class GeoreferenceDecorator: edges = [[i, i + 1] for i in range(0, len(points), 2)] verts = points - self.draw_batch("LINES", verts, colour, edges) + self.draw_batch("LINES", verts, colour, edges, should_scale=should_scale) def calculate_angles(self, context): self.pn_angle = 0.0 diff --git a/src/bonsai/bonsai/bim/module/georeference/prop.py b/src/bonsai/bonsai/bim/module/georeference/prop.py index 0a5eecf4c1..1b6088556b 100644 --- a/src/bonsai/bonsai/bim/module/georeference/prop.py +++ b/src/bonsai/bonsai/bim/module/georeference/prop.py @@ -215,7 +215,7 @@ class BIMGeoreferenceProperties(PropertyGroup): description="Affects the georeference decorator size", default=1, soft_min=0.1, - soft_max=50, + soft_max=100, ) grid_north_angle: StringProperty(name="Grid North Angle", update=update_grid_north_angle) x_axis_abscissa: StringProperty(name="X Axis Abscissa", update=update_grid_north_vector)