snap: clear raycast global variables cache

This commit is contained in:
Bruno Perdigão
2026-08-22 15:57:55 -03:00
parent ddb58e4cf0
commit 0f9717b346
3 changed files with 20 additions and 8 deletions
@@ -380,10 +380,7 @@ class PolylineOperator:
if event.value == "RELEASE" and event.type in {"ESC"}:
self.tool_state.axis_method = None
self.tool_state.plane_method = None
context.workspace.status_text_set(text=None)
PolylineDecorator.uninstall()
tool.Polyline.clear_polyline()
tool.Blender.update_viewport()
self.cleanup(context)
return {"CANCELLED"}
def handle_mouse_move(
@@ -424,6 +421,13 @@ class PolylineOperator:
tool.Blender.update_viewport()
return {"RUNNING_MODAL"}
def cleanup(self, context: bpy.Types.Context):
context.workspace.status_text_set(text=None)
PolylineDecorator.uninstall()
tool.Polyline.clear_polyline()
tool.Raycast.clear_cache()
tool.Blender.update_viewport()
def set_offset(self, context: bpy.types.Context, relating_type: ifcopenshell.entity_instance) -> None:
props = tool.Model.get_model_props()
direction_sense = props.direction_sense
@@ -3265,13 +3265,10 @@ class MeasureTool(bpy.types.Operator, PolylineOperator):
and event.value == "RELEASE"
and event.type in {"RET", "NUMPAD_ENTER", "RIGHTMOUSE"}
) or single_mode:
context.workspace.status_text_set(text=None)
self.tool_state.plane_method = None
PolylineDecorator.uninstall()
tool.Polyline.move_polyline_to_measure(context, self.input_ui)
tool.Polyline.clear_polyline()
MeasureDecorator.install(context)
tool.Blender.update_viewport()
self.cleanup(context)
return {"FINISHED"}
self.handle_keyboard_input(context, event)
+11
View File
@@ -1070,6 +1070,17 @@ class Raycast(bonsai.core.tool.Raycast):
def get_gpu_wireframe_snaps(cls, context, event, objs_to_raycast):
return cls.get_gpu_detection_snaps(context, event, objs_to_raycast)
@classmethod
def clear_cache(cls):
global _wireframe_batch_cache, _wireframe_vert_fmt, _triangle_batch_cache, _triangle_vert_fmt, _encoding_shader, _offscreen, _obj_list
_wireframe_batch_cache = {}
_wireframe_vert_fmt= None
_triangle_batch_cache= {}
_triangle_vert_fmt= None
_encoding_shader= None
_offscreen= None
_obj_list= []
@classmethod
def ray_cast_by_proximity(
cls,