[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31988] branches/soc-2008-mxcurioni/source /blender: Added support for animation of line style parameters.
Tamito Kajiyama
rd6t-kjym at asahi-net.or.jp
Sat Sep 18 02:31:22 CEST 2010
Revision: 31988
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31988
Author: kjym3
Date: 2010-09-18 02:31:22 +0200 (Sat, 18 Sep 2010)
Log Message:
-----------
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.
Modified Paths:
--------------
branches/soc-2008-mxcurioni/source/blender/blenkernel/BKE_linestyle.h
branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/anim_sys.c
branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/linestyle.c
branches/soc-2008-mxcurioni/source/blender/blenloader/intern/readfile.c
branches/soc-2008-mxcurioni/source/blender/blenloader/intern/writefile.c
branches/soc-2008-mxcurioni/source/blender/editors/animation/keyframes_draw.c
branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_linestyle_types.h
branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_color.c
branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_linestyle.c
Modified: branches/soc-2008-mxcurioni/source/blender/blenkernel/BKE_linestyle.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/blenkernel/BKE_linestyle.h 2010-09-18 00:19:53 UTC (rev 31987)
+++ branches/soc-2008-mxcurioni/source/blender/blenkernel/BKE_linestyle.h 2010-09-18 00:31:22 UTC (rev 31988)
@@ -55,4 +55,7 @@
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
Modified: branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/anim_sys.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/anim_sys.c 2010-09-18 00:19:53 UTC (rev 31987)
+++ branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/anim_sys.c 2010-09-18 00:31:22 UTC (rev 31988)
@@ -75,6 +75,7 @@
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;
Modified: branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/linestyle.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/linestyle.c 2010-09-18 00:19:53 UTC (rev 31987)
+++ branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/linestyle.c 2010-09-18 00:31:22 UTC (rev 31988)
@@ -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 @@
{
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 @@
{
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);
+}
Modified: branches/soc-2008-mxcurioni/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/blenloader/intern/readfile.c 2010-09-18 00:19:53 UTC (rev 31987)
+++ branches/soc-2008-mxcurioni/source/blender/blenloader/intern/readfile.c 2010-09-18 00:31:22 UTC (rev 31988)
@@ -5362,22 +5362,28 @@
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 @@
{
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 @@
{
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);
Modified: branches/soc-2008-mxcurioni/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/blenloader/intern/writefile.c 2010-09-18 00:19:53 UTC (rev 31987)
+++ branches/soc-2008-mxcurioni/source/blender/blenloader/intern/writefile.c 2010-09-18 00:31:22 UTC (rev 31988)
@@ -2462,6 +2462,8 @@
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);
Modified: branches/soc-2008-mxcurioni/source/blender/editors/animation/keyframes_draw.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/editors/animation/keyframes_draw.c 2010-09-18 00:19:53 UTC (rev 31987)
+++ branches/soc-2008-mxcurioni/source/blender/editors/animation/keyframes_draw.c 2010-09-18 00:31:22 UTC (rev 31988)
@@ -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 @@
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);
+ }
+ }
+ }
+ }
}
}
Modified: branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_linestyle_types.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_linestyle_types.h 2010-09-18 00:19:53 UTC (rev 31987)
+++ branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_linestyle_types.h 2010-09-18 00:31:22 UTC (rev 31988)
@@ -180,6 +180,7 @@
typedef struct FreestyleLineStyle {
ID id;
+ struct AnimData *adt;
float r, g, b, alpha;
float thickness;
Modified: branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_color.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_color.c 2010-09-18 00:19:53 UTC (rev 31987)
+++ branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_color.c 2010-09-18 00:31:22 UTC (rev 31988)
@@ -44,6 +44,7 @@
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list