Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test bmesh from pydata index updates #4549

Merged
merged 5 commits into from
Jun 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nodes/modifier_make/clip_verts.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def process(self):
edges_out = []
faces_out = []
for verts, edges, faces in zip_long_repeat(verts_s, edges_s, faces_s):
bm = bmesh_from_pydata(verts, edges, faces, normal_update=True)
bm = bmesh_from_pydata(verts, edges, faces, normal_update=True, index_edges=True)
new_bm = truncate_vertices(bm)
bm.free()
new_verts, new_edges, new_faces = pydata_from_bmesh(new_bm)
Expand Down
6 changes: 5 additions & 1 deletion utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ def wrapped(*args, **kwargs):
duration = str_color(f"{duration:.5g} ms", 32)

msg = f"\n{func_name}: {duration}" # + display_args + display_kwargs
info(msg)
try:
info(msg)
except:
print(msg)

return result
return wrapped
19 changes: 13 additions & 6 deletions utils/sv_bmesh_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,18 @@ def bmesh_from_edit_mesh(mesh) -> ContextManager[bmesh.types.BMesh]:
finally:
bmesh.update_edit_mesh(mesh)

def bmesh_from_pydata(
verts=None, edges=[], faces=[],
markup_face_data=False, markup_edge_data=False, markup_vert_data=False,
normal_update=False, index_edges=False):

def bmesh_from_pydata(verts=None, edges=[], faces=[], markup_face_data=False, markup_edge_data=False,
markup_vert_data=False, normal_update=False):
''' verts is necessary, edges/faces are optional
normal_update, will update verts/edges/faces normals at the end
'''
"""
verts : necessary
edges / faces : optional
normal_update : optional - will update verts/edges/faces normals at the end
index_edges (bool) : optional - will make it possible for users of the bmesh to manually
iterate over any edges or do index lookups
"""

bm = bmesh.new()
bm_verts = bm.verts
Expand Down Expand Up @@ -105,7 +111,8 @@ def bmesh_from_pydata(verts=None, edges=[], faces=[], markup_face_data=False, ma
if markup_edge_data:
bm_edge[initial_index_layer] = idx

bm.edges.index_update()
if has_element(edges) or index_edges:
bm.edges.index_update()

if markup_vert_data:
bm_verts.ensure_lookup_table()
Expand Down