def scene_update_post_handler(scene):
obj = scene.objects.active
if not obj:
return
if obj.mode == "EDIT" and obj.type == "MESH":
# Ensure to have an instance of the edit bmesh in the global dictionary to retrieve it in update methods.
bm = kcl_dict.setdefault(obj.name, bmesh.from_edit_mesh(obj.data))
face = bm.faces.active # TODO: bm instance might be dead here due to previous editing.
flag_layer = bm.faces.layers.int.get("kcl_flags")
if face and flag_layer:
flags = face[flag_layer]
# Update the flags stored in the window manager.
kcl_dict["update_by_code"] = True
bpy.context.window_manager.kcl_flag = flags
bpy.context.window_manager.kcl_is_lakitu = (flags & 0x0010) != 0 # Bit 5
kcl_dict["update_by_code"] = False
else:
kcl_dict.clear()
评论列表
文章目录