Skip to content

Commit

Permalink
1.4.6 Fix Numpy type depreciation for Blender 4 1
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienHeijmans authored Mar 29, 2024
2 parents 200b239 + 23d96f4 commit 1a234b9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"name": "QuickSnap",
"author": "Julien Heijmans",
"blender": (2, 93, 0),
'version': (1, 4, 5),
'version': (1, 4, 6),
"category": "3D View",
"description": "Quickly snap objects/vertices/curve points",
"warning": "",
Expand Down
7 changes: 4 additions & 3 deletions quicksnap_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def draw_line_3d_smooth_blend(source, target, color_a=(1, 0, 0, 1), color_b=(0,
color_fade = (color_a, color_b)

batch = batch_for_shader(shader_3d_polyline_smooth_color, 'LINES', {"pos": vertices, "color": color_fade})
shader_3d_polyline_smooth_color.uniform_float("lineWidth", line_width)
shader_3d_polyline_smooth_color.bind()
batch.draw(shader_3d_polyline_smooth_color)
if line_width != 1:
Expand Down Expand Up @@ -566,7 +567,7 @@ def draw_edge_highlight(context,
if target_object not in npdata:
npdata[target_object] = {}
if "edge_verts" not in npdata[target_object]:
arr = np.zeros(len(data.edges) * 2, dtype=np.int)
arr = np.zeros(len(data.edges) * 2, dtype=int)
data.edges.foreach_get('vertices', arr)
arr.shape = (len(data.edges), 2)
npdata[target_object]["edge_verts"] = arr
Expand Down Expand Up @@ -602,10 +603,10 @@ def draw_edge_highlight(context,
npdata[target_object] = {}
if "polygon_loop_tri_idx" not in npdata[target_object]:
data.calc_loop_triangles()
arr = np.zeros(len(data.loop_triangles), dtype=np.int)
arr = np.zeros(len(data.loop_triangles), dtype=int)
data.loop_triangles.foreach_get('polygon_index', arr)
npdata[target_object]["polygon_loop_tri_idx"] = arr
arr2 = np.zeros(len(data.loop_triangles) * 3, dtype=np.int)
arr2 = np.zeros(len(data.loop_triangles) * 3, dtype=int)
data.loop_triangles.foreach_get('vertices', arr2)
arr2.shape = (len(data.loop_triangles), 3)
npdata[target_object]["polygon_loop_verts"] = arr2
Expand Down
6 changes: 3 additions & 3 deletions quicksnap_snapdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(self, obj, object_id, perspective_matrix, width, height, width_half
edges = obj.data.edges
edge_count = len(edges)
edges_vertid_shape = (edge_count, 2)
edges_vertid = np.zeros((edge_count * 2), dtype=np.int) # [0.0, 0.0] * len(mesh.edges)
edges_vertid = np.zeros((edge_count * 2), dtype=int) # [0.0, 0.0] * len(mesh.edges)
edges.foreach_get('vertices', edges_vertid)
edges_vertid.shape = edges_vertid_shape
# Get edges center points
Expand Down Expand Up @@ -119,9 +119,9 @@ def __init__(self, obj, object_id, perspective_matrix, width, height, width_half
polygons.foreach_get('loop_total', polygon_vert_count)

polygon_vert_start_index = np.concatenate(
[np.zeros(1, dtype=np.int), np.cumsum(polygon_vert_count[1:])])
[np.zeros(1, dtype=int), np.cumsum(polygon_vert_count[1:])])

polygon_verts = np.empty(np.sum(polygon_vert_count), dtype=np.int)
polygon_verts = np.empty(np.sum(polygon_vert_count), dtype=int)
polygons.foreach_get('vertices', polygon_verts)
selected_polygon_verts = verts_selected[polygon_verts]

Expand Down

0 comments on commit 1a234b9

Please sign in to comment.