Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2006-11-10 05:23:30 +0300
committerCampbell Barton <ideasman42@gmail.com>2006-11-10 05:23:30 +0300
commitdaec99c47020ba6ec78a9f852b381690568b51ae (patch)
tree8ccffe29336a7d97f95ea278624579666613b03a /release/scripts/bpymodules/BPyMesh.py
parent7c6ffecfffbfc8165fd31d024fc74c10f664cac0 (diff)
new image names were being created with 2 ..'s
added a function to BPyMesh.py to get faces in linked groups (like split by loose parts) - but returns lists of faces only.
Diffstat (limited to 'release/scripts/bpymodules/BPyMesh.py')
-rw-r--r--release/scripts/bpymodules/BPyMesh.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/release/scripts/bpymodules/BPyMesh.py b/release/scripts/bpymodules/BPyMesh.py
index 53268cd1bbf..d0d48504d9d 100644
--- a/release/scripts/bpymodules/BPyMesh.py
+++ b/release/scripts/bpymodules/BPyMesh.py
@@ -236,7 +236,59 @@ def dictWeightFlipGroups(dict_weight, groupNames, createNewGroups):
new_wdict[flipname]= weight
return new_wdict, groupNames
+
+
+def mesh2linkedFaces(me):
+ '''
+ Splits the mesh into connected parts,
+ these parts are returned as lists of faces.
+ used for seperating cubes from other mesh elements in the 1 mesh
+ '''
+
+ # Build vert face connectivity
+ vert_faces= [[] for i in xrange(len(me.verts))]
+ for f in me.faces:
+ for v in f:
+ vert_faces[v.index].append(f)
+
+ # sort faces into connectivity groups
+ face_groups= [[f] for f in me.faces]
+ face_mapping = range(len(me.faces)) # map old, new face location
+ # Now clump faces iterativly
+ ok= True
+ while ok:
+ ok= False
+
+ for i, f in enumerate(me.faces):
+ mapped_index= face_mapping[f.index]
+ mapped_group= face_groups[mapped_index]
+
+ for v in f:
+ for nxt_f in vert_faces[v.index]:
+ if nxt_f != f:
+ nxt_mapped_index= face_mapping[nxt_f.index]
+
+ # We are not a part of the same group
+ if mapped_index != nxt_mapped_index:
+
+ ok= True
+
+ # Assign mapping to this group so they all map to this group
+ for grp_f in face_groups[nxt_mapped_index]:
+ face_mapping[grp_f.index] = mapped_index
+
+ # Move faces into this group
+ mapped_group.extend(face_groups[nxt_mapped_index])
+
+ # remove reference to the list
+ face_groups[nxt_mapped_index]= None
+
+
+ # return all face groups that are not null
+ # this is all the faces that are connected in their own lists.
+ return [fg for fg in face_groups if fg]
+
def getMeshFromObject(ob, container_mesh=None, apply_modifiers=True, vgroups=True, scn=None):
'''