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.
This commit is contained in:
parent
fdb4b0c3ed
commit
56303415e4
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -5362,6 +5362,11 @@ static void lib_link_linestyle(FileData *fd, Main *main)
|
|||
|
||||
linestyle = main->linestyle.first;
|
||||
while (linestyle) {
|
||||
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;
|
||||
|
@ -5380,6 +5385,7 @@ static void lib_link_linestyle(FileData *fd, Main *main)
|
|||
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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -180,6 +180,7 @@ typedef struct LineStyleThicknessModifier_DistanceFromObject {
|
|||
|
||||
typedef struct FreestyleLineStyle {
|
||||
ID id;
|
||||
struct AnimData *adt;
|
||||
|
||||
float r, g, b, alpha;
|
||||
float thickness;
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue