Fix #2927. Continuing to make mesh editing stricter.

This commit is contained in:
Dion Moult
2023-04-02 15:02:43 +10:00
parent 65d2e51742
commit 40fb960101
2 changed files with 25 additions and 14 deletions
@@ -748,7 +748,7 @@ class OverrideModeSetEdit(bpy.types.Operator):
continue
if tool.Geometry.is_meshlike(representation):
if element.HasOpenings:
if getattr(element, "HasOpenings", None):
# Mesh elements with openings must disable openings
# so that you can edit the original topology.
core.switch_representation(
+24 -13
View File
@@ -129,21 +129,32 @@ class Geometry(blenderbim.core.tool.Geometry):
@classmethod
def get_mesh_checksum(cls, mesh):
# Get mesh data
vertices = mesh.vertices[:]
edges = mesh.edges[:]
faces = mesh.polygons[:]
# Convert mesh data to bytes
data_bytes = b""
for v in vertices:
data_bytes += struct.pack("3f", *v.co)
for e in edges:
data_bytes += struct.pack("2i", *e.vertices)
for f in faces:
data_bytes += struct.pack("%di" % len(f.vertices), *f.vertices)
if isinstance(mesh, bpy.types.Mesh):
vertices = mesh.vertices[:]
edges = mesh.edges[:]
faces = mesh.polygons[:]
# Convert mesh data to bytes
for v in vertices:
data_bytes += struct.pack("3f", *v.co)
for e in edges:
data_bytes += struct.pack("2i", *e.vertices)
for f in faces:
data_bytes += struct.pack("%di" % len(f.vertices), *f.vertices)
elif isinstance(mesh, bpy.types.Curve):
splines = mesh.splines[:]
for spline in splines:
if spline.type == "BEZIER":
for bezier_point in spline.bezier_points:
data_bytes += struct.pack("3f", *bezier_point.co)
data_bytes += struct.pack("3f", *bezier_point.handle_left)
data_bytes += struct.pack("3f", *bezier_point.handle_right)
else:
for point in spline.points:
data_bytes += struct.pack("4f", *point.co)
# Generate hash of mesh data
hasher = hashlib.sha1()
hasher.update(data_bytes)
return hasher.hexdigest()