Skip to content

Commit

Permalink
Fix mesh baking in latest 4.1 RC
Browse files Browse the repository at this point in the history
  • Loading branch information
vbousquet committed Mar 22, 2024
1 parent e9522c6 commit 911d677
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion addons/vpx_lightmapper/vlm_meshes_baker.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,14 +457,15 @@ def create_bake_meshes(op, context):
obj_name = f'LM.{light_name}.{bake_name}'
prev_nestmap = -1
if bpy.data.objects.get(obj_name): # Expert mode: if regenerating meshes with previous nestmapping result, just reuse them
logger.info(f'\n > Reusing existing mesh for {obj_name}')
prev_nestmap = bpy.data.objects[obj_name].vlmSettings.bake_nestmap
bpy.data.objects.remove(bpy.data.objects[obj_name], do_unlink=True)
prev_nestmap = bpy.data.objects[obj_name].vlmSettings.bake_nestmap if bpy.data.objects.get(obj_name) else -1
bake_instance = bpy.data.objects.new(obj_name, bake_mesh.copy())
# Remove face shading (lightmap are not made to be shaded and the pruning process breaks the shading)
if bpy.app.version < (4, 1, 0): # FIXME Remove for Blender 4.1
bake_instance.data.free_normals_split()
bake_instance.data.use_auto_smooth = False # Don't use custom normals since we removed them
bake_instance.data.use_auto_smooth = False # Don't use custom normals since we removed them
with context.temp_override(active_object=bake_instance, selected_objects=[bake_instance]):
bpy.ops.object.shade_flat()
n_faces = len(bake_instance.data.polygons)
Expand Down

0 comments on commit 911d677

Please sign in to comment.