mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 23:00:53 +00:00
bim.assign_class - flip normals if matrix is negative #6500
object.transform_apply doesn't preserve normals (https://projects.blender.org/blender/blender/issues/102266)
This commit is contained in:
@@ -229,12 +229,19 @@ class AssignClass(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if self.should_add_representation and isinstance(obj.data, bpy.types.Mesh) and obj.data.polygons:
|
if self.should_add_representation and isinstance(obj.data, bpy.types.Mesh) and obj.data.polygons:
|
||||||
|
# Apply scale.
|
||||||
if obj.scale != (1, 1, 1):
|
if obj.scale != (1, 1, 1):
|
||||||
if obj.data.users > 1:
|
if obj.data.users > 1:
|
||||||
bpy.ops.object.make_single_user(
|
bpy.ops.object.make_single_user(
|
||||||
object=True, obdata=True, material=False, animation=False, obdata_animation=False
|
object=True, obdata=True, material=False, animation=False, obdata_animation=False
|
||||||
)
|
)
|
||||||
|
is_negative = obj.matrix_world.is_negative
|
||||||
bpy.ops.object.transform_apply(location=False, rotation=False, scale=True, properties=False)
|
bpy.ops.object.transform_apply(location=False, rotation=False, scale=True, properties=False)
|
||||||
|
# object.transform_apply is losing normals.
|
||||||
|
if is_negative:
|
||||||
|
for polygon in obj.data.polygons:
|
||||||
|
polygon.flip()
|
||||||
|
|
||||||
if tool.Geometry.mesh_has_loose_geometry(obj.data):
|
if tool.Geometry.mesh_has_loose_geometry(obj.data):
|
||||||
self.report(
|
self.report(
|
||||||
{"WARNING"},
|
{"WARNING"},
|
||||||
|
|||||||
Reference in New Issue
Block a user