Skip to content

Commit

Permalink
Add support for changes made in Blender 4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sercero committed Mar 31, 2024
1 parent c546c42 commit f93b6f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 6 additions & 2 deletions io_ogre/ogre/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ def dot_mesh(ob, path, force_name=None, ignore_shape_animation=False, normals=Tr
mesh.calc_tangents(uvmap=mesh.uv_layers.active.name)
else:
# calc_tangents() already calculates split normals for us
mesh.calc_normals_split()
if bpy.app.version < (4, 1, 0):
mesh.calc_normals_split()

progressbar = util.ProgressBar("Faces", len(mesh.polygons))

Expand All @@ -247,7 +248,10 @@ def dot_mesh(ob, path, force_name=None, ignore_shape_animation=False, normals=Tr
for loop_idx, idx in zip(F.loop_indices, tri):
v = mesh.vertices[ idx ]

nx,ny,nz = swap( mesh.loops[ loop_idx ].normal )
if bpy.app.version < (3, 6, 0):
nx,ny,nz = swap( mesh.loops[ loop_idx ].normal )
else:
nx,ny,nz = swap( mesh.corner_normals[ loop_idx ].vector )

if tangents != 0:
tx,ty,tz = swap( mesh.loops[ loop_idx ].tangent )
Expand Down
5 changes: 2 additions & 3 deletions io_ogre/ogre/ogre_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,6 @@ def bCreateSubMeshes(meshData, meshName):
me.vertices.foreach_set("co", unpack_list(verts))

if hasNormals:
me.create_normals_split()
me.vertices.foreach_set("normal", unpack_list(normals))

me.polygons.foreach_set("loop_start", [i for i in range(0, FaceLength * 3, 3)])
Expand Down Expand Up @@ -1349,9 +1348,9 @@ def bCreateSubMeshes(meshData, meshName):

# Try to set custom normals
if hasNormals:
me.polygons.foreach_set("use_smooth", [True] * len(me.polygons))
if bpy.app.version < (4, 1, 0):
me.use_auto_smooth = True
me.normals_split_custom_set_from_vertices(normals)
me.use_auto_smooth = True

Report.orig_vertices = len( me.vertices )
Report.faces += len( me.polygons )
Expand Down

0 comments on commit f93b6f1

Please sign in to comment.