Blender  V2.59
rna_fcurve.c
Go to the documentation of this file.
00001 /*
00002  * $Id: rna_fcurve.c 37031 2011-05-31 02:14:25Z campbellbarton $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * Contributor(s): Blender Foundation (2009), Joshua Leung
00021  *
00022  * ***** END GPL LICENSE BLOCK *****
00023  */
00024 
00030 #include <stdlib.h>
00031 
00032 #include "RNA_access.h"
00033 #include "RNA_define.h"
00034 #include "RNA_enum_types.h"
00035 
00036 #include "rna_internal.h"
00037 
00038 #include "DNA_anim_types.h"
00039 #include "DNA_object_types.h"
00040 #include "DNA_scene_types.h"
00041 
00042 #include "MEM_guardedalloc.h"
00043 
00044 #include "BLI_math.h"
00045 
00046 #include "BKE_action.h"
00047 
00048 #include "WM_types.h"
00049 
00050 #include "ED_keyframing.h"
00051 #include "ED_keyframes_edit.h"
00052 
00053 EnumPropertyItem fmodifier_type_items[] = {
00054         {FMODIFIER_TYPE_NULL, "NULL", 0, "Invalid", ""},
00055         {FMODIFIER_TYPE_GENERATOR, "GENERATOR", 0, "Generator", ""},
00056         {FMODIFIER_TYPE_FN_GENERATOR, "FNGENERATOR", 0, "Built-In Function", ""},
00057         {FMODIFIER_TYPE_ENVELOPE, "ENVELOPE", 0, "Envelope", ""},
00058         {FMODIFIER_TYPE_CYCLES, "CYCLES", 0, "Cycles", ""},
00059         {FMODIFIER_TYPE_NOISE, "NOISE", 0, "Noise", ""},
00060         {FMODIFIER_TYPE_FILTER, "FILTER", 0, "Filter", ""},
00061         //{FMODIFIER_TYPE_PYTHON, "PYTHON", 0, "Python", ""},   // FIXME: not implemented yet!
00062         {FMODIFIER_TYPE_LIMITS, "LIMITS", 0, "Limits", ""},
00063         {FMODIFIER_TYPE_STEPPED, "STEPPED", 0, "Stepped Interpolation", ""},
00064         {0, NULL, 0, NULL, NULL}};
00065 
00066 EnumPropertyItem beztriple_keyframe_type_items[] = {
00067         {BEZT_KEYTYPE_KEYFRAME, "KEYFRAME", 0, "Keyframe", ""},
00068         {BEZT_KEYTYPE_BREAKDOWN, "BREAKDOWN", 0, "Breakdown", ""},
00069         {BEZT_KEYTYPE_EXTREME, "EXTREME", 0, "Extreme", ""},
00070         {BEZT_KEYTYPE_JITTER, "JITTER", 0, "Jitter", ""},
00071         {0, NULL, 0, NULL, NULL}};
00072 
00073 #ifdef RNA_RUNTIME
00074 
00075 #include "WM_api.h"
00076 
00077 static StructRNA *rna_FModifierType_refine(struct PointerRNA *ptr)
00078 {
00079         FModifier *fcm= (FModifier *)ptr->data;
00080 
00081         switch (fcm->type) {
00082                 case FMODIFIER_TYPE_GENERATOR:
00083                         return &RNA_FModifierGenerator;
00084                 case FMODIFIER_TYPE_FN_GENERATOR:
00085                         return &RNA_FModifierFunctionGenerator;
00086                 case FMODIFIER_TYPE_ENVELOPE:
00087                         return &RNA_FModifierEnvelope;
00088                 case FMODIFIER_TYPE_CYCLES:
00089                         return &RNA_FModifierCycles;
00090                 case FMODIFIER_TYPE_NOISE:
00091                         return &RNA_FModifierNoise;
00092                 //case FMODIFIER_TYPE_FILTER:
00093                 //      return &RNA_FModifierFilter;
00094                 case FMODIFIER_TYPE_PYTHON:
00095                         return &RNA_FModifierPython;
00096                 case FMODIFIER_TYPE_LIMITS:
00097                         return &RNA_FModifierLimits;
00098                 case FMODIFIER_TYPE_STEPPED:
00099                         return &RNA_FModifierStepped;
00100                 default:
00101                         return &RNA_UnknownType;
00102         }
00103 }
00104 
00105 /* ****************************** */
00106 
00107 #include "BKE_fcurve.h"
00108 #include "BKE_depsgraph.h"
00109 #include "BKE_animsys.h"
00110 
00111 static void rna_ChannelDriver_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
00112 {
00113         ID *id= ptr->id.data;
00114         ChannelDriver *driver= ptr->data;
00115 
00116         driver->flag &= ~DRIVER_FLAG_INVALID;
00117         
00118         // TODO: this really needs an update guard...
00119         DAG_scene_sort(bmain, scene);
00120         DAG_id_tag_update(id, OB_RECALC_OB|OB_RECALC_DATA);
00121         
00122         WM_main_add_notifier(NC_SCENE|ND_FRAME, scene);
00123 }
00124 
00125 static void rna_ChannelDriver_update_expr(Main *bmain, Scene *scene, PointerRNA *ptr)
00126 {
00127         ChannelDriver *driver= ptr->data;
00128         driver->flag |= DRIVER_FLAG_RECOMPILE;
00129         rna_ChannelDriver_update_data(bmain, scene, ptr);
00130 }
00131 
00132 static void rna_DriverTarget_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
00133 {
00134         PointerRNA driverptr;
00135         ChannelDriver *driver;
00136         FCurve *fcu;
00137         AnimData *adt= BKE_animdata_from_id(ptr->id.data);
00138 
00139         /* find the driver this belongs to and update it */
00140         for (fcu=adt->drivers.first; fcu; fcu=fcu->next) {
00141                 driver= fcu->driver;
00142                 
00143                 if (driver) {
00144                         // FIXME: need to be able to search targets for required one...
00145                         //BLI_findindex(&driver->targets, ptr->data) != -1) 
00146                         RNA_pointer_create(ptr->id.data, &RNA_Driver, driver, &driverptr);
00147                         rna_ChannelDriver_update_data(bmain, scene, &driverptr);
00148                         return;
00149                 }
00150         }
00151 }
00152 
00153 static void rna_DriverTarget_update_name(Main *bmain, Scene *scene, PointerRNA *ptr)
00154 {
00155         ChannelDriver *driver= ptr->data;
00156         rna_DriverTarget_update_data(bmain, scene, ptr);
00157 
00158         driver->flag |= DRIVER_FLAG_RENAMEVAR;
00159 
00160 }
00161 
00162 /* ----------- */
00163 
00164 /* note: this function exists only to avoid id refcounting */
00165 static void rna_DriverTarget_id_set(PointerRNA *ptr, PointerRNA value)
00166 {
00167         DriverTarget *dtar= (DriverTarget*)ptr->data;
00168         dtar->id= value.data;
00169 }
00170 
00171 static StructRNA *rna_DriverTarget_id_typef(PointerRNA *ptr)
00172 {
00173         DriverTarget *dtar= (DriverTarget*)ptr->data;
00174         return ID_code_to_RNA_type(dtar->idtype);
00175 }
00176 
00177 static int rna_DriverTarget_id_editable(PointerRNA *ptr)
00178 {
00179         DriverTarget *dtar= (DriverTarget*)ptr->data;
00180         return (dtar->idtype)? PROP_EDITABLE : 0;
00181 }
00182 
00183 static int rna_DriverTarget_id_type_editable(PointerRNA *ptr)
00184 {
00185         DriverTarget *dtar= (DriverTarget*)ptr->data;
00186         
00187         /* when the id-type can only be object, don't allow editing
00188          * otherwise, there may be strange crashes
00189          */
00190         return ((dtar->flag & DTAR_FLAG_ID_OB_ONLY) == 0);
00191 }
00192 
00193 static void rna_DriverTarget_id_type_set(PointerRNA *ptr, int value)
00194 {
00195         DriverTarget *data= (DriverTarget*)(ptr->data);
00196         
00197         /* check if ID-type is settable */
00198         if ((data->flag & DTAR_FLAG_ID_OB_ONLY) == 0) {
00199                 /* change ID-type to the new type */
00200                 data->idtype= value;
00201         }
00202         else {
00203                 /* make sure ID-type is Object */
00204                 data->idtype= ID_OB;
00205         }
00206         
00207         /* clear the id-block if the type is invalid */
00208         if ((data->id) && (GS(data->id->name) != data->idtype))
00209                 data->id= NULL;
00210 }
00211 
00212 static void rna_DriverTarget_RnaPath_get(PointerRNA *ptr, char *value)
00213 {
00214         DriverTarget *dtar= (DriverTarget *)ptr->data;
00215 
00216         if (dtar->rna_path)
00217                 strcpy(value, dtar->rna_path);
00218         else
00219                 strcpy(value, "");
00220 }
00221 
00222 static int rna_DriverTarget_RnaPath_length(PointerRNA *ptr)
00223 {
00224         DriverTarget *dtar= (DriverTarget *)ptr->data;
00225         
00226         if (dtar->rna_path)
00227                 return strlen(dtar->rna_path);
00228         else
00229                 return 0;
00230 }
00231 
00232 static void rna_DriverTarget_RnaPath_set(PointerRNA *ptr, const char *value)
00233 {
00234         DriverTarget *dtar= (DriverTarget *)ptr->data;
00235         
00236         // XXX in this case we need to be very careful, as this will require some new dependencies to be added!
00237         if (dtar->rna_path)
00238                 MEM_freeN(dtar->rna_path);
00239         
00240         if (strlen(value))
00241                 dtar->rna_path= BLI_strdup(value);
00242         else 
00243                 dtar->rna_path= NULL;
00244 }
00245 
00246 static void rna_DriverVariable_type_set(PointerRNA *ptr, int value)
00247 {
00248         DriverVar *dvar= (DriverVar *)ptr->data;
00249         
00250         /* call the API function for this */
00251         driver_change_variable_type(dvar, value);
00252 }
00253 
00254 /* ****************************** */
00255 
00256 static void rna_FKeyframe_handle1_get(PointerRNA *ptr, float *values)
00257 {
00258         BezTriple *bezt= (BezTriple*)ptr->data;
00259         
00260         values[0]= bezt->vec[0][0];
00261         values[1]= bezt->vec[0][1];
00262 }
00263 
00264 static void rna_FKeyframe_handle1_set(PointerRNA *ptr, const float *values)
00265 {
00266         BezTriple *bezt= (BezTriple*)ptr->data;
00267         
00268         bezt->vec[0][0]= values[0];
00269         bezt->vec[0][1]= values[1];
00270 }
00271 
00272 static void rna_FKeyframe_handle2_get(PointerRNA *ptr, float *values)
00273 {
00274         BezTriple *bezt= (BezTriple*)ptr->data;
00275         
00276         values[0]= bezt->vec[2][0];
00277         values[1]= bezt->vec[2][1];
00278 }
00279 
00280 static void rna_FKeyframe_handle2_set(PointerRNA *ptr, const float *values)
00281 {
00282         BezTriple *bezt= (BezTriple*)ptr->data;
00283         
00284         bezt->vec[2][0]= values[0];
00285         bezt->vec[2][1]= values[1];
00286 }
00287 
00288 static void rna_FKeyframe_ctrlpoint_get(PointerRNA *ptr, float *values)
00289 {
00290         BezTriple *bezt= (BezTriple*)ptr->data;
00291         
00292         values[0]= bezt->vec[1][0];
00293         values[1]= bezt->vec[1][1];
00294 }
00295 
00296 static void rna_FKeyframe_ctrlpoint_set(PointerRNA *ptr, const float *values)
00297 {
00298         BezTriple *bezt= (BezTriple*)ptr->data;
00299         
00300         bezt->vec[1][0]= values[0];
00301         bezt->vec[1][1]= values[1];
00302 }
00303 
00304 /* ****************************** */
00305 
00306 static void rna_FCurve_RnaPath_get(PointerRNA *ptr, char *value)
00307 {
00308         FCurve *fcu= (FCurve *)ptr->data;
00309 
00310         if (fcu->rna_path)
00311                 strcpy(value, fcu->rna_path);
00312         else
00313                 strcpy(value, "");
00314 }
00315 
00316 static int rna_FCurve_RnaPath_length(PointerRNA *ptr)
00317 {
00318         FCurve *fcu= (FCurve *)ptr->data;
00319         
00320         if (fcu->rna_path)
00321                 return strlen(fcu->rna_path);
00322         else
00323                 return 0;
00324 }
00325 
00326 static void rna_FCurve_RnaPath_set(PointerRNA *ptr, const char *value)
00327 {
00328         FCurve *fcu= (FCurve *)ptr->data;
00329 
00330         if (fcu->rna_path)
00331                 MEM_freeN(fcu->rna_path);
00332         
00333         if (strlen(value)) {
00334                 fcu->rna_path= BLI_strdup(value);
00335                 fcu->flag &= ~FCURVE_DISABLED;
00336         }
00337         else 
00338                 fcu->rna_path= NULL;
00339 }
00340 
00341 static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value)
00342 {
00343         ID *pid = (ID *)ptr->id.data;
00344         ID *vid = (ID *)value.id.data;
00345         FCurve *fcu= ptr->data;
00346         bAction *act = NULL;
00347         
00348         /* get action */
00349         if (ELEM(NULL, pid, vid)) {
00350                 printf("ERROR: one of the ID's for the groups to assign to is invalid (ptr=%p, val=%p)\n", pid, vid);
00351                 return;
00352         }
00353         else if (value.data && (pid != vid)) {
00354                 /* id's differ, cant do this, should raise an error */
00355                 printf("ERROR: ID's differ - ptr=%p vs value=%p \n", pid, vid);
00356                 return;
00357         }
00358         
00359         if (GS(pid->name)==ID_AC && GS(vid->name)==ID_AC) {
00360                 /* the ID given is the action already - usually when F-Curve is obtained from an action's pointer */
00361                 act = (bAction *)pid;
00362         }
00363         else {
00364                 /* the ID given is the owner of the F-Curve (for drivers) */
00365                 AnimData *adt = BKE_animdata_from_id(ptr->id.data);
00366                 act = (adt)? adt->action : NULL;
00367         }
00368         
00369         /* already belongs to group? */
00370         if (fcu->grp == value.data) {
00371                 /* nothing to do */
00372                 printf("ERROR: F-Curve already belongs to this group\n");
00373                 return; 
00374         }
00375         
00376         /* can only change group if we have info about the action the F-Curve is in 
00377          * (i.e. for drivers or random F-Curves, this cannot be done)
00378          */
00379         if (act == NULL) {
00380                 /* can't change the grouping of F-Curve when it doesn't belong to an action */
00381                 printf("ERROR: cannot assign F-Curve to group, since F-Curve is not attached to any ID\n");
00382                 return;
00383         }
00384         /* make sure F-Curve exists in this action first, otherwise we could still have been tricked */
00385         else if (BLI_findindex(&act->curves, fcu) == -1) {
00386                 printf("ERROR: F-Curve (%p) doesn't exist in action '%s'\n", fcu, act->id.name);
00387                 return;
00388         }
00389         
00390         /* try to remove F-Curve from action (including from any existing groups) */
00391         action_groups_remove_channel(act, fcu);
00392         
00393         /* add the F-Curve back to the action now in the right place */
00394         // TODO: make the api function handle the case where there isn't any group to assign to 
00395         if (value.data) {
00396                 /* add to its group using API function, which makes sure everything goes ok */
00397                 action_groups_add_channel(act, value.data, fcu);
00398         }
00399         else {
00400                 /* need to add this back, but it can only go at the end of the list (or else will corrupt groups) */
00401                 BLI_addtail(&act->curves, fcu);
00402         }
00403 }
00404 
00405 DriverVar *rna_Driver_new_variable(ChannelDriver *driver)
00406 {
00407         /* call the API function for this */
00408         return driver_add_new_variable(driver);
00409 }
00410 
00411 void rna_Driver_remove_variable(ChannelDriver *driver, ReportList *reports, DriverVar *dvar)
00412 {
00413         if(BLI_findindex(&driver->variables, dvar) == -1) {
00414                 BKE_report(reports, RPT_ERROR, "Variable does not exist in this driver.");
00415                 return;
00416         }
00417 
00418         driver_free_variable(driver, dvar);
00419 }
00420 
00421 
00422 static PointerRNA rna_FCurve_active_modifier_get(PointerRNA *ptr)
00423 {
00424         FCurve *fcu= (FCurve*)ptr->data;
00425         FModifier *fcm= find_active_fmodifier(&fcu->modifiers);
00426         return rna_pointer_inherit_refine(ptr, &RNA_FModifier, fcm);
00427 }
00428 
00429 static void rna_FCurve_active_modifier_set(PointerRNA *ptr, PointerRNA value)
00430 {
00431         FCurve *fcu= (FCurve*)ptr->data;
00432         set_active_fmodifier(&fcu->modifiers, (FModifier *)value.data);
00433 }
00434 
00435 static FModifier *rna_FCurve_modifiers_new(FCurve *fcu, int type)
00436 {
00437         return add_fmodifier(&fcu->modifiers, type);
00438 }
00439 
00440 static void rna_FCurve_modifiers_remove(FCurve *fcu, ReportList *reports, FModifier *fcm)
00441 {
00442         if(BLI_findindex(&fcu->modifiers, fcm) == -1) {
00443                 BKE_reportf(reports, RPT_ERROR, "FCurveModifier '%s' not found in fcurve.", fcm->name);
00444                 return;
00445         }
00446         remove_fmodifier(&fcu->modifiers, fcm);
00447 }
00448 
00449 static void rna_FModifier_active_set(PointerRNA *ptr, int UNUSED(value))
00450 {
00451         FModifier *fm= (FModifier*)ptr->data;
00452 
00453         /* don't toggle, always switch on */
00454         fm->flag |= FMODIFIER_FLAG_ACTIVE;
00455 }
00456 
00457 static void rna_FModifier_active_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
00458 {
00459         FModifier *fm, *fmo= (FModifier*)ptr->data;
00460 
00461         /* clear active state of other FModifiers in this list */
00462         for (fm=fmo->prev; fm; fm=fm->prev)
00463         {
00464                 fm->flag &= ~FMODIFIER_FLAG_ACTIVE;
00465         }
00466         for (fm=fmo->next; fm; fm=fm->next)
00467         {
00468                 fm->flag &= ~FMODIFIER_FLAG_ACTIVE;
00469         }
00470         
00471 }
00472 
00473 static int rna_FModifierGenerator_coefficients_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
00474 {
00475         FModifier *fcm= (FModifier*)ptr->data;
00476         FMod_Generator *gen= fcm->data;
00477 
00478         if(gen)
00479                 length[0]= gen->arraysize;
00480         else
00481                 length[0]= 100; /* for raw_access, untested */
00482 
00483         return length[0];
00484 }
00485 
00486 static void rna_FModifierGenerator_coefficients_get(PointerRNA *ptr, float *values)
00487 {
00488         FModifier *fcm= (FModifier*)ptr->data;
00489         FMod_Generator *gen= fcm->data;
00490         memcpy(values, gen->coefficients, gen->arraysize * sizeof(float));
00491 }
00492 
00493 static void rna_FModifierGenerator_coefficients_set(PointerRNA *ptr, const float *values)
00494 {
00495         FModifier *fcm= (FModifier*)ptr->data;
00496         FMod_Generator *gen= fcm->data;
00497         memcpy(gen->coefficients, values, gen->arraysize * sizeof(float));
00498 }
00499 
00500 static void rna_FModifierLimits_minx_range(PointerRNA *ptr, float *min, float *max)
00501 {
00502         FModifier *fcm= (FModifier*)ptr->data;
00503         FMod_Limits *data= fcm->data;
00504 
00505         *min= MINAFRAMEF;
00506         *max= (data->flag & FCM_LIMIT_XMAX)? data->rect.xmax : MAXFRAMEF;
00507 }
00508 
00509 static void rna_FModifierLimits_maxx_range(PointerRNA *ptr, float *min, float *max)
00510 {
00511         FModifier *fcm= (FModifier*)ptr->data;
00512         FMod_Limits *data= fcm->data;
00513 
00514         *min= (data->flag & FCM_LIMIT_XMIN)? data->rect.xmin : MINAFRAMEF;
00515         *max= MAXFRAMEF;
00516 }
00517 
00518 static void rna_FModifierLimits_miny_range(PointerRNA *ptr, float *min, float *max)
00519 {
00520         FModifier *fcm= (FModifier*)ptr->data;
00521         FMod_Limits *data= fcm->data;
00522 
00523         *min= -FLT_MAX;
00524         *max= (data->flag & FCM_LIMIT_YMAX)? data->rect.ymax : FLT_MAX;
00525 }
00526 
00527 static void rna_FModifierLimits_maxy_range(PointerRNA *ptr, float *min, float *max)
00528 {
00529         FModifier *fcm= (FModifier*)ptr->data;
00530         FMod_Limits *data= fcm->data;
00531 
00532         *min= (data->flag & FCM_LIMIT_YMIN)? data->rect.ymin : -FLT_MAX;
00533         *max= FLT_MAX;
00534 }
00535 
00536 
00537 static void rna_FModifierStepped_start_frame_range(PointerRNA *ptr, float *min, float *max)
00538 {
00539         FModifier *fcm= (FModifier*)ptr->data;
00540         FMod_Stepped *data= fcm->data;
00541         
00542         *min= MINAFRAMEF;
00543         *max= (data->flag & FCM_STEPPED_NO_AFTER)? data->end_frame : MAXFRAMEF;
00544 }
00545 
00546 static void rna_FModifierStepped_end_frame_range(PointerRNA *ptr, float *min, float *max)
00547 {
00548         FModifier *fcm= (FModifier*)ptr->data;
00549         FMod_Stepped *data= fcm->data;
00550 
00551         *min= (data->flag & FCM_STEPPED_NO_BEFORE)? data->start_frame : MINAFRAMEF;
00552         *max= MAXFRAMEF;
00553 }
00554 
00555 static BezTriple *rna_FKeyframe_points_insert(FCurve *fcu, float frame, float value, int flag)
00556 {
00557         int index= insert_vert_fcurve(fcu, frame, value, flag);
00558         return ((fcu->bezt) && (index >= 0))? (fcu->bezt + index) : NULL;
00559 }
00560 
00561 static void rna_FKeyframe_points_add(FCurve *fcu, int tot)
00562 {
00563         if(tot > 0) {
00564                 BezTriple *bezt;
00565                 if(fcu->totvert) {
00566                         BezTriple *nbezt= MEM_callocN(sizeof(BezTriple) * (fcu->totvert + tot), "rna_FKeyframe_points_add");
00567                         memcpy(nbezt, fcu->bezt, sizeof(BezTriple) * fcu->totvert);
00568                         MEM_freeN(fcu->bezt);
00569                         fcu->bezt= nbezt;
00570                 }
00571                 else {
00572                         fcu->bezt= MEM_callocN(sizeof(BezTriple) * tot, "rna_FKeyframe_points_add");
00573                 }
00574 
00575                 bezt= fcu->bezt + fcu->totvert;
00576                 fcu->totvert += tot;
00577 
00578                 while(tot--) {
00579                         /* defaults, no userprefs gives pradictable results for API */
00580                         bezt->f1= bezt->f2= bezt->f3= SELECT;
00581                         bezt->ipo= BEZT_IPO_BEZ;
00582                         bezt->h1= bezt->h2= HD_AUTO;
00583                         bezt++;
00584                 }
00585         }
00586 }
00587 
00588 static void rna_FKeyframe_points_remove(FCurve *fcu, ReportList *reports, BezTriple *bezt, int do_fast)
00589 {
00590         int index= (int)(bezt - fcu->bezt);
00591         if (index < 0 || index >= fcu->totvert) {
00592                 BKE_report(reports, RPT_ERROR, "Keyframe not in F-Curve.");
00593                 return;
00594         }
00595 
00596         delete_fcurve_key(fcu, index, !do_fast);
00597 }
00598 
00599 static void rna_fcurve_range(FCurve *fcu, float range[2])
00600 {
00601         calc_fcurve_range(fcu, range, range+1, FALSE);
00602 }
00603 
00604 #else
00605 
00606 static void rna_def_fmodifier_generator(BlenderRNA *brna)
00607 {
00608         StructRNA *srna;
00609         PropertyRNA *prop;
00610         
00611         static EnumPropertyItem generator_mode_items[] = {
00612                 {FCM_GENERATOR_POLYNOMIAL, "POLYNOMIAL", 0, "Expanded Polynomial", ""},
00613                 {FCM_GENERATOR_POLYNOMIAL_FACTORISED, "POLYNOMIAL_FACTORISED", 0, "Factorised Polynomial", ""},
00614                 {0, NULL, 0, NULL, NULL}};
00615         
00616         srna= RNA_def_struct(brna, "FModifierGenerator", "FModifier");
00617         RNA_def_struct_ui_text(srna, "Generator F-Curve Modifier", "Deterministically generates values for the modified F-Curve");
00618         RNA_def_struct_sdna_from(srna, "FMod_Generator", "data");
00619         
00620         /* define common props */
00621         prop= RNA_def_property(srna, "use_additive", PROP_BOOLEAN, PROP_NONE);
00622         RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_GENERATOR_ADDITIVE);
00623         RNA_def_property_ui_text(prop, "Additive", "Values generated by this modifier are applied on top of the existing values instead of overwriting them");
00624         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00625         
00626                 // XXX this has a special validation func
00627         prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
00628         RNA_def_property_enum_items(prop, generator_mode_items);
00629         RNA_def_property_ui_text(prop, "Mode", "Type of generator to use");
00630         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00631         
00632         
00633         /* order of the polynomial */
00634                 // XXX this has a special validation func
00635         prop= RNA_def_property(srna, "poly_order", PROP_INT, PROP_NONE);
00636         RNA_def_property_ui_text(prop, "Polynomial Order", "The highest power of 'x' for this polynomial. (number of coefficients - 1)");
00637         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00638         
00639         /* coefficients array */
00640         prop= RNA_def_property(srna, "coefficients", PROP_FLOAT, PROP_NONE);
00641         RNA_def_property_array(prop, 32);
00642         RNA_def_property_flag(prop, PROP_DYNAMIC);
00643         RNA_def_property_dynamic_array_funcs(prop, "rna_FModifierGenerator_coefficients_get_length");
00644         RNA_def_property_float_funcs(prop, "rna_FModifierGenerator_coefficients_get", "rna_FModifierGenerator_coefficients_set", NULL);
00645         RNA_def_property_ui_text(prop, "Coefficients", "Coefficients for 'x' (starting from lowest power of x^0)");
00646 }
00647 
00648 /* --------- */
00649 
00650 static void rna_def_fmodifier_function_generator(BlenderRNA *brna)
00651 {
00652         StructRNA *srna;
00653         PropertyRNA *prop;
00654         
00655         static EnumPropertyItem prop_type_items[] = {
00656                 {0, "SIN", 0, "Sine", ""},
00657                 {1, "COS", 0, "Cosine", ""},
00658                 {2, "TAN", 0, "Tangent", ""},
00659                 {3, "SQRT", 0, "Square Root", ""},
00660                 {4, "LN", 0, "Natural Logarithm", ""},
00661                 {5, "SINC", 0, "Normalised Sine", "sin(x) / x"},
00662                 {0, NULL, 0, NULL, NULL}};
00663         
00664         srna= RNA_def_struct(brna, "FModifierFunctionGenerator", "FModifier");
00665         RNA_def_struct_ui_text(srna, "Built-In Function F-Modifier", "Generates values using a Built-In Function");
00666         RNA_def_struct_sdna_from(srna, "FMod_FunctionGenerator", "data");
00667         
00668         /* coefficients */
00669         prop= RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
00670         RNA_def_property_ui_text(prop, "Amplitude", "Scale factor determining the maximum/minimum values");
00671         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00672         
00673         prop= RNA_def_property(srna, "phase_multiplier", PROP_FLOAT, PROP_NONE);
00674         RNA_def_property_ui_text(prop, "Phase Multiplier", "Scale factor determining the 'speed' of the function");
00675         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00676         
00677         prop= RNA_def_property(srna, "phase_offset", PROP_FLOAT, PROP_NONE);
00678         RNA_def_property_ui_text(prop, "Phase Offset", "Constant factor to offset time by for function");
00679         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00680         
00681         prop= RNA_def_property(srna, "value_offset", PROP_FLOAT, PROP_NONE);
00682         RNA_def_property_ui_text(prop, "Value Offset", "Constant factor to offset values by");
00683         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00684         
00685         /* flags */
00686         prop= RNA_def_property(srna, "use_additive", PROP_BOOLEAN, PROP_NONE);
00687         RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_GENERATOR_ADDITIVE);
00688         RNA_def_property_ui_text(prop, "Additive", "Values generated by this modifier are applied on top of the existing values instead of overwriting them");
00689         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00690         
00691         prop= RNA_def_property(srna, "function_type", PROP_ENUM, PROP_NONE);
00692         RNA_def_property_enum_sdna(prop, NULL, "type");
00693         RNA_def_property_enum_items(prop, prop_type_items);
00694         RNA_def_property_ui_text(prop, "Type", "Type of built-in function to use");
00695         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00696 }
00697 
00698 /* --------- */
00699 
00700 static void rna_def_fmodifier_envelope_ctrl(BlenderRNA *brna)
00701 {
00702         StructRNA *srna;
00703         PropertyRNA *prop;
00704         
00705         srna= RNA_def_struct(brna, "FModifierEnvelopeControlPoint", NULL);
00706         RNA_def_struct_ui_text(srna, "Envelope Control Point", "Control point for envelope F-Modifier");
00707         RNA_def_struct_sdna(srna, "FCM_EnvelopeData");
00708         
00709         /* min/max extents 
00710          *      - for now, these are allowed to go past each other, so that we can have inverted action
00711          *      - technically, the range is limited by the settings in the envelope-modifier data, not here...
00712          */
00713         prop= RNA_def_property(srna, "min", PROP_FLOAT, PROP_NONE);
00714         RNA_def_property_float_sdna(prop, NULL, "min");
00715         RNA_def_property_ui_text(prop, "Minimum Value", "Lower bound of envelope at this control-point");
00716         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00717         
00718         prop= RNA_def_property(srna, "max", PROP_FLOAT, PROP_NONE);
00719         RNA_def_property_float_sdna(prop, NULL, "max");
00720         RNA_def_property_ui_text(prop, "Maximum Value", "Upper bound of envelope at this control-point");
00721         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00722         
00723         /* Frame */
00724         prop= RNA_def_property(srna, "frame", PROP_FLOAT, PROP_TIME);
00725         RNA_def_property_float_sdna(prop, NULL, "time");
00726         RNA_def_property_ui_text(prop, "Frame", "Frame this control-point occurs on");
00727         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00728         
00729         // TODO:
00730         //      - selection flags (not implemented in UI yet though)
00731 }
00732 
00733 static void rna_def_fmodifier_envelope(BlenderRNA *brna)
00734 {
00735         StructRNA *srna;
00736         PropertyRNA *prop;
00737         
00738         srna= RNA_def_struct(brna, "FModifierEnvelope", "FModifier");
00739         RNA_def_struct_ui_text(srna, "Envelope F-Modifier", "Scales the values of the modified F-Curve");
00740         RNA_def_struct_sdna_from(srna, "FMod_Envelope", "data");
00741         
00742         /* Collections */
00743         prop= RNA_def_property(srna, "control_points", PROP_COLLECTION, PROP_NONE);
00744         RNA_def_property_collection_sdna(prop, NULL, "data", "totvert");
00745         RNA_def_property_struct_type(prop, "FModifierEnvelopeControlPoint");
00746         RNA_def_property_ui_text(prop, "Control Points", "Control points defining the shape of the envelope");
00747         
00748         /* Range Settings */
00749         prop= RNA_def_property(srna, "reference_value", PROP_FLOAT, PROP_NONE);
00750         RNA_def_property_float_sdna(prop, NULL, "midval");
00751         RNA_def_property_ui_text(prop, "Reference Value", "Value that envelope's influence is centered around / based on");
00752         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00753         
00754         prop= RNA_def_property(srna, "default_min", PROP_FLOAT, PROP_NONE);
00755         RNA_def_property_float_sdna(prop, NULL, "min");
00756         RNA_def_property_ui_text(prop, "Default Minimum", "Lower distance from Reference Value for 1:1 default influence");
00757         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00758         
00759         prop= RNA_def_property(srna, "default_max", PROP_FLOAT, PROP_NONE);
00760         RNA_def_property_float_sdna(prop, NULL, "max");
00761         RNA_def_property_ui_text(prop, "Default Maximum", "Upper distance from Reference Value for 1:1 default influence");
00762         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00763 }
00764 
00765 /* --------- */
00766 
00767 static void rna_def_fmodifier_cycles(BlenderRNA *brna)
00768 {
00769         StructRNA *srna;
00770         PropertyRNA *prop;
00771         
00772         static EnumPropertyItem prop_type_items[] = {
00773                 {FCM_EXTRAPOLATE_NONE, "NONE", 0, "No Cycles", "Don't do anything"},
00774                 {FCM_EXTRAPOLATE_CYCLIC, "REPEAT", 0, "Repeat Motion", "Repeat keyframe range as-is"},
00775                 {FCM_EXTRAPOLATE_CYCLIC_OFFSET, "REPEAT_OFFSET", 0, "Repeat with Offset", "Repeat keyframe range, but with offset based on gradient between values"},
00776                 {FCM_EXTRAPOLATE_MIRROR, "MIRROR", 0, "Repeat Mirrored", "Alternate between forward and reverse playback of keyframe range"},
00777                 {0, NULL, 0, NULL, NULL}};
00778         
00779         srna= RNA_def_struct(brna, "FModifierCycles", "FModifier");
00780         RNA_def_struct_ui_text(srna, "Cycles F-Modifier", "Repeats the values of the modified F-Curve");
00781         RNA_def_struct_sdna_from(srna, "FMod_Cycles", "data");
00782         
00783         /* before */
00784         prop= RNA_def_property(srna, "mode_before", PROP_ENUM, PROP_NONE);
00785         RNA_def_property_enum_sdna(prop, NULL, "before_mode");
00786         RNA_def_property_enum_items(prop, prop_type_items);
00787         RNA_def_property_ui_text(prop, "Before Mode", "Cycling mode to use before first keyframe");
00788         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00789         
00790         prop= RNA_def_property(srna, "cycles_before", PROP_INT, PROP_NONE);
00791         RNA_def_property_int_sdna(prop, NULL, "before_cycles");
00792         RNA_def_property_ui_text(prop, "Before Cycles", "Maximum number of cycles to allow before first keyframe. (0 = infinite)");
00793         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00794         
00795         /* after */
00796         prop= RNA_def_property(srna, "mode_after", PROP_ENUM, PROP_NONE);
00797         RNA_def_property_enum_sdna(prop, NULL, "after_mode");
00798         RNA_def_property_enum_items(prop, prop_type_items);
00799         RNA_def_property_ui_text(prop, "After Mode", "Cycling mode to use after last keyframe");
00800         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00801         
00802         prop= RNA_def_property(srna, "cycles_after", PROP_INT, PROP_NONE);
00803         RNA_def_property_int_sdna(prop, NULL, "after_cycles");
00804         RNA_def_property_ui_text(prop, "After Cycles", "Maximum number of cycles to allow after last keyframe. (0 = infinite)");
00805         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00806 }
00807 
00808 /* --------- */
00809 
00810 static void rna_def_fmodifier_python(BlenderRNA *brna)
00811 {
00812         StructRNA *srna;
00813         //PropertyRNA *prop;
00814         
00815         srna= RNA_def_struct(brna, "FModifierPython", "FModifier");
00816         RNA_def_struct_ui_text(srna, "Python F-Modifier", "Performs user-defined operation on the modified F-Curve");
00817         RNA_def_struct_sdna_from(srna, "FMod_Python", "data");
00818 }
00819 
00820 /* --------- */
00821 
00822 static void rna_def_fmodifier_limits(BlenderRNA *brna)
00823 {
00824         StructRNA *srna;
00825         PropertyRNA *prop;
00826         
00827         srna= RNA_def_struct(brna, "FModifierLimits", "FModifier");
00828         RNA_def_struct_ui_text(srna, "Limits F-Modifier", "Limits the time/value ranges of the modified F-Curve");
00829         RNA_def_struct_sdna_from(srna, "FMod_Limits", "data");
00830         
00831         prop= RNA_def_property(srna, "use_min_x", PROP_BOOLEAN, PROP_NONE);
00832         RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_LIMIT_XMIN);
00833         RNA_def_property_ui_text(prop, "Minimum X", "Use the minimum X value");
00834         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00835         
00836         prop= RNA_def_property(srna, "use_min_y", PROP_BOOLEAN, PROP_NONE);
00837         RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_LIMIT_YMIN);
00838         RNA_def_property_ui_text(prop, "Minimum Y", "Use the minimum Y value");
00839         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00840         
00841         prop= RNA_def_property(srna, "use_max_x", PROP_BOOLEAN, PROP_NONE);
00842         RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_LIMIT_XMAX);
00843         RNA_def_property_ui_text(prop, "Maximum X", "Use the maximum X value");
00844         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00845         
00846         prop= RNA_def_property(srna, "use_max_y", PROP_BOOLEAN, PROP_NONE);
00847         RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_LIMIT_YMAX);
00848         RNA_def_property_ui_text(prop, "Maximum Y", "Use the maximum Y value");
00849         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00850         
00851         prop= RNA_def_property(srna, "min_x", PROP_FLOAT, PROP_NONE);
00852         RNA_def_property_float_sdna(prop, NULL, "rect.xmin");
00853         RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_minx_range");
00854         RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow");
00855         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00856         
00857         prop= RNA_def_property(srna, "min_y", PROP_FLOAT, PROP_NONE);
00858         RNA_def_property_float_sdna(prop, NULL, "rect.ymin");
00859         RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_miny_range");
00860         RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow");
00861         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00862         
00863         prop= RNA_def_property(srna, "max_x", PROP_FLOAT, PROP_NONE);
00864         RNA_def_property_float_sdna(prop, NULL, "rect.xmax");
00865         RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_maxx_range");
00866         RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow");
00867         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00868         
00869         prop= RNA_def_property(srna, "max_y", PROP_FLOAT, PROP_NONE);
00870         RNA_def_property_float_sdna(prop, NULL, "rect.ymax");
00871         RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_maxy_range");
00872         RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow");
00873         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00874 }
00875 
00876 /* --------- */
00877 
00878 static void rna_def_fmodifier_noise(BlenderRNA *brna)
00879 {
00880         StructRNA *srna;
00881         PropertyRNA *prop;
00882         
00883         static EnumPropertyItem prop_modification_items[] = {
00884                 {FCM_NOISE_MODIF_REPLACE, "REPLACE", 0, "Replace", ""},
00885                 {FCM_NOISE_MODIF_ADD, "ADD", 0, "Add", ""},
00886                 {FCM_NOISE_MODIF_SUBTRACT, "SUBTRACT", 0, "Subtract", ""},
00887                 {FCM_NOISE_MODIF_MULTIPLY, "MULTIPLY", 0, "Multiply", ""},
00888                 {0, NULL, 0, NULL, NULL}};
00889         
00890         srna= RNA_def_struct(brna, "FModifierNoise", "FModifier");
00891         RNA_def_struct_ui_text(srna, "Noise F-Modifier", "Gives randomness to the modified F-Curve");
00892         RNA_def_struct_sdna_from(srna, "FMod_Noise", "data");
00893         
00894         prop= RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE);
00895         RNA_def_property_enum_sdna(prop, NULL, "modification");
00896         RNA_def_property_enum_items(prop, prop_modification_items);
00897         RNA_def_property_ui_text(prop, "Blend Type", "Method of modifying the existing F-Curve");
00898         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00899         
00900         prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
00901         RNA_def_property_float_sdna(prop, NULL, "size");
00902         RNA_def_property_ui_text(prop, "Scale", "Scaling (in time) of the noise");
00903         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00904         
00905         prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
00906         RNA_def_property_float_sdna(prop, NULL, "strength");
00907         RNA_def_property_ui_text(prop, "Strength", "Amplitude of the noise - the amount that it modifies the underlying curve");
00908         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00909         
00910         prop= RNA_def_property(srna, "phase", PROP_FLOAT, PROP_NONE);
00911         RNA_def_property_float_sdna(prop, NULL, "phase");
00912         RNA_def_property_ui_text(prop, "Phase", "A random seed for the noise effect");
00913         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00914         
00915         prop= RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
00916         RNA_def_property_int_sdna(prop, NULL, "depth");
00917         RNA_def_property_ui_text(prop, "Depth", "Amount of fine level detail present in the noise");
00918         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00919 
00920 }
00921 
00922 /* --------- */
00923 
00924 static void rna_def_fmodifier_stepped(BlenderRNA *brna)
00925 {
00926         StructRNA *srna;
00927         PropertyRNA *prop;
00928         
00929         srna= RNA_def_struct(brna, "FModifierStepped", "FModifier");
00930         RNA_def_struct_ui_text(srna, "Stepped Interpolation F-Modifier", "Holds each interpolated value from the F-Curve for several frames without changing the timing");
00931         RNA_def_struct_sdna_from(srna, "FMod_Stepped", "data");
00932         
00933         /* properties */
00934         prop= RNA_def_property(srna, "frame_step", PROP_FLOAT, PROP_NONE);
00935         RNA_def_property_float_sdna(prop, NULL, "step_size");
00936         RNA_def_property_ui_text(prop, "Step Size", "Number of frames to hold each value");
00937         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00938         
00939         prop= RNA_def_property(srna, "frame_offset", PROP_FLOAT, PROP_NONE);
00940         RNA_def_property_float_sdna(prop, NULL, "offset");
00941         RNA_def_property_ui_text(prop, "Offset", "Reference number of frames before frames get held. Use to get hold for '1-3' vs '5-7' holding patterns");
00942         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00943         
00944         prop= RNA_def_property(srna, "use_frame_start", PROP_BOOLEAN, PROP_NONE);
00945         RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_STEPPED_NO_BEFORE);
00946         RNA_def_property_ui_text(prop, "Use Start Frame", "Restrict modifier to only act after its 'start' frame");
00947         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00948         
00949         prop= RNA_def_property(srna, "use_frame_end", PROP_BOOLEAN, PROP_NONE);
00950         RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_STEPPED_NO_AFTER);
00951         RNA_def_property_ui_text(prop, "Use End Frame", "Restrict modifier to only act before its 'end' frame");
00952         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00953         
00954         prop= RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE);
00955         RNA_def_property_float_sdna(prop, NULL, "start_frame");
00956         RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierStepped_start_frame_range");
00957         RNA_def_property_ui_text(prop, "Start Frame", "Frame that modifier's influence starts (if applicable)");
00958         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00959         
00960         prop= RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE);
00961         RNA_def_property_float_sdna(prop, NULL, "end_frame");
00962         RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierStepped_end_frame_range");
00963         RNA_def_property_ui_text(prop, "End Frame", "Frame that modifier's influence ends (if applicable)");
00964         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
00965 }
00966 
00967 /* --------- */
00968 
00969 
00970 static void rna_def_fmodifier(BlenderRNA *brna)
00971 {
00972         StructRNA *srna;
00973         PropertyRNA *prop;
00974         
00975         /* base struct definition */
00976         srna= RNA_def_struct(brna, "FModifier", NULL);
00977         RNA_def_struct_refine_func(srna, "rna_FModifierType_refine");
00978         RNA_def_struct_ui_text(srna, "F-Modifier", "Modifier for values of F-Curve");
00979         
00980 #if 0 // XXX not used yet
00981         /* name */
00982         prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
00983         RNA_def_struct_name_property(srna, prop);
00984         RNA_def_property_ui_text(prop, "Name", "Short description of F-Curve Modifier");
00985 #endif // XXX not used yet
00986         
00987         /* type */
00988         prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
00989         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
00990         RNA_def_property_enum_items(prop, fmodifier_type_items);
00991         RNA_def_property_ui_text(prop, "Type", "F-Curve Modifier Type");
00992         
00993         /* settings */
00994         prop= RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
00995         RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_EXPANDED);
00996         RNA_def_property_ui_text(prop, "Expanded", "F-Curve Modifier's panel is expanded in UI");
00997         RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
00998         
00999         prop= RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
01000         RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_MUTED);
01001         RNA_def_property_ui_text(prop, "Muted", "F-Curve Modifier will not be evaluated");
01002         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
01003         RNA_def_property_ui_icon(prop, ICON_MUTE_IPO_OFF, 1);
01004         
01005         prop= RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
01006         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
01007         RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", FMODIFIER_FLAG_DISABLED);
01008         RNA_def_property_ui_text(prop, "Disabled", "F-Curve Modifier has invalid settings and will not be evaluated");
01009         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
01010         
01011                 // TODO: setting this to true must ensure that all others in stack are turned off too...
01012         prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
01013         RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_ACTIVE);
01014         RNA_def_property_ui_text(prop, "Active", "F-Curve Modifier is the one being edited ");
01015         RNA_def_property_boolean_funcs(prop, NULL, "rna_FModifier_active_set");
01016         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, "rna_FModifier_active_update");
01017         RNA_def_property_ui_icon(prop, ICON_RADIOBUT_OFF, 1);
01018 }       
01019 
01020 /* *********************** */
01021 
01022 static void rna_def_drivertarget(BlenderRNA *brna)
01023 {
01024         StructRNA *srna;
01025         PropertyRNA *prop;
01026         
01027         static EnumPropertyItem prop_trans_chan_items[] = {
01028                 {DTAR_TRANSCHAN_LOCX, "LOC_X", 0, "X Location", ""},
01029                 {DTAR_TRANSCHAN_LOCY, "LOC_Y", 0, "Y Location", ""},
01030                 {DTAR_TRANSCHAN_LOCZ, "LOC_Z", 0, "Z Location", ""},
01031                 {DTAR_TRANSCHAN_ROTX, "ROT_X", 0, "X Rotation", ""},
01032                 {DTAR_TRANSCHAN_ROTY, "ROT_Y", 0, "Y Rotation", ""},
01033                 {DTAR_TRANSCHAN_ROTZ, "ROT_Z", 0, "Z Rotation", ""},
01034                 {DTAR_TRANSCHAN_SCALEX, "SCALE_X", 0, "X Scale", ""},
01035                 {DTAR_TRANSCHAN_SCALEY, "SCALE_Y", 0, "Y Scale", ""},
01036                 {DTAR_TRANSCHAN_SCALEZ, "SCALE_Z", 0, "Z Scale", ""},
01037                 {0, NULL, 0, NULL, NULL}};
01038         
01039         srna= RNA_def_struct(brna, "DriverTarget", NULL);
01040         RNA_def_struct_ui_text(srna, "Driver Target", "Source of input values for driver variables");
01041         
01042         /* Target Properties - ID-block to Drive */
01043         prop= RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE);
01044         RNA_def_property_struct_type(prop, "ID");
01045         RNA_def_property_flag(prop, PROP_EDITABLE);
01046         RNA_def_property_editable_func(prop, "rna_DriverTarget_id_editable");
01047         /* note: custom set function is ONLY to avoid rna setting a user for this. */
01048         RNA_def_property_pointer_funcs(prop, NULL, "rna_DriverTarget_id_set", "rna_DriverTarget_id_typef", NULL);
01049         RNA_def_property_ui_text(prop, "ID", "ID-block that the specific property used can be found from (id_type property must be set first)");
01050         RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
01051         
01052         prop= RNA_def_property(srna, "id_type", PROP_ENUM, PROP_NONE);
01053         RNA_def_property_enum_sdna(prop, NULL, "idtype");
01054         RNA_def_property_enum_items(prop, id_type_items);
01055         RNA_def_property_enum_default(prop, ID_OB);
01056         RNA_def_property_enum_funcs(prop, NULL, "rna_DriverTarget_id_type_set", NULL);
01057         RNA_def_property_editable_func(prop, "rna_DriverTarget_id_type_editable");
01058         RNA_def_property_ui_text(prop, "ID Type", "Type of ID-block that can be used");
01059         RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
01060         
01061         /* Target Properties - Property to Drive */
01062         prop= RNA_def_property(srna, "data_path", PROP_STRING, PROP_NONE);
01063         RNA_def_property_string_funcs(prop, "rna_DriverTarget_RnaPath_get", "rna_DriverTarget_RnaPath_length", "rna_DriverTarget_RnaPath_set");
01064         RNA_def_property_ui_text(prop, "Data Path", "RNA Path (from ID-block) to property used");
01065         RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
01066         
01067         prop= RNA_def_property(srna, "bone_target", PROP_STRING, PROP_NONE);
01068         RNA_def_property_string_sdna(prop, NULL, "pchan_name");
01069         RNA_def_property_ui_text(prop, "Bone Name", "Name of PoseBone to use as target");
01070         RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
01071         
01072         prop= RNA_def_property(srna, "transform_type", PROP_ENUM, PROP_NONE);
01073         RNA_def_property_enum_sdna(prop, NULL, "transChan");
01074         RNA_def_property_enum_items(prop, prop_trans_chan_items);
01075         RNA_def_property_ui_text(prop, "Type", "Driver variable type");
01076         RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
01077         
01078         prop= RNA_def_property(srna, "use_local_space_transform", PROP_BOOLEAN, PROP_NONE);
01079         RNA_def_property_boolean_sdna(prop, NULL, "flag", DTAR_FLAG_LOCALSPACE);
01080         RNA_def_property_ui_text(prop, "Local Space", "Use transforms in Local Space (as opposed to the worldspace default)");
01081         RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
01082 }
01083 
01084 static void rna_def_drivervar(BlenderRNA *brna)
01085 {
01086         StructRNA *srna;
01087         PropertyRNA *prop;
01088         
01089         static EnumPropertyItem prop_type_items[] = {
01090                 {DVAR_TYPE_SINGLE_PROP, "SINGLE_PROP", 0, "Single Property", "Use the value from some RNA property (Default)"},
01091                 {DVAR_TYPE_TRANSFORM_CHAN, "TRANSFORMS", 0, "Transform Channel", "Final transformation value of object or bone"},
01092                 {DVAR_TYPE_ROT_DIFF, "ROTATION_DIFF", 0, "Rotational Difference", "Use the angle between two bones"},
01093                 {DVAR_TYPE_LOC_DIFF, "LOC_DIFF", 0, "Distance", "Distance between two bones or objects"},
01094                 {0, NULL, 0, NULL, NULL}};
01095                 
01096         
01097         srna= RNA_def_struct(brna, "DriverVariable", NULL);
01098         RNA_def_struct_sdna(srna, "DriverVar");
01099         RNA_def_struct_ui_text(srna, "Driver Variable", "Variable from some source/target for driver relationship");
01100         
01101         /* Variable Name */
01102         prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
01103         RNA_def_struct_name_property(srna, prop);
01104         RNA_def_property_ui_text(prop, "Name", "Name to use in scripted expressions/functions. (No spaces or dots are allowed. Also, must not start with a symbol or digit)");
01105         RNA_def_property_update(prop, 0, "rna_DriverTarget_update_name"); // XXX
01106         
01107         /* Enums */
01108         prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
01109         RNA_def_property_enum_items(prop, prop_type_items);
01110         RNA_def_property_enum_funcs(prop, NULL, "rna_DriverVariable_type_set", NULL);
01111         RNA_def_property_ui_text(prop, "Type", "Driver variable type");
01112         RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_data"); // XXX
01113         
01114         /* Targets */
01115         // TODO: for nicer api, only expose the relevant props via subclassing, instead of exposing the collection of targets
01116         prop= RNA_def_property(srna, "targets", PROP_COLLECTION, PROP_NONE);
01117         RNA_def_property_collection_sdna(prop, NULL, "targets", "num_targets");
01118         RNA_def_property_struct_type(prop, "DriverTarget");
01119         RNA_def_property_ui_text(prop, "Targets", "Sources of input data for evaluating this variable");
01120 }
01121 
01122 
01123 /* channeldriver.variables.* */
01124 static void rna_def_channeldriver_variables(BlenderRNA *brna, PropertyRNA *cprop)
01125 {
01126         StructRNA *srna;
01127 //      PropertyRNA *prop;
01128         
01129         FunctionRNA *func;
01130         PropertyRNA *parm;
01131         
01132         RNA_def_property_srna(cprop, "ChannelDriverVariables");
01133         srna= RNA_def_struct(brna, "ChannelDriverVariables", NULL);
01134         RNA_def_struct_sdna(srna, "ChannelDriver");
01135         RNA_def_struct_ui_text(srna, "ChannelDriver Variables", "Collection of channel driver Variables");
01136         
01137         
01138         /* add variable */
01139         func= RNA_def_function(srna, "new", "rna_Driver_new_variable");
01140         RNA_def_function_ui_description(func, "Add a new variable for the driver.");
01141                 /* return type */
01142         parm= RNA_def_pointer(func, "var", "DriverVariable", "", "Newly created Driver Variable.");
01143                 RNA_def_function_return(func, parm);
01144 
01145         /* remove variable */
01146         func= RNA_def_function(srna, "remove", "rna_Driver_remove_variable");
01147         RNA_def_function_ui_description(func, "Remove an existing variable from the driver.");
01148         RNA_def_function_flag(func, FUNC_USE_REPORTS);
01149         /* target to remove */
01150         parm= RNA_def_pointer(func, "variable", "DriverVariable", "", "Variable to remove from the driver.");
01151         RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
01152 }
01153 
01154 static void rna_def_channeldriver(BlenderRNA *brna)
01155 {
01156         StructRNA *srna;
01157         PropertyRNA *prop;
01158         
01159         static EnumPropertyItem prop_type_items[] = {
01160                 {DRIVER_TYPE_AVERAGE, "AVERAGE", 0, "Averaged Value", ""},
01161                 {DRIVER_TYPE_SUM, "SUM", 0, "Sum Values", ""},
01162                 {DRIVER_TYPE_PYTHON, "SCRIPTED", 0, "Scripted Expression", ""},
01163                 {DRIVER_TYPE_MIN, "MIN", 0, "Minimum Value", ""},
01164                 {DRIVER_TYPE_MAX, "MAX", 0, "Maximum Value", ""},
01165                 {0, NULL, 0, NULL, NULL}};
01166 
01167         srna= RNA_def_struct(brna, "Driver", NULL);
01168         RNA_def_struct_sdna(srna, "ChannelDriver");
01169         RNA_def_struct_ui_text(srna, "Driver", "Driver for the value of a setting based on an external value");
01170 
01171         /* Enums */
01172         prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
01173         RNA_def_property_enum_items(prop, prop_type_items);
01174         RNA_def_property_ui_text(prop, "Type", "Driver type");
01175         RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_data");
01176 
01177         /* String values */
01178         prop= RNA_def_property(srna, "expression", PROP_STRING, PROP_NONE);
01179         RNA_def_property_ui_text(prop, "Expression", "Expression to use for Scripted Expression");
01180         RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_expr");
01181 
01182         /* Collections */
01183         prop= RNA_def_property(srna, "variables", PROP_COLLECTION, PROP_NONE);
01184         RNA_def_property_collection_sdna(prop, NULL, "variables", NULL);
01185         RNA_def_property_struct_type(prop, "DriverVariable");
01186         RNA_def_property_ui_text(prop, "Variables", "Properties acting as inputs for this driver");
01187         rna_def_channeldriver_variables(brna, prop);
01188         
01189         /* Settings */
01190         prop= RNA_def_property(srna, "show_debug_info", PROP_BOOLEAN, PROP_NONE);
01191         RNA_def_property_boolean_sdna(prop, NULL, "flag", DRIVER_FLAG_SHOWDEBUG);
01192         RNA_def_property_ui_text(prop, "Show Debug Info", "Show intermediate values for the driver calculations to allow debugging of drivers");
01193         
01194         /* State Info (for Debugging) */
01195         prop= RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
01196         RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", DRIVER_FLAG_INVALID);
01197         RNA_def_property_ui_text(prop, "Invalid", "Driver could not be evaluated in past, so should be skipped");
01198         
01199         
01200         /* Functions */
01201         RNA_api_drivers(srna);
01202 }
01203 
01204 /* *********************** */
01205 
01206 static void rna_def_fpoint(BlenderRNA *brna)
01207 {
01208         StructRNA *srna;
01209         PropertyRNA *prop;
01210         
01211         srna= RNA_def_struct(brna, "FCurveSample", NULL);
01212         RNA_def_struct_sdna(srna, "FPoint");
01213         RNA_def_struct_ui_text(srna, "F-Curve Sample", "Sample point for F-Curve");
01214         
01215         /* Boolean values */
01216         prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
01217         RNA_def_property_boolean_sdna(prop, NULL, "flag", 1);
01218         RNA_def_property_ui_text(prop, "Select", "Selection status");
01219         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
01220         
01221         /* Vector value */
01222         prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
01223         RNA_def_property_float_sdna(prop, NULL, "vec");
01224         RNA_def_property_array(prop, 2);
01225         RNA_def_property_ui_text(prop, "Point", "Point coordinates");
01226         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
01227 }
01228 
01229 
01230 /* duplicate of BezTriple in rna_curve.c
01231  * but with F-Curve specific options updates/functionality 
01232  */
01233 static void rna_def_fkeyframe(BlenderRNA *brna)
01234 {
01235         StructRNA *srna;
01236         PropertyRNA *prop;
01237         
01238         srna= RNA_def_struct(brna, "Keyframe", NULL);
01239         RNA_def_struct_sdna(srna, "BezTriple");
01240         RNA_def_struct_ui_text(srna, "Keyframe", "Bezier curve point with two handles defining a Keyframe on an F-Curve");
01241         
01242         /* Boolean values */
01243         prop= RNA_def_property(srna, "select_left_handle", PROP_BOOLEAN, PROP_NONE);
01244         RNA_def_property_boolean_sdna(prop, NULL, "f1", 0);
01245         RNA_def_property_ui_text(prop, "Handle 1 selected", "Handle 1 selection status");
01246         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
01247         
01248         prop= RNA_def_property(srna, "select_right_handle", PROP_BOOLEAN, PROP_NONE);
01249         RNA_def_property_boolean_sdna(prop, NULL, "f3", 0);
01250         RNA_def_property_ui_text(prop, "Handle 2 selected", "Handle 2 selection status");
01251         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
01252         
01253         prop= RNA_def_property(srna, "select_control_point", PROP_BOOLEAN, PROP_NONE);
01254         RNA_def_property_boolean_sdna(prop, NULL, "f2", 0);
01255         RNA_def_property_ui_text(prop, "Select", "Control point selection status");
01256         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
01257         
01258         /* Enums */
01259         prop= RNA_def_property(srna, "handle_left_type", PROP_ENUM, PROP_NONE);
01260         RNA_def_property_enum_sdna(prop, NULL, "h1");
01261         RNA_def_property_enum_items(prop, beztriple_handle_type_items);
01262         RNA_def_property_ui_text(prop, "Handle 1 Type", "Handle types");
01263         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
01264         
01265         prop= RNA_def_property(srna, "handle_right_type", PROP_ENUM, PROP_NONE);
01266         RNA_def_property_enum_sdna(prop, NULL, "h2");
01267         RNA_def_property_enum_items(prop, beztriple_handle_type_items);
01268         RNA_def_property_ui_text(prop, "Handle 2 Type", "Handle types");
01269         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
01270         
01271         prop= RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
01272         RNA_def_property_enum_sdna(prop, NULL, "ipo");
01273         RNA_def_property_enum_items(prop, beztriple_interpolation_mode_items);
01274         RNA_def_property_ui_text(prop, "Interpolation", "Interpolation method to use for segment of the curve from this Keyframe until the next Keyframe");
01275         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
01276         
01277         prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
01278         RNA_def_property_enum_sdna(prop, NULL, "hide");
01279         RNA_def_property_enum_items(prop, beztriple_keyframe_type_items);
01280         RNA_def_property_ui_text(prop, "Type", "The type of keyframe");
01281         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
01282         
01283         /* Vector values */
01284         prop= RNA_def_property(srna, "handle_left", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
01285         RNA_def_property_array(prop, 2);
01286         RNA_def_property_float_funcs(prop, "rna_FKeyframe_handle1_get", "rna_FKeyframe_handle1_set", NULL);
01287         RNA_def_property_ui_text(prop, "Handle 1", "Coordinates of the first handle");
01288         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
01289         
01290         prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
01291         RNA_def_property_array(prop, 2);
01292         RNA_def_property_float_funcs(prop, "rna_FKeyframe_ctrlpoint_get", "rna_FKeyframe_ctrlpoint_set", NULL);
01293         RNA_def_property_ui_text(prop, "Control Point", "Coordinates of the control point");
01294         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
01295         
01296         prop= RNA_def_property(srna, "handle_right", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
01297         RNA_def_property_array(prop, 2);
01298         RNA_def_property_float_funcs(prop, "rna_FKeyframe_handle2_get", "rna_FKeyframe_handle2_set", NULL);
01299         RNA_def_property_ui_text(prop, "Handle 2", "Coordinates of the second handle");
01300         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
01301 }
01302 
01303 static void rna_def_fcurve_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
01304 {
01305         /* add modifiers */
01306         StructRNA *srna;
01307         PropertyRNA *prop;
01308 
01309         FunctionRNA *func;
01310         PropertyRNA *parm;
01311 
01312         RNA_def_property_srna(cprop, "FCurveModifiers");
01313         srna= RNA_def_struct(brna, "FCurveModifiers", NULL);
01314         RNA_def_struct_sdna(srna, "FCurve");
01315         RNA_def_struct_ui_text(srna, "F-Curve Modifiers", "Collection of F-Curve Modifiers");
01316 
01317 
01318         /* Collection active property */
01319         prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
01320         RNA_def_property_struct_type(prop, "FModifier");
01321         RNA_def_property_pointer_funcs(prop, "rna_FCurve_active_modifier_get", "rna_FCurve_active_modifier_set", NULL, NULL);
01322         RNA_def_property_flag(prop, PROP_EDITABLE);
01323         RNA_def_property_ui_text(prop, "Active F-Curve Modifier", "Active F-Curve Modifier");
01324 
01325         /* Constraint collection */
01326         func= RNA_def_function(srna, "new", "rna_FCurve_modifiers_new");
01327         RNA_def_function_ui_description(func, "Add a constraint to this object");
01328         /* return type */
01329         parm= RNA_def_pointer(func, "fmodifier", "FModifier", "", "New fmodifier.");
01330         RNA_def_function_return(func, parm);
01331         /* object to add */
01332         parm= RNA_def_enum(func, "type", fmodifier_type_items, 1, "", "Constraint type to add.");
01333         RNA_def_property_flag(parm, PROP_REQUIRED);
01334 
01335         func= RNA_def_function(srna, "remove", "rna_FCurve_modifiers_remove");
01336         RNA_def_function_flag(func, FUNC_USE_REPORTS);
01337         RNA_def_function_ui_description(func, "Remove a modifier from this fcurve.");
01338         /* modifier to remove */
01339         parm= RNA_def_pointer(func, "modifier", "FModifier", "", "Removed modifier.");
01340         RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
01341 }
01342 
01343 /* fcurve.keyframe_points */
01344 static void rna_def_fcurve_keyframe_points(BlenderRNA *brna, PropertyRNA *cprop)
01345 {
01346         StructRNA *srna;
01347 
01348         FunctionRNA *func;
01349         PropertyRNA *parm;
01350 
01351         static EnumPropertyItem keyframe_flag_items[] = {
01352                 {INSERTKEY_REPLACE, "REPLACE", 0, "Replace", "Don't add any new keyframes, but just replace existing ones"},
01353                 {INSERTKEY_NEEDED, "NEEDED", 0, "Needed", "Only adds keyframes that are needed"},
01354                 {INSERTKEY_FAST, "FAST", 0, "Fast", "Fast keyframe insertion to avoid recalculating the curve each time"},
01355                 {0, NULL, 0, NULL, NULL}};
01356 
01357         RNA_def_property_srna(cprop, "FCurveKeyframePoints");
01358         srna= RNA_def_struct(brna, "FCurveKeyframePoints", NULL);
01359         RNA_def_struct_sdna(srna, "FCurve");
01360         RNA_def_struct_ui_text(srna, "Keyframe Points", "Collection of keyframe points");
01361 
01362         func= RNA_def_function(srna, "insert", "rna_FKeyframe_points_insert");
01363         RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve.");
01364         parm= RNA_def_float(func, "frame", 0.0f, -FLT_MAX, FLT_MAX, "", "X Value of this keyframe point", -FLT_MAX, FLT_MAX);
01365         RNA_def_property_flag(parm, PROP_REQUIRED);
01366         parm= RNA_def_float(func, "value", 0.0f, -FLT_MAX, FLT_MAX, "", "Y Value of this keyframe point", -FLT_MAX, FLT_MAX);
01367         RNA_def_property_flag(parm, PROP_REQUIRED);
01368 
01369         RNA_def_enum_flag(func, "options", keyframe_flag_items, 0, "", "Keyframe options.");
01370 
01371         parm= RNA_def_pointer(func, "keyframe", "Keyframe", "", "Newly created keyframe");
01372         RNA_def_function_return(func, parm);
01373 
01374         func= RNA_def_function(srna, "add", "rna_FKeyframe_points_add");
01375         RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve.");
01376         RNA_def_int(func, "count", 1, 1, INT_MAX, "Number", "Number of points to add to the spline", 1, INT_MAX);
01377 
01378         func= RNA_def_function(srna, "remove", "rna_FKeyframe_points_remove");
01379         RNA_def_function_ui_description(func, "Remove keyframe from an fcurve.");
01380         RNA_def_function_flag(func, FUNC_USE_REPORTS);
01381         parm= RNA_def_pointer(func, "keyframe", "Keyframe", "", "Keyframe to remove.");
01382         RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
01383         /* optional */
01384         RNA_def_boolean(func, "fast", 0, "Fast", "Fast keyframe removal to avoid recalculating the curve each time");
01385 }
01386 
01387 static void rna_def_fcurve(BlenderRNA *brna)
01388 {
01389         StructRNA *srna;
01390         PropertyRNA *prop;
01391         FunctionRNA *func;
01392         PropertyRNA *parm;
01393 
01394         static EnumPropertyItem prop_mode_extend_items[] = {
01395                 {FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", 0, "Constant", ""},
01396                 {FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", 0, "Linear", ""},
01397                 {0, NULL, 0, NULL, NULL}};
01398         static EnumPropertyItem prop_mode_color_items[] = {
01399                 {FCURVE_COLOR_AUTO_RAINBOW, "AUTO_RAINBOW", 0, "Auto Rainbow", ""},
01400                 {FCURVE_COLOR_AUTO_RGB, "AUTO_RGB", 0, "Auto XYZ to RGB", ""},
01401                 {FCURVE_COLOR_CUSTOM, "CUSTOM", 0, "User Defined", ""},
01402                 {0, NULL, 0, NULL, NULL}};
01403 
01404         srna= RNA_def_struct(brna, "FCurve", NULL);
01405         RNA_def_struct_ui_text(srna, "F-Curve", "F-Curve defining values of a period of time");
01406         RNA_def_struct_ui_icon(srna, ICON_ANIM_DATA);
01407 
01408         /* Enums */
01409         prop= RNA_def_property(srna, "extrapolation", PROP_ENUM, PROP_NONE);
01410         RNA_def_property_enum_sdna(prop, NULL, "extend");
01411         RNA_def_property_enum_items(prop, prop_mode_extend_items);
01412         RNA_def_property_ui_text(prop, "Extrapolation", "");
01413         RNA_def_property_update(prop, NC_ANIMATION, NULL);      // XXX need an update callback for this so that animation gets evaluated
01414 
01415         /* Pointers */
01416         prop= RNA_def_property(srna, "driver", PROP_POINTER, PROP_NONE);
01417         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
01418         RNA_def_property_ui_text(prop, "Driver", "Channel Driver (only set for Driver F-Curves)");
01419         
01420         prop= RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
01421         RNA_def_property_pointer_sdna(prop, NULL, "grp");
01422         RNA_def_property_flag(prop, PROP_EDITABLE);
01423         RNA_def_property_ui_text(prop, "Group", "Action Group that this F-Curve belongs to");
01424         RNA_def_property_pointer_funcs(prop, NULL, "rna_FCurve_group_set", NULL, NULL);
01425         RNA_def_property_update(prop, NC_ANIMATION, NULL);
01426 
01427         /* Path + Array Index */
01428         prop= RNA_def_property(srna, "data_path", PROP_STRING, PROP_NONE);
01429         RNA_def_property_string_funcs(prop, "rna_FCurve_RnaPath_get", "rna_FCurve_RnaPath_length", "rna_FCurve_RnaPath_set");
01430         RNA_def_property_ui_text(prop, "Data Path", "RNA Path to property affected by F-Curve");
01431         RNA_def_property_update(prop, NC_ANIMATION, NULL);      // XXX need an update callback for this to that animation gets evaluated
01432 
01433         /* called 'index' when given as function arg */
01434         prop= RNA_def_property(srna, "array_index", PROP_INT, PROP_NONE);
01435         RNA_def_property_ui_text(prop, "RNA Array Index", "Index to the specific property affected by F-Curve if applicable");
01436         RNA_def_property_update(prop, NC_ANIMATION, NULL);      // XXX need an update callback for this so that animation gets evaluated
01437         
01438         /* Color */
01439         prop= RNA_def_property(srna, "color_mode", PROP_ENUM, PROP_NONE);
01440         RNA_def_property_enum_items(prop, prop_mode_color_items);
01441         RNA_def_property_ui_text(prop, "Color Mode", "Method used to determine color of F-Curve in Graph Editor");
01442         RNA_def_property_update(prop, NC_ANIMATION, NULL);      
01443         
01444         prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
01445         RNA_def_property_array(prop, 3);
01446         RNA_def_property_range(prop, 0.0f, 1.0f);
01447         RNA_def_property_ui_text(prop, "Color", "Color of the F-Curve in the Graph Editor");
01448         RNA_def_property_update(prop, NC_ANIMATION, NULL);      
01449         
01450         /* Flags */
01451         prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
01452         RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_SELECTED);
01453         RNA_def_property_ui_text(prop, "Select", "F-Curve is selected for editing");
01454         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
01455         
01456         prop= RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
01457         RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_PROTECTED);
01458         RNA_def_property_ui_text(prop, "Lock", "F-Curve's settings cannot be edited");
01459         RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
01460         
01461         prop= RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
01462         RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_MUTED);
01463         RNA_def_property_ui_text(prop, "Muted", "F-Curve is not evaluated");
01464         RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
01465         
01466         prop= RNA_def_property(srna, "use_auto_handle_clamp", PROP_BOOLEAN, PROP_NONE);
01467         RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_AUTO_HANDLES);
01468         RNA_def_property_ui_text(prop, "Auto Clamped Handles", "All auto-handles for F-Curve are clamped");
01469         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
01470         
01471         prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
01472         RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", FCURVE_VISIBLE);
01473         RNA_def_property_ui_text(prop, "Hide", "F-Curve and its keyframes are hidden in the Graph Editor graphs");
01474         RNA_def_property_update(prop, NC_SPACE|ND_SPACE_GRAPH, NULL);
01475 
01476         /* State Info (for Debugging) */
01477         prop= RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
01478         RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", FCURVE_DISABLED);
01479         RNA_def_property_ui_text(prop, "Valid", "False when F-Curve could not be evaluated in past, so should be skipped when evaluating");
01480         RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
01481         
01482         /* Collections */
01483         prop= RNA_def_property(srna, "sampled_points", PROP_COLLECTION, PROP_NONE);
01484         RNA_def_property_collection_sdna(prop, NULL, "fpt", "totvert");
01485         RNA_def_property_struct_type(prop, "FCurveSample");
01486         RNA_def_property_ui_text(prop, "Sampled Points", "Sampled animation data");
01487 
01488         prop= RNA_def_property(srna, "keyframe_points", PROP_COLLECTION, PROP_NONE);
01489         RNA_def_property_collection_sdna(prop, NULL, "bezt", "totvert");
01490         RNA_def_property_struct_type(prop, "Keyframe");
01491         RNA_def_property_ui_text(prop, "Keyframes", "User-editable keyframes");
01492         rna_def_fcurve_keyframe_points(brna, prop);
01493         
01494         prop= RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
01495         RNA_def_property_struct_type(prop, "FModifier");
01496         RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the shape of the F-Curve");
01497         rna_def_fcurve_modifiers(brna, prop);
01498 
01499         /* Functions */
01500         func= RNA_def_function(srna, "evaluate", "evaluate_fcurve"); /* calls the C/API direct */
01501         RNA_def_function_ui_description(func, "Evaluate fcurve.");
01502         parm= RNA_def_float(func, "frame", 1.0f, -FLT_MAX, FLT_MAX, "Frame", "Evaluate fcurve at given frame", -FLT_MAX, FLT_MAX);
01503         RNA_def_property_flag(parm, PROP_REQUIRED);
01504         /* return value */
01505         parm= RNA_def_float(func, "position", 0, -FLT_MAX, FLT_MAX, "Position", "FCurve position", -FLT_MAX, FLT_MAX);
01506         RNA_def_function_return(func, parm);
01507 
01508         func= RNA_def_function(srna, "range", "rna_fcurve_range");
01509         RNA_def_function_ui_description(func, "Get the time extents for F-Curve.");
01510         /* return value */
01511         parm= RNA_def_float_vector(func, "range", 2, NULL, -FLT_MAX, FLT_MAX, "Range", "Min/Max values", -FLT_MAX, FLT_MAX);
01512         RNA_def_property_flag(parm, PROP_THICK_WRAP);
01513         RNA_def_function_output(func, parm);
01514 }
01515 
01516 /* *********************** */
01517 
01518 void RNA_def_fcurve(BlenderRNA *brna)
01519 {
01520         rna_def_fcurve(brna);
01521                 rna_def_fkeyframe(brna);
01522                 rna_def_fpoint(brna);
01523         
01524         rna_def_drivertarget(brna);
01525         rna_def_drivervar(brna);
01526         rna_def_channeldriver(brna);
01527         
01528         rna_def_fmodifier(brna);
01529         
01530         rna_def_fmodifier_generator(brna);
01531         rna_def_fmodifier_function_generator(brna);
01532         rna_def_fmodifier_envelope(brna);
01533                 rna_def_fmodifier_envelope_ctrl(brna);
01534         rna_def_fmodifier_cycles(brna);
01535         rna_def_fmodifier_python(brna);
01536         rna_def_fmodifier_limits(brna);
01537         rna_def_fmodifier_noise(brna);
01538         rna_def_fmodifier_stepped(brna);
01539 }
01540 
01541 
01542 #endif