Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_nla.c
| Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include <math.h> | #include <math.h> | ||||
| /* needed for some of the validation stuff... */ | /* needed for some of the validation stuff... */ | ||||
| #include "BKE_animsys.h" | #include "BKE_animsys.h" | ||||
| #include "BKE_nla.h" | #include "BKE_nla.h" | ||||
| #include "BKE_fcurve.h" | |||||
| #include "ED_anim_api.h" | #include "ED_anim_api.h" | ||||
| /* temp constant defined for these funcs only... */ | /* temp constant defined for these funcs only... */ | ||||
| #define NLASTRIP_MIN_LEN_THRESH 0.1f | #define NLASTRIP_MIN_LEN_THRESH 0.1f | ||||
| static void rna_NlaStrip_name_set(PointerRNA *ptr, const char *value) | static void rna_NlaStrip_name_set(PointerRNA *ptr, const char *value) | ||||
| { | { | ||||
| NlaStrip *data = (NlaStrip *)ptr->data; | NlaStrip *data = (NlaStrip *)ptr->data; | ||||
| ▲ Show 20 Lines • Show All 265 Lines • ▼ Show 20 Lines | if (value) { | ||||
| /* set the flag, then make sure a curve for this exists */ | /* set the flag, then make sure a curve for this exists */ | ||||
| data->flag |= NLASTRIP_FLAG_USR_TIME; | data->flag |= NLASTRIP_FLAG_USR_TIME; | ||||
| BKE_nlastrip_validate_fcurves(data); | BKE_nlastrip_validate_fcurves(data); | ||||
| } | } | ||||
| else | else | ||||
| data->flag &= ~NLASTRIP_FLAG_USR_TIME; | data->flag &= ~NLASTRIP_FLAG_USR_TIME; | ||||
| } | } | ||||
| static FCurve *rna_NlaStrip_fcurve_find(NlaStrip *strip, ReportList *reports, const char *data_path, int index) | |||||
| { | |||||
| if (data_path[0] == '\0') { | |||||
| BKE_report(reports, RPT_ERROR, "F-Curve data path empty, invalid argument"); | |||||
| return NULL; | |||||
| } | |||||
| /* Returns NULL if not found. */ | |||||
| return list_find_fcurve(&strip->fcurves, data_path, index); | |||||
| } | |||||
| static NlaStrip *rna_NlaStrip_new(NlaTrack *track, bContext *C, ReportList *reports, const char *UNUSED(name), | static NlaStrip *rna_NlaStrip_new(NlaTrack *track, bContext *C, ReportList *reports, const char *UNUSED(name), | ||||
| int start, bAction *action) | int start, bAction *action) | ||||
| { | { | ||||
| NlaStrip *strip = add_nlastrip(action); | NlaStrip *strip = add_nlastrip(action); | ||||
| if (strip == NULL) { | if (strip == NULL) { | ||||
| BKE_report(reports, RPT_ERROR, "Unable to create new strip"); | BKE_report(reports, RPT_ERROR, "Unable to create new strip"); | ||||
| return NULL; | return NULL; | ||||
| ▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | |||||
| EnumPropertyItem nla_mode_extend_items[] = { | EnumPropertyItem nla_mode_extend_items[] = { | ||||
| {NLASTRIP_EXTEND_NOTHING, "NOTHING", 0, "Nothing", "Strip has no influence past its extents"}, | {NLASTRIP_EXTEND_NOTHING, "NOTHING", 0, "Nothing", "Strip has no influence past its extents"}, | ||||
| {NLASTRIP_EXTEND_HOLD, "HOLD", 0, "Hold", | {NLASTRIP_EXTEND_HOLD, "HOLD", 0, "Hold", | ||||
| "Hold the first frame if no previous strips in track, and always hold last frame"}, | "Hold the first frame if no previous strips in track, and always hold last frame"}, | ||||
| {NLASTRIP_EXTEND_HOLD_FORWARD, "HOLD_FORWARD", 0, "Hold Forward", "Only hold last frame"}, | {NLASTRIP_EXTEND_HOLD_FORWARD, "HOLD_FORWARD", 0, "Hold Forward", "Only hold last frame"}, | ||||
| {0, NULL, 0, NULL, NULL} | {0, NULL, 0, NULL, NULL} | ||||
| }; | }; | ||||
| static void rna_def_strip_fcurves(BlenderRNA *brna, PropertyRNA *cprop) | |||||
| { | |||||
| StructRNA *srna; | |||||
| FunctionRNA *func; | |||||
| PropertyRNA *parm; | |||||
| RNA_def_property_srna(cprop, "StripFCurves"); | |||||
aligorith: It would be better to call this NlaStripFCurves, to avoid confusion with Sequencer strips | |||||
| srna = RNA_def_struct(brna, "StripFCurves", NULL); | |||||
| RNA_def_struct_sdna(srna, "NlaStrip"); | |||||
| RNA_def_struct_ui_text(srna, "Strip F-Curves", "Collection of strip F-Curves"); | |||||
| /* Strip.fcurves.find(...) */ | |||||
| func = RNA_def_function(srna, "find", "rna_NlaStrip_fcurve_find"); | |||||
| RNA_def_function_ui_description(func, "Find an F-Curve. Note that this function performs a linear scan " | |||||
| "of all F-Curves in the strip."); | |||||
| RNA_def_function_flag(func, FUNC_USE_REPORTS); | |||||
| parm = RNA_def_string(func, "data_path", NULL, 0, "Data Path", "F-Curve data path"); | |||||
| RNA_def_property_flag(parm, PROP_REQUIRED); | |||||
| RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Array index", 0, INT_MAX); | |||||
| parm = RNA_def_pointer(func, "fcurve", "FCurve", "", "The found F-Curve, or None if it doesn't exist"); | |||||
| RNA_def_function_return(func, parm); | |||||
| } | |||||
| static void rna_def_nlastrip(BlenderRNA *brna) | static void rna_def_nlastrip(BlenderRNA *brna) | ||||
| { | { | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| /* enum defs */ | /* enum defs */ | ||||
| static EnumPropertyItem prop_type_items[] = { | static EnumPropertyItem prop_type_items[] = { | ||||
| {NLASTRIP_TYPE_CLIP, "CLIP", 0, "Action Clip", "NLA Strip references some Action"}, | {NLASTRIP_TYPE_CLIP, "CLIP", 0, "Action Clip", "NLA Strip references some Action"}, | ||||
| ▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | static void rna_def_nlastrip(BlenderRNA *brna) | ||||
| /* these limits can be extended, but beyond this, we can get some crazy+annoying bugs | /* these limits can be extended, but beyond this, we can get some crazy+annoying bugs | ||||
| * due to numeric errors */ | * due to numeric errors */ | ||||
| RNA_def_property_range(prop, 0.0001f, 1000.0f); | RNA_def_property_range(prop, 0.0001f, 1000.0f); | ||||
| RNA_def_property_ui_text(prop, "Scale", "Scaling factor for action"); | RNA_def_property_ui_text(prop, "Scale", "Scaling factor for action"); | ||||
| RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, NULL); /* this will do? */ | RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, NULL); /* this will do? */ | ||||
| /* Strip's F-Curves */ | /* Strip's F-Curves */ | ||||
| prop = RNA_def_property(srna, "fcurves", PROP_COLLECTION, PROP_NONE); | prop = RNA_def_property(srna, "fcurves", PROP_COLLECTION, PROP_NONE); | ||||
| RNA_def_property_collection_sdna(prop, NULL, "fcurves", NULL); | |||||
| RNA_def_property_struct_type(prop, "FCurve"); | RNA_def_property_struct_type(prop, "FCurve"); | ||||
| RNA_def_property_ui_text(prop, "F-Curves", "F-Curves for controlling the strip's influence and timing"); | RNA_def_property_ui_text(prop, "F-Curves", "F-Curves for controlling the strip's influence and timing"); | ||||
| rna_def_strip_fcurves(brna, prop); | |||||
| /* Strip's F-Modifiers */ | /* Strip's F-Modifiers */ | ||||
| prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE); | prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE); | ||||
| RNA_def_property_struct_type(prop, "FModifier"); | RNA_def_property_struct_type(prop, "FModifier"); | ||||
| RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting all the F-Curves in the referenced Action"); | RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting all the F-Curves in the referenced Action"); | ||||
| /* Strip's Sub-Strips (for Meta-Strips) */ | /* Strip's Sub-Strips (for Meta-Strips) */ | ||||
| prop = RNA_def_property(srna, "strips", PROP_COLLECTION, PROP_NONE); | prop = RNA_def_property(srna, "strips", PROP_COLLECTION, PROP_NONE); | ||||
| RNA_def_property_struct_type(prop, "NlaStrip"); | RNA_def_property_struct_type(prop, "NlaStrip"); | ||||
| ▲ Show 20 Lines • Show All 164 Lines • Show Last 20 Lines | |||||
It would be better to call this NlaStripFCurves, to avoid confusion with Sequencer strips