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