--- tools\blender\meshy_old_port\reskin.py +++ tools\blender\meshy_old_port\reskin.py @@ -175,39 +175,17 @@ log("zones: rigid", nrig, "limited", nlim, "rigid-mode" if RIGID else "") SPLIT = RIGID and os.environ.get("SPLIT") == "1" if SPLIT: - # Stone: cut the surface along block borders so each block moves as one rigid piece. A face takes - # the bone most of its corners follow; edges between faces of different bones are split, and every - # vertex then follows its faces' bone alone. Blocks part slightly at the joints instead of smearing. - bm = bmesh.new(); bm.from_mesh(me.data) - deform = bm.verts.layers.deform.verify() - def bone_of(vert): - d = vert[deform] - return max(d.items(), key=lambda kv: kv[1])[0] if d else -1 - face_bone = {} - for f in bm.faces: - votes = collections.Counter(bone_of(v) for v in f.verts) - face_bone[f.index] = votes.most_common(1)[0][0] - border = [e for e in bm.edges if len(e.link_faces) == 2 - and face_bone[e.link_faces[0].index] != face_bone[e.link_faces[1].index]] - bmesh.ops.split_edges(bm, edges=border) - bm.faces.ensure_lookup_table() - owner = {} - for f in bm.faces: - for v in f.verts: - owner.setdefault(v.index, collections.Counter())[face_bone[f.index]] += 1 - for v in bm.verts: - if v.index in owner: - b = owner[v.index].most_common(1)[0][0] - v[deform].clear(); v[deform][b] = 1.0 - bm.to_mesh(me.data); bm.free() - log("split along", len(border), "border edges ->", len(me.data.vertices), "vertices") + # Close every rigid piece, including its interior joint faces. + sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) + from close_rigid_blocks import seal_rigid_blocks + log("sealed rigid blocks", seal_rigid_blocks(me)) elif RIGID: # blend only along block borders; block interiors keep a single bone weight_ops((bpy.ops.object.vertex_group_smooth, dict(group_select_mode="ALL", factor=0.5, repeat=int(os.environ.get("SEAM", "3")))), (bpy.ops.object.vertex_group_normalize_all, dict(lock_active=False))) elif Z and not KEEP: weight_ops((bpy.ops.object.vertex_group_smooth, dict(group_select_mode="ALL", factor=0.3, repeat=1)), (bpy.ops.object.vertex_group_normalize_all, dict(lock_active=False))) -if Z.get("rigid") and (RIGID or not KEEP): +if Z.get("rigid") and (RIGID or not KEEP) and not SPLIT: reassert_rigid() cnt = collections.Counter()