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:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2010-09-18 04:31:22 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2010-09-18 04:31:22 +0400
commit56303415e4d534d4f2f4075a818a2aa19ea19fbd (patch)
tree768355c547c5a9971dfa1120d4e41ba64454a9b4
parentfdb4b0c3ed9279473eb0edf4bac0333e7e929727 (diff)
Added support for animation of line style parameters.
Most stylization parameters in line style datablocks are now animatable by means of keyframes. Right click on a line style parameter, and you will see a list of keyframe-related commands in the context menu. Concerning the implementation, RNA path resolution has been extended to properly address color ramps in line style color modifiers. File I/O has been also improved to load/save the animation data associated with line style datablocks. Known issue: Freestyle-related options in render layers are not animatable at the moment, because of general inability (or maybe a bug) that keyframes cannot be inserted with respect to render layer options.
-rw-r--r--source/blender/blenkernel/BKE_linestyle.h3
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c1
-rw-r--r--source/blender/blenkernel/intern/linestyle.c57
-rw-r--r--source/blender/blenloader/intern/readfile.c38
-rw-r--r--source/blender/blenloader/intern/writefile.c2
-rw-r--r--source/blender/editors/animation/keyframes_draw.c18
-rw-r--r--source/blender/makesdna/DNA_linestyle_types.h1
-rw-r--r--source/blender/makesrna/intern/rna_color.c23
-rw-r--r--source/blender/makesrna/intern/rna_linestyle.c19
9 files changed, 148 insertions, 14 deletions
diff --git a/source/blender/blenkernel/BKE_linestyle.h b/source/blender/blenkernel/BKE_linestyle.h
index 0514cb73e5b..2e68ab38ecd 100644
--- a/source/blender/blenkernel/BKE_linestyle.h
+++ b/source/blender/blenkernel/BKE_linestyle.h
@@ -55,4 +55,7 @@ void FRS_move_linestyle_color_modifier(FreestyleLineStyle *linestyle, LineStyleM
void FRS_move_linestyle_alpha_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction);
void FRS_move_linestyle_thickness_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction);
+void FRS_list_modifier_color_ramps(FreestyleLineStyle *linestyle, ListBase *listbase);
+char *FRS_path_from_ID_to_color_ramp(FreestyleLineStyle *linestyle, ColorBand *color_ramp);
+
#endif
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 28eed5a27e8..e58526cae0f 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -75,6 +75,7 @@ short id_type_can_have_animdata (ID *id)
case ID_PA:
case ID_MA: case ID_TE: case ID_NT:
case ID_LA: case ID_CA: case ID_WO:
+ case ID_LS:
case ID_SCE:
{
return 1;
diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c
index acd8f0e4368..ef4ce16328f 100644
--- a/source/blender/blenkernel/intern/linestyle.c
+++ b/source/blender/blenkernel/intern/linestyle.c
@@ -34,6 +34,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_material_types.h" /* for ramp blend */
+#include "DNA_texture_types.h"
#include "BKE_global.h"
#include "BKE_library.h"
@@ -41,6 +42,7 @@
#include "BKE_main.h"
#include "BKE_texture.h"
#include "BKE_colortools.h"
+#include "BKE_animsys.h"
#include "BLI_blenlib.h"
@@ -80,6 +82,7 @@ void FRS_free_linestyle(FreestyleLineStyle *linestyle)
{
LineStyleModifier *m;
+ BKE_free_animdata(&linestyle->id);
while ((m = (LineStyleModifier *)linestyle->color_modifiers.first))
FRS_remove_linestyle_color_modifier(linestyle, m);
while ((m = (LineStyleModifier *)linestyle->alpha_modifiers.first))
@@ -308,3 +311,57 @@ void FRS_move_linestyle_thickness_modifier(FreestyleLineStyle *linestyle, LineSt
{
move_modifier(&linestyle->thickness_modifiers, modifier, direction);
}
+
+void FRS_list_modifier_color_ramps(FreestyleLineStyle *linestyle, ListBase *listbase)
+{
+ LineStyleModifier *m;
+ ColorBand *color_ramp;
+ LinkData *link;
+
+ listbase->first = listbase->last = NULL;
+ for (m = (LineStyleModifier *)linestyle->color_modifiers.first; m; m = m->next) {
+ switch (m->type) {
+ case LS_MODIFIER_ALONG_STROKE:
+ color_ramp = ((LineStyleColorModifier_AlongStroke *)m)->color_ramp;
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA:
+ color_ramp = ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp;
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT:
+ color_ramp = ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp;
+ break;
+ default:
+ continue;
+ }
+ link = (LinkData *) MEM_callocN( sizeof(LinkData), "link to color ramp");
+ link->data = color_ramp;
+ BLI_addtail(listbase, link);
+ }
+}
+
+char *FRS_path_from_ID_to_color_ramp(FreestyleLineStyle *linestyle, ColorBand *color_ramp)
+{
+ LineStyleModifier *m;
+
+ for (m = (LineStyleModifier *)linestyle->color_modifiers.first; m; m = m->next) {
+ switch (m->type) {
+ case LS_MODIFIER_ALONG_STROKE:
+ if (color_ramp == ((LineStyleColorModifier_AlongStroke *)m)->color_ramp)
+ goto found;
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA:
+ if (color_ramp == ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp)
+ goto found;
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT:
+ if (color_ramp == ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp)
+ goto found;
+ break;
+ }
+ }
+ printf("FRS_path_from_ID_to_color_ramp: No color ramps correspond to the given pointer.\n");
+ return NULL;
+
+found:
+ return BLI_sprintfN("color_modifiers[\"%s\"].color_ramp", m->name);
+}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index f916253f239..a03634e0625 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5362,22 +5362,28 @@ static void lib_link_linestyle(FileData *fd, Main *main)
linestyle = main->linestyle.first;
while (linestyle) {
- for (m = linestyle->color_modifiers.first; m; m = m->next) {
- if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
- LineStyleColorModifier_DistanceFromObject *cm = (LineStyleColorModifier_DistanceFromObject *)m;
- cm->target = newlibadr(fd, linestyle->id.lib, cm->target);
+ if (linestyle->id.flag & LIB_NEEDLINK) {
+ linestyle->id.flag -= LIB_NEEDLINK;
+
+ if (linestyle->id.properties) IDP_LibLinkProperty(linestyle->id.properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ if (linestyle->adt) lib_link_animdata(fd, &linestyle->id, linestyle->adt);
+ for (m = linestyle->color_modifiers.first; m; m = m->next) {
+ if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
+ LineStyleColorModifier_DistanceFromObject *cm = (LineStyleColorModifier_DistanceFromObject *)m;
+ cm->target = newlibadr(fd, linestyle->id.lib, cm->target);
+ }
}
- }
- for (m = linestyle->alpha_modifiers.first; m; m = m->next){
- if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
- LineStyleAlphaModifier_DistanceFromObject *am = (LineStyleAlphaModifier_DistanceFromObject *)m;
- am->target = newlibadr(fd, linestyle->id.lib, am->target);
+ for (m = linestyle->alpha_modifiers.first; m; m = m->next){
+ if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
+ LineStyleAlphaModifier_DistanceFromObject *am = (LineStyleAlphaModifier_DistanceFromObject *)m;
+ am->target = newlibadr(fd, linestyle->id.lib, am->target);
+ }
}
- }
- for (m = linestyle->thickness_modifiers.first; m; m = m->next){
- if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
- LineStyleThicknessModifier_DistanceFromObject *tm = (LineStyleThicknessModifier_DistanceFromObject *)m;
- tm->target = newlibadr(fd, linestyle->id.lib, tm->target);
+ for (m = linestyle->thickness_modifiers.first; m; m = m->next){
+ if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
+ LineStyleThicknessModifier_DistanceFromObject *tm = (LineStyleThicknessModifier_DistanceFromObject *)m;
+ tm->target = newlibadr(fd, linestyle->id.lib, tm->target);
+ }
}
}
linestyle = linestyle->id.next;
@@ -5466,6 +5472,8 @@ static void direct_link_linestyle(FileData *fd, FreestyleLineStyle *linestyle)
{
LineStyleModifier *modifier;
+ linestyle->adt= newdataadr(fd, linestyle->adt);
+ direct_link_animdata(fd, linestyle->adt);
link_list(fd, &linestyle->color_modifiers);
for(modifier=linestyle->color_modifiers.first; modifier; modifier= modifier->next)
direct_link_linestyle_color_modifier(fd, modifier);
@@ -12207,6 +12215,8 @@ static void expand_linestyle(FileData *fd, Main *mainvar, FreestyleLineStyle *li
{
LineStyleModifier *m;
+ if (linestyle->adt)
+ expand_animdata(fd, mainvar, linestyle->adt);
for (m = linestyle->color_modifiers.first; m; m = m->next) {
if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT)
expand_doit(fd, mainvar, ((LineStyleColorModifier_DistanceFromObject *)m)->target);
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index ba47b23ce06..9d94b639f73 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2462,6 +2462,8 @@ static void write_linestyles(WriteData *wd, ListBase *idbase)
for(linestyle=idbase->first; linestyle; linestyle= linestyle->id.next) {
if(linestyle->id.us>0 || wd->current) {
writestruct(wd, ID_LS, "FreestyleLineStyle", 1, linestyle);
+ if (linestyle->id.properties) IDP_WriteProperty(linestyle->id.properties, wd);
+ if (linestyle->adt) write_animdata(wd, linestyle->adt);
write_linestyle_color_modifiers(wd, &linestyle->color_modifiers);
write_linestyle_alpha_modifiers(wd, &linestyle->alpha_modifiers);
write_linestyle_thickness_modifiers(wd, &linestyle->thickness_modifiers);
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index 02e141a7a69..55bada5ba4e 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -47,6 +47,7 @@
#include "DNA_scene_types.h"
#include "DNA_key_types.h"
#include "DNA_lamp_types.h"
+#include "DNA_linestyle_types.h"
#include "DNA_mesh_types.h"
#include "DNA_material_types.h"
#include "DNA_meta_types.h"
@@ -720,6 +721,23 @@ void scene_to_keylist(bDopeSheet *ads, Scene *sce, DLRBT_Tree *keys, DLRBT_Tree
if (adt->action)
action_to_keylist(adt, adt->action, keys, blocks);
}
+
+ /* linestyle animdata */
+ if (sce->r.mode & R_EDGE_FRS) {
+ SceneRenderLayer *srl;
+ FreestyleLineSet *lineset;
+
+ for (srl= sce->r.layers.first; srl; srl= srl->next) {
+ if (srl->layflag & SCE_LAY_FRS) {
+ for (lineset= srl->freestyleConfig.linesets.first; lineset; lineset= lineset->next) {
+ adt= lineset->linestyle->adt;
+
+ if (adt && adt->action)
+ action_to_keylist(adt, adt->action, keys, blocks);
+ }
+ }
+ }
+ }
}
}
diff --git a/source/blender/makesdna/DNA_linestyle_types.h b/source/blender/makesdna/DNA_linestyle_types.h
index 6f55b3459b4..a19bbdf1bf9 100644
--- a/source/blender/makesdna/DNA_linestyle_types.h
+++ b/source/blender/makesdna/DNA_linestyle_types.h
@@ -180,6 +180,7 @@ typedef struct LineStyleThicknessModifier_DistanceFromObject {
typedef struct FreestyleLineStyle {
ID id;
+ struct AnimData *adt;
float r, g, b, alpha;
float thickness;
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index 509fecb0122..40ebc59b562 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -44,6 +44,7 @@
#include "BKE_depsgraph.h"
#include "BKE_node.h"
#include "BKE_texture.h"
+#include "BKE_linestyle.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -147,6 +148,14 @@ static char *rna_ColorRamp_path(PointerRNA *ptr)
return BLI_strdup("specular_ramp");
}
break;
+
+ case ID_LS:
+ {
+ char *path = FRS_path_from_ID_to_color_ramp((FreestyleLineStyle *)id, (ColorBand *)ptr->data);
+ if (path)
+ return path;
+ }
+ break;
}
}
@@ -215,6 +224,20 @@ MEM_freeN(texture_path); \
}
break;
+ case ID_LS:
+ {
+ ListBase listbase;
+ LinkData *link;
+
+ FRS_list_modifier_color_ramps((FreestyleLineStyle *)id, &listbase);
+ for (link = (LinkData *)listbase.first; link; link = link->next) {
+ RNA_pointer_create(id, &RNA_ColorRamp, link->data, &ramp_ptr);
+ COLRAMP_GETPATH;
+ }
+ BLI_freelistN(&listbase);
+ }
+ break;
+
default: /* everything else should have a "color_ramp" property */
{
/* create pointer to the ID block, and try to resolve "color_ramp" pointer */
diff --git a/source/blender/makesrna/intern/rna_linestyle.c b/source/blender/makesrna/intern/rna_linestyle.c
index de7fe1a8258..1aa7b71af2c 100644
--- a/source/blender/makesrna/intern/rna_linestyle.c
+++ b/source/blender/makesrna/intern/rna_linestyle.c
@@ -31,6 +31,7 @@
#include "DNA_linestyle_types.h"
#include "DNA_material_types.h"
+#include "DNA_texture_types.h"
#include "WM_types.h"
#include "WM_api.h"
@@ -103,6 +104,21 @@ static StructRNA *rna_LineStyle_thickness_modifier_refine(struct PointerRNA *ptr
}
}
+static char *rna_LineStyle_color_modifier_path(PointerRNA *ptr)
+{
+ return BLI_sprintfN("color_modifiers[\"%s\"]", ((LineStyleModifier*)ptr->data)->name);
+}
+
+static char *rna_LineStyle_alpha_modifier_path(PointerRNA *ptr)
+{
+ return BLI_sprintfN("alpha_modifiers[\"%s\"]", ((LineStyleModifier*)ptr->data)->name);
+}
+
+static char *rna_LineStyle_thickness_modifier_path(PointerRNA *ptr)
+{
+ return BLI_sprintfN("thickness_modifiers[\"%s\"]", ((LineStyleModifier*)ptr->data)->name);
+}
+
#else
#include "DNA_material_types.h"
@@ -284,6 +300,7 @@ static void rna_def_linestyle_modifiers(BlenderRNA *brna)
srna= RNA_def_struct(brna, "LineStyleColorModifier", "LineStyleModifier");
RNA_def_struct_sdna(srna, "LineStyleModifier");
RNA_def_struct_refine_func(srna, "rna_LineStyle_color_modifier_refine");
+ RNA_def_struct_path_func(srna, "rna_LineStyle_color_modifier_path");
RNA_def_struct_ui_text(srna, "Line Style Color Modifier", "Base type to define line color modifiers.");
srna= RNA_def_struct(brna, "LineStyleColorModifier_AlongStroke", "LineStyleColorModifier");
@@ -313,6 +330,7 @@ static void rna_def_linestyle_modifiers(BlenderRNA *brna)
srna= RNA_def_struct(brna, "LineStyleAlphaModifier", "LineStyleModifier");
RNA_def_struct_sdna(srna, "LineStyleModifier");
RNA_def_struct_refine_func(srna, "rna_LineStyle_alpha_modifier_refine");
+ RNA_def_struct_path_func(srna, "rna_LineStyle_alpha_modifier_path");
RNA_def_struct_ui_text(srna, "Line Style Alpha Modifier", "Base type to define alpha transparency modifiers.");
srna= RNA_def_struct(brna, "LineStyleAlphaModifier_AlongStroke", "LineStyleAlphaModifier");
@@ -342,6 +360,7 @@ static void rna_def_linestyle_modifiers(BlenderRNA *brna)
srna= RNA_def_struct(brna, "LineStyleThicknessModifier", "LineStyleModifier");
RNA_def_struct_sdna(srna, "LineStyleModifier");
RNA_def_struct_refine_func(srna, "rna_LineStyle_thickness_modifier_refine");
+ RNA_def_struct_path_func(srna, "rna_LineStyle_thickness_modifier_path");
RNA_def_struct_ui_text(srna, "Line Style Thickness Modifier", "Base type to define line thickness modifiers.");
srna= RNA_def_struct(brna, "LineStyleThicknessModifier_AlongStroke", "LineStyleThicknessModifier");