Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-07-03 05:10:46 +0400
committerJoshua Leung <aligorith@gmail.com>2009-07-03 05:10:46 +0400
commit28d371d1178642e17f5dfc300f1500a132ce7149 (patch)
tree8b6eb6ae7ac36b4a1823e5725ed92f29b1e528c8 /source/blender
parente55d90b340d15944d53414419d8f4671f435af75 (diff)
NLA SoC: Assorted fixes
* Made NLA Editing functions more aware of transitions. - A transition can only be added between a pair of action-clips. Previous, two transitions could be added next to each other, which has undefined behaviour - Deleting a strip with transition(s) on either side will remove the transitions too. Feedback welcome on this - The 'type' setting for NLA-Strips is no longer editable. This was dangerous as it could result in transitions with undefined behaviour (though nothing would happen). * Menus for adding F-Modifiers now only show relevant modifiers (i.e. 'Invalid' is not included in the list, and 'Cycles' doesn't need to be shown for NLA since we've got repeat) * Function Generator and Noise F-Modifiers now have complete GUI's. A few settings were missed during the porting process. * F-Modifier buttons now have their source-ID's included in the RNA Pointers used. This didn't get them animateable directly, but is a step closer.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_fcurve.h33
-rw-r--r--source/blender/blenkernel/intern/nla.c8
-rw-r--r--source/blender/editors/animation/fmodifier_ui.c56
-rw-r--r--source/blender/editors/include/ED_anim_api.h2
-rw-r--r--source/blender/editors/space_graph/graph_buttons.c2
-rw-r--r--source/blender/editors/space_graph/graph_edit.c31
-rw-r--r--source/blender/editors/space_nla/nla_buttons.c2
-rw-r--r--source/blender/editors/space_nla/nla_edit.c50
-rw-r--r--source/blender/makesdna/DNA_anim_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_nla.c6
10 files changed, 150 insertions, 42 deletions
diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h
index cfc4e9077f6..4dcb08dc0df 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -1,12 +1,33 @@
-/* Testing code for new animation system in 2.5
- * Copyright 2009, Joshua Leung
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
+ * All rights reserved.
+ *
+ * Contributor(s): Joshua Leung (full recode)
+ *
+ * ***** END GPL LICENSE BLOCK *****
*/
#ifndef BKE_FCURVE_H
#define BKE_FCURVE_H
-//struct ListBase;
-
struct FCurve;
struct FModifier;
struct ChannelDriver;
@@ -54,8 +75,8 @@ typedef struct FModifierTypeInfo {
short size; /* size in bytes of the struct */
short acttype; /* eFMI_Action_Types */
short requires; /* eFMI_Requirement_Flags */
- char name[32]; /* name of modifier in interface */
- char structName[32]; /* name of struct for SDNA */
+ char name[64]; /* name of modifier in interface */
+ char structName[64]; /* name of struct for SDNA */
/* data management function pointers - special handling */
/* free any data that is allocated separately (optional) */
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 14e658b3903..d554fbbabc1 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -66,7 +66,6 @@
/* Remove the given NLA strip from the NLA track it occupies, free the strip's data,
* and the strip itself.
*/
-// TODO: with things like transitions, should these get freed too? Maybe better as a UI tool
void free_nlastrip (ListBase *strips, NlaStrip *strip)
{
/* sanity checks */
@@ -793,6 +792,7 @@ void BKE_nla_action_pushdown (AnimData *adt)
/* not first, so extend mode can only be NLASTRIP_EXTEND_HOLD_FORWARD not NLASTRIP_EXTEND_HOLD,
* so that it doesn't override strips in previous tracks
*/
+ // FIXME: this needs to be more automated, since user can rearrange strips
strip->extendmode= NLASTRIP_EXTEND_HOLD_FORWARD;
}
}
@@ -844,7 +844,7 @@ short BKE_nla_tweakmode_enter (AnimData *adt)
if (strip->act == activeStrip->act)
strip->flag |= NLASTRIP_FLAG_TWEAKUSER;
else
- strip->flag &= ~NLASTRIP_FLAG_TWEAKUSER; // XXX probably don't need to clear this...
+ strip->flag &= ~NLASTRIP_FLAG_TWEAKUSER;
}
}
@@ -887,8 +887,8 @@ void BKE_nla_tweakmode_exit (AnimData *adt)
// TODO: need to sync the user-strip with the new state of the action!
- /* for all NLA-tracks, clear the 'disabled' flag
- * for all NLA-strips, clear the 'tweak-user' flag
+ /* for all Tracks, clear the 'disabled' flag
+ * for all Strips, clear the 'tweak-user' flag
*/
for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) {
nlt->flag &= ~NLATRACK_DISABLED;
diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c
index cd0a00fa859..7a618f4d222 100644
--- a/source/blender/editors/animation/fmodifier_ui.c
+++ b/source/blender/editors/animation/fmodifier_ui.c
@@ -134,7 +134,7 @@ static void delete_fmodifier_cb (bContext *C, void *fmods_v, void *fcm_v)
/* --------------- */
/* draw settings for generator modifier */
-static void draw_modifier__generator(uiLayout *layout, FModifier *fcm, short width)
+static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, short width)
{
FMod_Generator *data= (FMod_Generator *)fcm->data;
uiLayout *col, *row;
@@ -143,7 +143,7 @@ static void draw_modifier__generator(uiLayout *layout, FModifier *fcm, short wid
PointerRNA ptr;
/* init the RNA-pointer */
- RNA_pointer_create(NULL, &RNA_FModifierFunctionGenerator, fcm, &ptr);
+ RNA_pointer_create(id, &RNA_FModifierFunctionGenerator, fcm, &ptr);
/* basic settings (backdrop + mode selector + some padding) */
col= uiLayoutColumn(layout, 1);
@@ -248,31 +248,36 @@ static void draw_modifier__generator(uiLayout *layout, FModifier *fcm, short wid
/* --------------- */
/* draw settings for noise modifier */
-static void draw_modifier__fn_generator(uiLayout *layout, FModifier *fcm, short width)
+static void draw_modifier__fn_generator(uiLayout *layout, ID *id, FModifier *fcm, short width)
{
- uiLayout *col= uiLayoutColumn(layout, 0); // no grouping for now
+ uiLayout *col;
PointerRNA ptr;
/* init the RNA-pointer */
- RNA_pointer_create(NULL, &RNA_FModifierFunctionGenerator, fcm, &ptr);
+ RNA_pointer_create(id, &RNA_FModifierFunctionGenerator, fcm, &ptr);
/* add the settings */
- uiItemR(col, NULL, 0, &ptr, "amplitude", 0, 0, 0);
- uiItemR(col, NULL, 0, &ptr, "phase_multiplier", 0, 0, 0);
- uiItemR(col, NULL, 0, &ptr, "phase_offset", 0, 0, 0);
- uiItemR(col, NULL, 0, &ptr, "value_offset", 0, 0, 0);
+ col= uiLayoutColumn(layout, 1);
+ uiItemR(col, "", 0, &ptr, "type", 0, 0, 0);
+ uiItemR(col, NULL, 0, &ptr, "additive", 0, 0, 1);
+
+ col= uiLayoutColumn(layout, 0); // no grouping for now
+ uiItemR(col, NULL, 0, &ptr, "amplitude", 0, 0, 0);
+ uiItemR(col, NULL, 0, &ptr, "phase_multiplier", 0, 0, 0);
+ uiItemR(col, NULL, 0, &ptr, "phase_offset", 0, 0, 0);
+ uiItemR(col, NULL, 0, &ptr, "value_offset", 0, 0, 0);
}
/* --------------- */
/* draw settings for cycles modifier */
-static void draw_modifier__cycles(uiLayout *layout, FModifier *fcm, short width)
+static void draw_modifier__cycles(uiLayout *layout, ID *id, FModifier *fcm, short width)
{
uiLayout *split, *col;
PointerRNA ptr;
/* init the RNA-pointer */
- RNA_pointer_create(NULL, &RNA_FModifierCycles, fcm, &ptr);
+ RNA_pointer_create(id, &RNA_FModifierCycles, fcm, &ptr);
/* split into 2 columns
* NOTE: the mode comboboxes shouldn't get labels, otherwise there isn't enough room
@@ -295,13 +300,16 @@ static void draw_modifier__cycles(uiLayout *layout, FModifier *fcm, short width)
/* --------------- */
/* draw settings for noise modifier */
-static void draw_modifier__noise(uiLayout *layout, FModifier *fcm, short width)
+static void draw_modifier__noise(uiLayout *layout, ID *id, FModifier *fcm, short width)
{
uiLayout *split, *col;
PointerRNA ptr;
/* init the RNA-pointer */
- RNA_pointer_create(NULL, &RNA_FModifierNoise, fcm, &ptr);
+ RNA_pointer_create(id, &RNA_FModifierNoise, fcm, &ptr);
+
+ /* blending mode */
+ uiItemR(layout, NULL, 0, &ptr, "modification", 0, 0, 0);
/* split into 2 columns */
split= uiLayoutSplit(layout, 0.5f);
@@ -479,7 +487,7 @@ static void fmod_envelope_deletepoint_cb (bContext *C, void *fcm_dv, void *ind_v
}
/* draw settings for envelope modifier */
-static void draw_modifier__envelope(uiLayout *layout, FModifier *fcm, short width)
+static void draw_modifier__envelope(uiLayout *layout, ID *id, FModifier *fcm, short width)
{
FMod_Envelope *env= (FMod_Envelope *)fcm->data;
FCM_EnvelopeData *fed;
@@ -490,7 +498,7 @@ static void draw_modifier__envelope(uiLayout *layout, FModifier *fcm, short widt
int i;
/* init the RNA-pointer */
- RNA_pointer_create(NULL, &RNA_FModifierEnvelope, fcm, &ptr);
+ RNA_pointer_create(id, &RNA_FModifierEnvelope, fcm, &ptr);
/* general settings */
col= uiLayoutColumn(layout, 1);
@@ -534,13 +542,13 @@ static void draw_modifier__envelope(uiLayout *layout, FModifier *fcm, short widt
/* --------------- */
/* draw settings for limits modifier */
-static void draw_modifier__limits(uiLayout *layout, FModifier *fcm, short width)
+static void draw_modifier__limits(uiLayout *layout, ID *id, FModifier *fcm, short width)
{
uiLayout *split, *col, *row;
PointerRNA ptr;
/* init the RNA-pointer */
- RNA_pointer_create(NULL, &RNA_FModifierLimits, fcm, &ptr);
+ RNA_pointer_create(id, &RNA_FModifierLimits, fcm, &ptr);
/* row 1: minimum */
{
@@ -582,7 +590,7 @@ static void draw_modifier__limits(uiLayout *layout, FModifier *fcm, short width)
/* --------------- */
-void ANIM_uiTemplate_fmodifier_draw (uiLayout *layout, ListBase *modifiers, FModifier *fcm)
+void ANIM_uiTemplate_fmodifier_draw (uiLayout *layout, ID *id, ListBase *modifiers, FModifier *fcm)
{
FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
uiLayout *box, *row, *subrow;
@@ -639,27 +647,27 @@ void ANIM_uiTemplate_fmodifier_draw (uiLayout *layout, ListBase *modifiers, FMod
/* draw settings for individual modifiers */
switch (fcm->type) {
case FMODIFIER_TYPE_GENERATOR: /* Generator */
- draw_modifier__generator(box, fcm, width);
+ draw_modifier__generator(box, id, fcm, width);
break;
case FMODIFIER_TYPE_FN_GENERATOR: /* Built-In Function Generator */
- draw_modifier__fn_generator(box, fcm, width);
+ draw_modifier__fn_generator(box, id, fcm, width);
break;
case FMODIFIER_TYPE_CYCLES: /* Cycles */
- draw_modifier__cycles(box, fcm, width);
+ draw_modifier__cycles(box, id, fcm, width);
break;
case FMODIFIER_TYPE_ENVELOPE: /* Envelope */
- draw_modifier__envelope(box, fcm, width);
+ draw_modifier__envelope(box, id, fcm, width);
break;
case FMODIFIER_TYPE_LIMITS: /* Limits */
- draw_modifier__limits(box, fcm, width);
+ draw_modifier__limits(box, id, fcm, width);
break;
case FMODIFIER_TYPE_NOISE: /* Noise */
- draw_modifier__noise(box, fcm, width);
+ draw_modifier__noise(box, id, fcm, width);
break;
default: /* unknown type */
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index df4e704cae8..87811fa34f9 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -300,7 +300,7 @@ struct uiLayout;
/* draw a given F-Modifier for some layout/UI-Block */
// XXX not quite complete yet
-void ANIM_uiTemplate_fmodifier_draw(struct uiLayout *layout, ListBase *modifiers, struct FModifier *fcm);
+void ANIM_uiTemplate_fmodifier_draw(struct uiLayout *layout, struct ID *id, ListBase *modifiers, struct FModifier *fcm);
/* ************************************************* */
/* ASSORTED TOOLS */
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index 17bc78f9ee6..0e48d56ac90 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -388,7 +388,7 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa)
for (fcm= fcu->modifiers.first; fcm; fcm= fcm->next) {
col= uiLayoutColumn(pa->layout, 1);
- ANIM_uiTemplate_fmodifier_draw(col, &fcu->modifiers, fcm);
+ ANIM_uiTemplate_fmodifier_draw(col, ale->id, &fcu->modifiers, fcm);
}
MEM_freeN(ale);
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 9a50c5cc203..2cade676817 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -73,6 +73,7 @@
#include "BKE_report.h"
#include "BKE_utildefines.h"
+#include "UI_interface.h"
#include "UI_view2d.h"
#include "BIF_transform.h"
@@ -1743,6 +1744,34 @@ void GRAPH_OT_smooth (wmOperatorType *ot)
/* ******************** Add F-Modifier Operator *********************** */
+/* present a special customised popup menu for this, with some filtering */
+static int graph_fmodifier_add_invoke (bContext *C, wmOperator *op, wmEvent *event)
+{
+ uiPopupMenu *pup;
+ uiLayout *layout;
+ int i;
+
+ pup= uiPupMenuBegin(C, "Add F-Curve Modifier", 0);
+ layout= uiPupMenuLayout(pup);
+
+ /* start from 1 to skip the 'Invalid' modifier type */
+ for (i = 1; i < FMODIFIER_NUM_TYPES; i++) {
+ FModifierTypeInfo *fmi= get_fmodifier_typeinfo(i);
+
+ /* check if modifier is valid for this context */
+ if (fmi == NULL)
+ continue;
+
+ /* add entry to add this type of modifier */
+ uiItemEnumO(layout, fmi->name, 0, "GRAPH_OT_fmodifier_add", "type", i);
+ }
+ uiItemS(layout);
+
+ uiPupMenuEnd(C, pup);
+
+ return OPERATOR_CANCELLED;
+}
+
static int graph_fmodifier_add_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
@@ -1793,7 +1822,7 @@ void GRAPH_OT_fmodifier_add (wmOperatorType *ot)
ot->idname= "GRAPH_OT_fmodifier_add";
/* api callbacks */
- ot->invoke= WM_menu_invoke;
+ ot->invoke= graph_fmodifier_add_invoke;
ot->exec= graph_fmodifier_add_exec;
ot->poll= graphop_active_fcurve_poll;
diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c
index 7eb10866b8c..38ac59cbc9e 100644
--- a/source/blender/editors/space_nla/nla_buttons.c
+++ b/source/blender/editors/space_nla/nla_buttons.c
@@ -341,7 +341,7 @@ static void nla_panel_modifiers(const bContext *C, Panel *pa)
for (fcm= strip->modifiers.first; fcm; fcm= fcm->next) {
col= uiLayoutColumn(pa->layout, 1);
- ANIM_uiTemplate_fmodifier_draw(col, &strip->modifiers, fcm);
+ ANIM_uiTemplate_fmodifier_draw(col, strip_ptr.id.data, &strip->modifiers, fcm);
}
}
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index 9910e62b262..10b25beddff 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -386,6 +386,12 @@ static int nlaedit_add_transition_exec (bContext *C, wmOperator *op)
/* check if there's space between the two */
if (IS_EQ(s1->end, s2->start))
continue;
+ /* make neither one is a transition
+ * - although this is impossible to create with the standard tools,
+ * the user may have altered the settings
+ */
+ if (ELEM(NLASTRIP_TYPE_TRANSITION, s1->type, s2->type))
+ continue;
/* allocate new strip */
strip= MEM_callocN(sizeof(NlaStrip), "NlaStrip");
@@ -577,8 +583,18 @@ static int nlaedit_delete_exec (bContext *C, wmOperator *op)
nstrip= strip->next;
/* if selected, delete */
- if (strip->flag & NLASTRIP_FLAG_SELECT)
+ if (strip->flag & NLASTRIP_FLAG_SELECT) {
+ /* if a strip either side of this was a transition, delete those too */
+ if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION))
+ free_nlastrip(&nlt->strips, strip->prev);
+ if ((nstrip) && (nstrip->type == NLASTRIP_TYPE_TRANSITION)) {
+ nstrip= nstrip->next;
+ free_nlastrip(&nlt->strips, strip->next);
+ }
+
+ /* finally, delete this strip */
free_nlastrip(&nlt->strips, strip);
+ }
}
}
@@ -1026,6 +1042,36 @@ void NLA_OT_clear_scale (wmOperatorType *ot)
/* ******************** Add F-Modifier Operator *********************** */
+/* present a special customised popup menu for this, with some filtering */
+static int nla_fmodifier_add_invoke (bContext *C, wmOperator *op, wmEvent *event)
+{
+ uiPopupMenu *pup;
+ uiLayout *layout;
+ int i;
+
+ pup= uiPupMenuBegin(C, "Add F-Modifier", 0);
+ layout= uiPupMenuLayout(pup);
+
+ /* start from 1 to skip the 'Invalid' modifier type */
+ for (i = 1; i < FMODIFIER_NUM_TYPES; i++) {
+ FModifierTypeInfo *fmi= get_fmodifier_typeinfo(i);
+
+ /* check if modifier is valid for this context */
+ if (fmi == NULL)
+ continue;
+ if (i == FMODIFIER_TYPE_CYCLES) /* we already have repeat... */
+ continue;
+
+ /* add entry to add this type of modifier */
+ uiItemEnumO(layout, fmi->name, 0, "NLA_OT_fmodifier_add", "type", i);
+ }
+ uiItemS(layout);
+
+ uiPupMenuEnd(C, pup);
+
+ return OPERATOR_CANCELLED;
+}
+
static int nla_fmodifier_add_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
@@ -1089,7 +1135,7 @@ void NLA_OT_fmodifier_add (wmOperatorType *ot)
ot->idname= "NLA_OT_fmodifier_add";
/* api callbacks */
- ot->invoke= WM_menu_invoke;
+ ot->invoke= nla_fmodifier_add_invoke;
ot->exec= nla_fmodifier_add_exec;
ot->poll= nlaop_poll_tweakmode_off;
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index ad3edde6552..f9508efef31 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -69,7 +69,7 @@ enum {
FMODIFIER_TYPE_FN_GENERATOR,
FMODIFIER_TYPE_ENVELOPE,
FMODIFIER_TYPE_CYCLES,
- FMODIFIER_TYPE_NOISE, /* unimplemented - generate variations using some basic noise generator... */
+ FMODIFIER_TYPE_NOISE,
FMODIFIER_TYPE_FILTER, /* unimplemented - for applying: fft, high/low pass filters, etc. */
FMODIFIER_TYPE_PYTHON,
FMODIFIER_TYPE_LIMITS,
diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c
index 965692212a5..dfa496fd8f3 100644
--- a/source/blender/makesrna/intern/rna_nla.c
+++ b/source/blender/makesrna/intern/rna_nla.c
@@ -228,6 +228,7 @@ void rna_def_nlastrip(BlenderRNA *brna)
/* Enums */
prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "type");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE); // XXX for now, not editable, since this is dangerous
RNA_def_property_enum_items(prop, prop_type_items);
RNA_def_property_ui_text(prop, "Type", "Type of NLA Strip.");
@@ -296,7 +297,10 @@ void rna_def_nlastrip(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0001f, 1000.0f); /* these limits can be extended, but beyond this, we can get some crazy+annoying bugs due to numeric errors */
RNA_def_property_ui_text(prop, "Scale", "Scaling factor for action.");
- // TODO: strip's F-Curves?
+ /* Strip's F-Curves */
+ prop= RNA_def_property(srna, "fcurves", PROP_COLLECTION, PROP_NONE);
+ 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.");
/* Strip's F-Modifiers */
prop= RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);