Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mesh/meshtools.c
| Show First 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | if (ob_src != ob_dst) { | ||||
| /* For each shapekey in destination mesh: | /* For each shapekey in destination mesh: | ||||
| * - if there's a matching one, copy it across | * - if there's a matching one, copy it across | ||||
| * (will need to transform vertices into new space...). | * (will need to transform vertices into new space...). | ||||
| * - otherwise, just copy own coordinates of mesh | * - otherwise, just copy own coordinates of mesh | ||||
| * (no need to transform vertex coordinates into new space). | * (no need to transform vertex coordinates into new space). | ||||
| */ | */ | ||||
| if (key) { | if (key) { | ||||
| /* if this mesh has any shapekeys, check first, otherwise just copy coordinates */ | /* if this mesh has any shapekeys, check first, otherwise just copy coordinates */ | ||||
| for (KeyBlock *kb = key->block.first; kb; kb = kb->next) { | LISTBASE_FOREACH (KeyBlock *, kb, &key->block) { | ||||
| /* get pointer to where to write data for this mesh in shapekey's data array */ | /* get pointer to where to write data for this mesh in shapekey's data array */ | ||||
| float(*cos)[3] = ((float(*)[3])kb->data) + *vertofs; | float(*cos)[3] = ((float(*)[3])kb->data) + *vertofs; | ||||
| /* check if this mesh has such a shapekey */ | /* check if this mesh has such a shapekey */ | ||||
| KeyBlock *okb = me->key ? BKE_keyblock_find_name(me->key, kb->name) : NULL; | KeyBlock *okb = me->key ? BKE_keyblock_find_name(me->key, kb->name) : NULL; | ||||
| if (okb) { | if (okb) { | ||||
| /* copy this mesh's shapekey to the destination shapekey | /* copy this mesh's shapekey to the destination shapekey | ||||
| * (need to transform first) */ | * (need to transform first) */ | ||||
| Show All 13 Lines | if (ob_src != ob_dst) { | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* for each shapekey in destination mesh: | /* for each shapekey in destination mesh: | ||||
| * - if it was an 'original', copy the appropriate data from nkey | * - if it was an 'original', copy the appropriate data from nkey | ||||
| * - otherwise, copy across plain coordinates (no need to transform coordinates) | * - otherwise, copy across plain coordinates (no need to transform coordinates) | ||||
| */ | */ | ||||
| if (key) { | if (key) { | ||||
| for (KeyBlock *kb = key->block.first; kb; kb = kb->next) { | LISTBASE_FOREACH (KeyBlock *, kb, &key->block) { | ||||
| /* get pointer to where to write data for this mesh in shapekey's data array */ | /* get pointer to where to write data for this mesh in shapekey's data array */ | ||||
| float(*cos)[3] = ((float(*)[3])kb->data) + *vertofs; | float(*cos)[3] = ((float(*)[3])kb->data) + *vertofs; | ||||
| /* check if this was one of the original shapekeys */ | /* check if this was one of the original shapekeys */ | ||||
| KeyBlock *okb = nkey ? BKE_keyblock_find_name(nkey, kb->name) : NULL; | KeyBlock *okb = nkey ? BKE_keyblock_find_name(nkey, kb->name) : NULL; | ||||
| if (okb) { | if (okb) { | ||||
| /* copy this mesh's shapekey to the destination shapekey */ | /* copy this mesh's shapekey to the destination shapekey */ | ||||
| float(*ocos)[3] = okb->data; | float(*ocos)[3] = okb->data; | ||||
| ▲ Show 20 Lines • Show All 232 Lines • ▼ Show 20 Lines | if ((ob != ob_iter) && (ob_iter->type == OB_MESH)) { | ||||
| BLI_addtail(&ob->defbase, odg); | BLI_addtail(&ob->defbase, odg); | ||||
| } | } | ||||
| } | } | ||||
| if (ob->defbase.first && ob->actdef == 0) { | if (ob->defbase.first && ob->actdef == 0) { | ||||
| ob->actdef = 1; | ob->actdef = 1; | ||||
| } | } | ||||
| /* Join this object's face maps to the base one's. */ | /* Join this object's face maps to the base one's. */ | ||||
| for (bFaceMap *fmap = ob_iter->fmaps.first; fmap; fmap = fmap->next) { | LISTBASE_FOREACH (bFaceMap *, fmap, &ob_iter->fmaps) { | ||||
| /* See if this group exists in the object (if it doesn't, add it to the end) */ | /* See if this group exists in the object (if it doesn't, add it to the end) */ | ||||
| if (BKE_object_facemap_find_name(ob, fmap->name) == NULL) { | if (BKE_object_facemap_find_name(ob, fmap->name) == NULL) { | ||||
| bFaceMap *fmap_new = MEM_mallocN(sizeof(bFaceMap), "join faceMap"); | bFaceMap *fmap_new = MEM_mallocN(sizeof(bFaceMap), "join faceMap"); | ||||
| memcpy(fmap_new, fmap, sizeof(bFaceMap)); | memcpy(fmap_new, fmap, sizeof(bFaceMap)); | ||||
| BLI_addtail(&ob->fmaps, fmap_new); | BLI_addtail(&ob->fmaps, fmap_new); | ||||
| } | } | ||||
| } | } | ||||
| if (ob->fmaps.first && ob->actfmap == 0) { | if (ob->fmaps.first && ob->actfmap == 0) { | ||||
| ▲ Show 20 Lines • Show All 1,067 Lines • Show Last 20 Lines | |||||