Skip to content

Commit

Permalink
move vert group check to mesh validation loop
Browse files Browse the repository at this point in the history
  • Loading branch information
DoctorPresto committed Apr 11, 2024
1 parent 138110a commit 31e9969
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions i_scene_cp77_gltf/exporters/glb_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,18 @@ def export_cyberpunk_glb(context, filepath, export_poses, export_visible, limit_
bpy.ops.mesh.select_face_by_sides(number=3, type='NOTEQUAL', extend=False)
bpy.ops.cp77.message_box('INVOKE_DEFAULT', message="All faces must be triangulated before exporting. Untriangulated faces have been selected for you")
return {'CANCELLED'}

# Check for ungrouped vertices, if they're found, switch to edit mode and select them
ungrouped_vertices = [v for v in mesh.data.vertices if not v.groups]
if ungrouped_vertices:
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_mode(type='VERT')
try:
bpy.ops.mesh.select_ungrouped()
except RuntimeError:
bpy.ops.cp77.message_box('INVOKE_DEFAULT', message=f"No vertex groups in: {mesh.name} are assigned weights. Assign weights before exporting.")
bpy.ops.cp77.message_box('INVOKE_DEFAULT', message=f"Ungrouped vertices found and selected in: {mesh.name}")
return {'CANCELLED'}

# set the export options for meshes
options = default_cp77_options()
Expand Down Expand Up @@ -172,19 +184,6 @@ def export_cyberpunk_glb(context, filepath, export_poses, export_visible, limit_
armature.hide_set(False)
armature.select_set(True)

# Check for ungrouped vertices, if they're found, switch to edit mode and select them
ungrouped_vertices = [v for v in mesh.data.vertices if not v.groups]
if ungrouped_vertices:
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_mode(type='VERT')
try:
bpy.ops.mesh.select_ungrouped()
armature.hide_set(True)
except RuntimeError:
bpy.ops.cp77.message_box('INVOKE_DEFAULT', message=f"No vertex groups in: {obj.name} are assigned weights. Assign weights before exporting.")
bpy.ops.cp77.message_box('INVOKE_DEFAULT', message=f"Ungrouped vertices found and selected in: {obj.name}")
return {'CANCELLED'}

for bone in armature.pose.bones:
bone_names.append(bone.name)

Expand Down

0 comments on commit 31e9969

Please sign in to comment.