fix(export_gltf): clear OCC custom_normal attribute before sharp edge processing

The geometry GLB from export_step_to_gltf.py contains a 'custom_normal' attribute
(CORNER, INT16_2D) from OCC tessellation. If left in place, Blender's glTF exporter
re-exports these pre-baked normals unchanged — ignoring shade_smooth_by_angle
processing and our explicit sharp edge marks.

Fix: remove the 'custom_normal' attribute from all imported mesh objects immediately
after GLB import, before applying smooth shading. Also add orphans_purge() before
export to remove palette materials (mat_0/1/2/3) that become users=0 after library
material substitution.

Same custom_normal clearing applied to blender_render.py for thumbnail renders.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-11 10:46:21 +01:00
parent a1d140d30f
commit 72123c5aa9
2 changed files with 32 additions and 0 deletions
+10
View File
@@ -342,6 +342,16 @@ def _import_glb(glb_file):
print(f"[blender_render] imported {len(parts)} part(s) from GLB: "
f"{[p.name for p in parts[:5]]}")
# Remove OCC-baked custom normals so shade_smooth_by_angle can recompute
# normals from scratch (respecting our sharp edge marks).
cleared = 0
for p in parts:
if "custom_normal" in p.data.attributes:
p.data.attributes.remove(p.data.attributes["custom_normal"])
cleared += 1
if cleared:
print(f"[blender_render] cleared OCC custom_normal from {cleared} mesh objects")
# Centre combined bbox at world origin
all_corners = []
for p in parts: