Patch #34204: [Render Animation] Fails with "Error: Specified sample_fmt is not suppo...
[blender.git] / source / blender / blenkernel / intern / ipo.c
index bbc1874..c536474 100644 (file)
@@ -32,7 +32,7 @@
 
 /* NOTE:
  *
- * This file is no longer used to provide tools for the depreceated IPO system. Instead, it
+ * This file is no longer used to provide tools for the deprecated IPO system. Instead, it
  * is only used to house the conversion code to the new system.
  *
  * -- Joshua Leung, Jan 2009
@@ -46,6 +46,7 @@
 /* since we have versioning code here */
 #define DNA_DEPRECATED_ALLOW
 
+#include "DNA_actuator_types.h"
 #include "DNA_anim_types.h"
 #include "DNA_constraint_types.h"
 #include "DNA_camera_types.h"
@@ -568,7 +569,7 @@ static const char *material_adrcodes_to_paths(int adrcode, int *array_index)
                        return mtex_adrcodes_to_paths(adrcode, array_index);
        }
        
-       return NULL;    
+       return NULL;
 }
 
 /* Camera Types */
@@ -726,7 +727,7 @@ static const char *world_adrcodes_to_paths(int adrcode, int *array_index)
                        return mtex_adrcodes_to_paths(adrcode, array_index);
        }
                
-       return NULL;    
+       return NULL;
 }
 
 /* Particle Types */
@@ -872,7 +873,7 @@ static char *get_rna_access(int blocktype, int adrcode, char actname[], char con
                        propname = "eval_time";
                        break;
                
-               /* XXX problematic blocktypes */                
+               /* XXX problematic blocktypes */
                case ID_SEQ: /* sequencer strip */
                        //SEQ_FAC1:
                        switch (adrcode) {
@@ -894,7 +895,7 @@ static char *get_rna_access(int blocktype, int adrcode, char actname[], char con
                        /* special case for rotdiff drivers... we don't need a property for this... */
                        break;
                        
-               // TODO... add other blocktypes...
+               /* TODO... add other blocktypes... */
                default:
                        printf("IPO2ANIMATO WARNING: No path for blocktype %d, adrcode %d yet\n", blocktype, adrcode);
                        break;
@@ -980,21 +981,21 @@ static char *get_rna_access(int blocktype, int adrcode, char actname[], char con
 static short adrcode_to_dtar_transchan(short adrcode)
 {
        switch (adrcode) {
-               case OB_LOC_X:  
+               case OB_LOC_X:
                        return DTAR_TRANSCHAN_LOCX;
                case OB_LOC_Y:
                        return DTAR_TRANSCHAN_LOCY;
                case OB_LOC_Z:
                        return DTAR_TRANSCHAN_LOCZ;
                
-               case OB_ROT_X:  
+               case OB_ROT_X:
                        return DTAR_TRANSCHAN_ROTX;
                case OB_ROT_Y:
                        return DTAR_TRANSCHAN_ROTY;
                case OB_ROT_Z:
                        return DTAR_TRANSCHAN_ROTZ;
                
-               case OB_SIZE_X: 
+               case OB_SIZE_X:
                        return DTAR_TRANSCHAN_SCALEX;
                case OB_SIZE_Y:
                        return DTAR_TRANSCHAN_SCALEX;
@@ -1358,8 +1359,8 @@ static void icu_to_fcurves(ID *id, ListBase *groups, ListBase *list, IpoCurve *i
                                
                                /* correct values for sequencer curves, that were not locked to frame */
                                if (seq && (seq->flag & SEQ_IPO_FRAME_LOCKED) == 0) {
-                                       double mul = (seq->enddisp - seq->startdisp) / 100.0f;
-                                       double offset = seq->startdisp;
+                                       const float mul = (seq->enddisp - seq->startdisp) / 100.0f;
+                                       const float offset = seq->startdisp;
                                        
                                        dst->vec[0][0] *= mul;
                                        dst->vec[0][0] += offset;
@@ -1547,7 +1548,7 @@ static void ipo_to_animdata(ID *id, Ipo *ipo, char actname[], char constname[],
                        
                        BLI_snprintf(nameBuf, sizeof(nameBuf), "CDA:%s", ipo->id.name + 2);
                        
-                       adt->action = add_empty_action(nameBuf);
+                       adt->action = add_empty_action(G.main, nameBuf);
                        if (G.debug & G_DEBUG) printf("\t\tadded new action - '%s'\n", nameBuf);
                }
                
@@ -1587,9 +1588,9 @@ static void action_to_animdata(ID *id, bAction *act)
 
 /* ------------------------- */
 
-// TODO:
-//     - NLA group duplicators info
-//     - NLA curve/stride modifiers...
+/* TODO:
+ * - NLA group duplicators info
+ * - NLA curve/stride modifiers... */
 
 /* Convert NLA-Strip to new system */
 static void nlastrips_to_animdata(ID *id, ListBase *strips)
@@ -1644,7 +1645,7 @@ static void nlastrips_to_animdata(ID *id, ListBase *strips)
                                /* by default, we now always extrapolate, while in the past this was optional */
                                if ((as->flag & ACTSTRIP_HOLDLASTFRAME) == 0)
                                        strip->extendmode = NLASTRIP_EXTEND_NOTHING;
-                       }       
+                       }
                        
                        /* try to add this strip to the current NLA-Track (i.e. the 'last' one on the stack atm) */
                        if (BKE_nlatrack_add_strip(nlt, strip) == 0) {
@@ -1753,6 +1754,23 @@ void do_versions_ipos_to_animato(Main *main)
                                ipo_to_animdata(id, ob->ipo, NULL, NULL, NULL);
                                ob->ipo->id.us--;
                                ob->ipo = NULL;
+
+                               {
+                                       /* If we have any empty action actuators, assume they were
+                                        * converted IPO Actuators using the object IPO */
+                                       bActuator *act;
+                                       bActionActuator *aa;
+
+                                       for (act = ob->actuators.first; act; act = act->next) {
+                                               /* Any actuators set to ACT_IPO at this point are actually Action Actuators that
+                                                * need this converted IPO to finish converting the actuator. */
+                                               if (act->type == ACT_IPO) {
+                                                       aa = (bActionActuator *)act->data;
+                                                       aa->act = ob->adt->action;
+                                                       act->type = ACT_ACTION;
+                                               }
+                                       }
+                               }
                        }
                }
                
@@ -2075,7 +2093,7 @@ void do_versions_ipos_to_animato(Main *main)
                        bAction *new_act;
                        
                        /* add a new action for this, and convert all data into that action */
-                       new_act = add_empty_action("ConvIPO_Action"); // XXX need a better name...
+                       new_act = add_empty_action(main, id->name + 2);
                        ipo_to_animato(NULL, ipo, NULL, NULL, NULL, NULL, &new_act->curves, &drivers);
                        new_act->idroot = ipo->blocktype;
                }