mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 18:21:59 +00:00
snap: avoid creating wireframe batches for solid objects
This commit is contained in:
committed by
Bruno Perdigão
parent
e93858b8c6
commit
540c0fdc9d
@@ -695,6 +695,10 @@ class Raycast(bonsai.core.tool.Raycast):
|
|||||||
obj_slots: list[tuple] = [] # [(snap_obj, pts_start, n_pts, lines_start, n_lines), ...]
|
obj_slots: list[tuple] = [] # [(snap_obj, pts_start, n_pts, lines_start, n_lines), ...]
|
||||||
|
|
||||||
for snap_obj in objs_to_raycast:
|
for snap_obj in objs_to_raycast:
|
||||||
|
# avoids creating batches for solid objects
|
||||||
|
if (hasattr(snap_obj.data, "polygons") and len(snap_obj.data.polygons) > 0):
|
||||||
|
continue
|
||||||
|
|
||||||
batches = _ensure_wireframe_batches(snap_obj)
|
batches = _ensure_wireframe_batches(snap_obj)
|
||||||
if not batches:
|
if not batches:
|
||||||
continue
|
continue
|
||||||
@@ -728,18 +732,15 @@ class Raycast(bonsai.core.tool.Raycast):
|
|||||||
|
|
||||||
# Render to offscreen buffer
|
# Render to offscreen buffer
|
||||||
|
|
||||||
if _encoding_shader is None:
|
|
||||||
_encoding_shader = _create_encoding_shader() # same shader works for TRIS
|
|
||||||
|
|
||||||
w, h = region.width, region.height
|
w, h = region.width, region.height
|
||||||
mx = int(event.mouse_region_x)
|
mx = int(event.mouse_region_x)
|
||||||
my = int(event.mouse_region_y)
|
my = int(event.mouse_region_y)
|
||||||
|
|
||||||
# Only update offscreen when view changes
|
if _encoding_shader is None:
|
||||||
offscreen_change = (region.as_pointer(), w, h)
|
_encoding_shader = _create_encoding_shader() # same shader works for TRIS
|
||||||
if _offscreen is None or _offscreen_change != offscreen_change:
|
|
||||||
|
if _offscreen is None:
|
||||||
_offscreen = GPUOffScreen(max(w, 1), max(h, 1), format="RGBA8")
|
_offscreen = GPUOffScreen(max(w, 1), max(h, 1), format="RGBA8")
|
||||||
_offscreen_change = offscreen_change
|
|
||||||
|
|
||||||
_encoding_shader.bind()
|
_encoding_shader.bind()
|
||||||
|
|
||||||
@@ -1201,7 +1202,7 @@ class Raycast(bonsai.core.tool.Raycast):
|
|||||||
for obj, bbox_2d in objs_2d_bbox:
|
for obj, bbox_2d in objs_2d_bbox:
|
||||||
if bbox_2d:
|
if bbox_2d:
|
||||||
if tool.Raycast.intersect_mouse_2d_bounding_box(mouse_pos, bbox_2d):
|
if tool.Raycast.intersect_mouse_2d_bounding_box(mouse_pos, bbox_2d):
|
||||||
if tool.Raycast.object_is_visible_in_clipping_plane(obj):
|
if tool.Raycast.object_is_visible_in_clipping_plane(obj): # TODO Make this work only if clipping plane is active
|
||||||
objs_to_raycast.append(obj)
|
objs_to_raycast.append(obj)
|
||||||
|
|
||||||
return objs_to_raycast
|
return objs_to_raycast
|
||||||
|
|||||||
Reference in New Issue
Block a user