Revision: 27529
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27529
Author:   broken
Date:     2010-03-16 08:44:57 +0100 (Tue, 16 Mar 2010)

Log Message:
-----------
Fix [#21165] Moved textures don't move the animation curves

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_animsys.h
    trunk/blender/source/blender/blenkernel/intern/anim_sys.c
    trunk/blender/source/blender/editors/armature/editarmature.c
    trunk/blender/source/blender/editors/render/render_shading.c

Modified: trunk/blender/source/blender/blenkernel/BKE_animsys.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_animsys.h       2010-03-16 
06:18:49 UTC (rev 27528)
+++ trunk/blender/source/blender/blenkernel/BKE_animsys.h       2010-03-16 
07:44:57 UTC (rev 27529)
@@ -92,7 +92,7 @@
 /* Path Fixing API */
 
 /* Fix all the paths for the given ID+AnimData */
-void BKE_animdata_fix_paths_rename(struct ID *owner_id, struct AnimData *adt, 
char *prefix, char *oldName, char *newName);
+void BKE_animdata_fix_paths_rename(struct ID *owner_id, struct AnimData *adt, 
char *prefix, char *oldName, char *newName, int oldSubscript, int newSubscript, 
int verify_paths);
 
 /* Fix all the paths for the entire database... */
 void BKE_all_animdata_fix_paths_rename(char *prefix, char *oldName, char 
*newName);

Modified: trunk/blender/source/blender/blenkernel/intern/anim_sys.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/anim_sys.c   2010-03-16 
06:18:49 UTC (rev 27528)
+++ trunk/blender/source/blender/blenkernel/intern/anim_sys.c   2010-03-16 
07:44:57 UTC (rev 27529)
@@ -274,7 +274,7 @@
 /* Check if some given RNA Path needs fixing - free the given path and set a 
new one as appropriate 
  * NOTE: we assume that oldName and newName have [" "] padding around them
  */
-static char *rna_path_rename_fix (ID *owner_id, char *prefix, char *oldName, 
char *newName, char *oldpath)
+static char *rna_path_rename_fix (ID *owner_id, char *prefix, char *oldName, 
char *newName, char *oldpath, int verify_paths)
 {
        char *prefixPtr= strstr(oldpath, prefix);
        char *oldNamePtr= strstr(oldpath, oldName);
@@ -286,7 +286,7 @@
         */
        if ( (prefixPtr && oldNamePtr) && (prefixPtr+prefixLen == oldNamePtr) ) 
{
                /* if we haven't aren't able to resolve the path now, try again 
after fixing it */
-               if (check_rna_path_is_valid(owner_id, oldpath) == 0) {          
+               if (!verify_paths || check_rna_path_is_valid(owner_id, oldpath) 
== 0) {         
                        DynStr *ds= BLI_dynstr_new();
                        char *postfixPtr= oldNamePtr+oldNameLen;
                        char *newPath = NULL;
@@ -315,7 +315,7 @@
                        
                        /* check if the new path will solve our problems */
                        // TODO: will need to check whether this step really 
helps in practice
-                       if (check_rna_path_is_valid(owner_id, newPath)) {
+                       if (!verify_paths || check_rna_path_is_valid(owner_id, 
newPath)) {
                                /* free the old path, and return the new one, 
since we've solved the issues */
                                MEM_freeN(oldpath);
                                return newPath;
@@ -332,7 +332,7 @@
 }
 
 /* Check RNA-Paths for a list of F-Curves */
-static void fcurves_path_rename_fix (ID *owner_id, char *prefix, char 
*oldName, char *newName, ListBase *curves)
+static void fcurves_path_rename_fix (ID *owner_id, char *prefix, char 
*oldName, char *newName, ListBase *curves, int verify_paths)
 {
        FCurve *fcu;
        
@@ -340,7 +340,7 @@
        for (fcu= curves->first; fcu; fcu= fcu->next) {
                /* firstly, handle the F-Curve's own path */
                if (fcu->rna_path)
-                       fcu->rna_path= rna_path_rename_fix(owner_id, prefix, 
oldName, newName, fcu->rna_path);
+                       fcu->rna_path= rna_path_rename_fix(owner_id, prefix, 
oldName, newName, fcu->rna_path, verify_paths);
                
                /* driver? */
                if (fcu->driver) {
@@ -354,7 +354,7 @@
                                {
                                        /* rename RNA path */
                                        if (dtar->rna_path)
-                                               dtar->rna_path= 
rna_path_rename_fix(dtar->id, prefix, oldName, newName, dtar->rna_path);
+                                               dtar->rna_path= 
rna_path_rename_fix(dtar->id, prefix, oldName, newName, dtar->rna_path, 
verify_paths);
                                        
                                        /* also fix the bone-name (if 
applicable) */
                                        // XXX this has been disabled because 
the old/new names have padding which means this check will fail
@@ -371,7 +371,7 @@
 }
 
 /* Fix all RNA-Paths for Actions linked to NLA Strips */
-static void nlastrips_path_rename_fix (ID *owner_id, char *prefix, char 
*oldName, char *newName, ListBase *strips)
+static void nlastrips_path_rename_fix (ID *owner_id, char *prefix, char 
*oldName, char *newName, ListBase *strips, int verify_paths)
 {
        NlaStrip *strip;
        
@@ -379,11 +379,11 @@
        for (strip= strips->first; strip; strip= strip->next) {
                /* fix strip's action */
                if (strip->act)
-                       fcurves_path_rename_fix(owner_id, prefix, oldName, 
newName, &strip->act->curves);
+                       fcurves_path_rename_fix(owner_id, prefix, oldName, 
newName, &strip->act->curves, verify_paths);
                /* ignore own F-Curves, since those are local...  */
                
                /* check sub-strips (if metas) */
-               nlastrips_path_rename_fix(owner_id, prefix, oldName, newName, 
&strip->strips);
+               nlastrips_path_rename_fix(owner_id, prefix, oldName, newName, 
&strip->strips, verify_paths);
        }
 }
 
@@ -391,31 +391,36 @@
  * NOTE: it is assumed that the structure we're replacing is 
<prefix><["><name><"]>
  *             i.e. pose.bones["Bone"]
  */
-void BKE_animdata_fix_paths_rename (ID *owner_id, AnimData *adt, char *prefix, 
char *oldName, char *newName)
+void BKE_animdata_fix_paths_rename (ID *owner_id, AnimData *adt, char *prefix, 
char *oldName, char *newName, int oldSubscript, int newSubscript, int 
verify_paths)
 {
        NlaTrack *nlt;
        char *oldN, *newN;
        
        /* if no AnimData, no need to proceed */
-       if (ELEM4(NULL, owner_id, adt, oldName, newName))
+       if (ELEM(NULL, owner_id, adt))
                return;
        
-       /* pad the names with [" "] so that only exact matches are made */
-       oldN= BLI_sprintfN("[\"%s\"]", oldName);
-       newN= BLI_sprintfN("[\"%s\"]", newName);
+       if (oldName != NULL && newName != NULL) {
+               /* pad the names with [" "] so that only exact matches are made 
*/
+               oldN= BLI_sprintfN("[\"%s\"]", oldName);
+               newN= BLI_sprintfN("[\"%s\"]", newName);
+       } else {
+               oldN= BLI_sprintfN("[%d]", oldSubscript);
+               newN= BLI_sprintfN("[%d]", newSubscript);
+       }
        
        /* Active action and temp action */
        if (adt->action)
-               fcurves_path_rename_fix(owner_id, prefix, oldN, newN, 
&adt->action->curves);
+               fcurves_path_rename_fix(owner_id, prefix, oldN, newN, 
&adt->action->curves, verify_paths);
        if (adt->tmpact)
-               fcurves_path_rename_fix(owner_id, prefix, oldN, newN, 
&adt->tmpact->curves);
+               fcurves_path_rename_fix(owner_id, prefix, oldN, newN, 
&adt->tmpact->curves, verify_paths);
                
        /* Drivers - Drivers are really F-Curves */
-       fcurves_path_rename_fix(owner_id, prefix, oldN, newN, &adt->drivers);
+       fcurves_path_rename_fix(owner_id, prefix, oldN, newN, &adt->drivers, 
verify_paths);
        
        /* NLA Data - Animation Data for Strips */
        for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next)
-               nlastrips_path_rename_fix(owner_id, prefix, oldN, newN, 
&nlt->strips);
+               nlastrips_path_rename_fix(owner_id, prefix, oldN, newN, 
&nlt->strips, verify_paths);
                
        /* free the temp names */
        MEM_freeN(oldN);
@@ -482,7 +487,7 @@
 #define RENAMEFIX_ANIM_IDS(first) \
        for (id= first; id; id= id->next) { \
                AnimData *adt= BKE_animdata_from_id(id); \
-               BKE_animdata_fix_paths_rename(id, adt, prefix, oldName, 
newName);\
+               BKE_animdata_fix_paths_rename(id, adt, prefix, oldName, 
newName, 0, 0, 1);\
        }
        
        /* nodes */
@@ -532,11 +537,11 @@
                /* do compositing nodes first (since these aren't included in 
main tree) */
                if (scene->nodetree) {
                        AnimData *adt2= BKE_animdata_from_id((ID 
*)scene->nodetree);
-                       BKE_animdata_fix_paths_rename((ID *)scene->nodetree, 
adt2, prefix, oldName, newName);
+                       BKE_animdata_fix_paths_rename((ID *)scene->nodetree, 
adt2, prefix, oldName, newName, 0, 0, 1);
                }
                
                /* now fix scene animation data as per normal */
-               BKE_animdata_fix_paths_rename((ID *)id, adt, prefix, oldName, 
newName);
+               BKE_animdata_fix_paths_rename((ID *)id, adt, prefix, oldName, 
newName, 0, 0, 1);
        }
 }
 

Modified: trunk/blender/source/blender/editors/armature/editarmature.c
===================================================================
--- trunk/blender/source/blender/editors/armature/editarmature.c        
2010-03-16 06:18:49 UTC (rev 27528)
+++ trunk/blender/source/blender/editors/armature/editarmature.c        
2010-03-16 07:44:57 UTC (rev 27529)
@@ -5540,7 +5540,7 @@
                        // TODO: should we be using the database wide version 
instead (since drivers may break)
                        if (ob->adt) {
                                /* posechannels only... */
-                               BKE_animdata_fix_paths_rename(&ob->id, ob->adt, 
"pose.bones", oldname, newname);
+                               BKE_animdata_fix_paths_rename(&ob->id, ob->adt, 
"pose.bones", oldname, newname, 0, 0, 1);
                        }
                }
        }

Modified: trunk/blender/source/blender/editors/render/render_shading.c
===================================================================
--- trunk/blender/source/blender/editors/render/render_shading.c        
2010-03-16 06:18:49 UTC (rev 27528)
+++ trunk/blender/source/blender/editors/render/render_shading.c        
2010-03-16 07:44:57 UTC (rev 27529)
@@ -697,6 +697,7 @@
 static int texture_slot_move(bContext *C, wmOperator *op)
 {
        ID *id= CTX_data_pointer_get_type(C, "texture_slot", 
&RNA_TextureSlot).id.data;
+       Material *ma = (Material *)id;
 
        if(id) {
                MTex **mtex_ar, *mtexswap;
@@ -710,6 +711,10 @@
                                mtexswap = mtex_ar[act];
                                mtex_ar[act] = mtex_ar[act-1];
                                mtex_ar[act-1] = mtexswap;
+                               
+                               BKE_animdata_fix_paths_rename(id, ma->adt, 
"texture_slots", NULL, NULL, act-1, -1, 0);
+                               BKE_animdata_fix_paths_rename(id, ma->adt, 
"texture_slots", NULL, NULL, act, act-1, 0);
+                               BKE_animdata_fix_paths_rename(id, ma->adt, 
"texture_slots", NULL, NULL, -1, act, 0);
 
                                if(GS(id->name)==ID_MA) {
                                        Material *ma= (Material *)id;
@@ -719,7 +724,7 @@
                                        ma->septex &= ~(1<<(act-1));
                                        ma->septex |= mtexuse >> 1;
                                }
-
+                               
                                set_active_mtex(id, act-1);
                        }
                }
@@ -728,6 +733,10 @@
                                mtexswap = mtex_ar[act];
                                mtex_ar[act] = mtex_ar[act+1];
                                mtex_ar[act+1] = mtexswap;
+                               
+                               BKE_animdata_fix_paths_rename(id, ma->adt, 
"texture_slots", NULL, NULL, act+1, -1, 0);
+                               BKE_animdata_fix_paths_rename(id, ma->adt, 
"texture_slots", NULL, NULL, act, act+1, 0);
+                               BKE_animdata_fix_paths_rename(id, ma->adt, 
"texture_slots", NULL, NULL, -1, act, 0);
 
                                if(GS(id->name)==ID_MA) {
                                        Material *ma= (Material *)id;
@@ -737,7 +746,7 @@
                                        ma->septex &= ~(1<<(act+1));
                                        ma->septex |= mtexuse << 1;
                                }
-
+                               
                                set_active_mtex(id, act+1);
                        }
                }


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to