diff options
Diffstat (limited to 'source/blender/editors')
23 files changed, 948 insertions, 22 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 386313b1d3c..a735f159e1b 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -47,6 +47,7 @@ #include "DNA_key_types.h" #include "DNA_lamp_types.h" #include "DNA_lattice_types.h" +#include "DNA_linestyle_types.h" #include "DNA_mesh_types.h" #include "DNA_material_types.h" #include "DNA_meta_types.h" @@ -2017,6 +2018,83 @@ static bAnimChannelType ACF_DSNTREE = acf_dsntree_setting_ptr /* pointer for setting */ }; +/* LineStyle Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dslinestyle_icon(bAnimListElem *ale) +{ + return ICON_BRUSH_DATA; /* FIXME */ +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dslinestyle_setting_flag(bAnimContext *ac, int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return LS_DS_EXPAND; + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + return ADT_NLA_EVAL_OFF; + + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ + *neg= 1; + return ADT_CURVES_NOT_VISIBLE; + + case ACHANNEL_SETTING_SELECT: /* selected */ + return ADT_UI_SELECTED; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dslinestyle_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + FreestyleLineStyle *linestyle= (FreestyleLineStyle *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return GET_ACF_FLAG_PTR(linestyle->flag, type); + + case ACHANNEL_SETTING_SELECT: /* selected */ + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (linestyle->adt) + return GET_ACF_FLAG_PTR(linestyle->adt->flag, type); + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* node tree expander type define */ +static bAnimChannelType ACF_DSLINESTYLE= +{ + "Line Style Expander", /* type name */ + + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dslinestyle_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dslinestyle_setting_flag, /* flag for setting */ + acf_dslinestyle_setting_ptr /* pointer for setting */ +}; + /* Mesh Expander ------------------------------------------- */ // TODO: just get this from RNA? @@ -2563,6 +2641,7 @@ static void ANIM_init_channel_typeinfo_data(void) animchannelTypeInfo[type++] = &ACF_DSTEX; /* Texture Channel */ animchannelTypeInfo[type++] = &ACF_DSLAT; /* Lattice Channel */ animchannelTypeInfo[type++] = &ACF_DSSPK; /* Speaker Channel */ + animchannelTypeInfo[type++] = &ACF_DSLINESTYLE; /* LineStyle Channel */ animchannelTypeInfo[type++] = &ACF_SHAPEKEY; /* ShapeKey */ diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index dc0886a473e..bbf89dfa74d 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -122,6 +122,7 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, short datatype, int f case ANIMTYPE_DSMESH: case ANIMTYPE_DSTEX: case ANIMTYPE_DSLAT: + case ANIMTYPE_DSLINESTYLE: case ANIMTYPE_DSSPK: { /* need to verify that this data is valid for now */ @@ -167,6 +168,7 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, short datatype, int f case ANIMTYPE_DSARM: case ANIMTYPE_DSMESH: case ANIMTYPE_DSLAT: + case ANIMTYPE_DSLINESTYLE: case ANIMTYPE_DSSPK: { /* need to verify that this data is valid for now */ @@ -247,6 +249,7 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, short datatype, s case ANIMTYPE_DSNTREE: case ANIMTYPE_DSTEX: case ANIMTYPE_DSLAT: + case ANIMTYPE_DSLINESTYLE: case ANIMTYPE_DSSPK: { if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) @@ -337,6 +340,7 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, short datatype, s case ANIMTYPE_DSNTREE: case ANIMTYPE_DSTEX: case ANIMTYPE_DSLAT: + case ANIMTYPE_DSLINESTYLE: case ANIMTYPE_DSSPK: { /* need to verify that this data is valid for now */ @@ -2159,6 +2163,7 @@ static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_in case ANIMTYPE_DSNTREE: case ANIMTYPE_DSTEX: case ANIMTYPE_DSLAT: + case ANIMTYPE_DSLINESTYLE: case ANIMTYPE_DSSPK: { /* sanity checking... */ diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 160e6957513..cebc0e8810e 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -55,6 +55,7 @@ #include "DNA_camera_types.h" #include "DNA_lamp_types.h" #include "DNA_lattice_types.h" +#include "DNA_linestyle_types.h" #include "DNA_key_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" @@ -719,6 +720,19 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne ale->adt = BKE_animdata_from_id(data); } break; + case ANIMTYPE_DSLINESTYLE: + { + FreestyleLineStyle *linestyle= (FreestyleLineStyle *)data; + AnimData *adt= linestyle->adt; + + ale->flag= FILTER_LS_SCED(linestyle); + + ale->key_data= (adt) ? adt->action : NULL; + ale->datatype= ALE_ACT; + + ale->adt= BKE_animdata_from_id(data); + } + break; case ANIMTYPE_DSPART: { ParticleSettings *part = (ParticleSettings *)ale->data; @@ -1389,6 +1403,54 @@ static size_t animdata_filter_ds_nodetree(bAnimContext *ac, ListBase *anim_data, return items; } +static size_t animdata_filter_ds_linestyle (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode) +{ + SceneRenderLayer *srl; + size_t items = 0; + + for (srl= sce->r.layers.first; srl; srl= srl->next) { + FreestyleLineSet *lineset; + + /* skip render layers without Freestyle enabled */ + if (!(srl->layflag & SCE_LAY_FRS)) + continue; + + /* loop over linesets defined in the render layer */ + for (lineset= srl->freestyleConfig.linesets.first; lineset; lineset= lineset->next) { + FreestyleLineStyle *linestyle = lineset->linestyle; + ListBase tmp_data = {NULL, NULL}; + size_t tmp_items = 0; + + /* add scene-level animation channels */ + BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_LS_SCED(linestyle)) + { + /* animation data filtering */ + tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)linestyle, filter_mode); + } + END_ANIMFILTER_SUBCHANNELS; + + /* did we find anything? */ + if (tmp_items) { + /* include anim-expand widget first */ + if (filter_mode & ANIMFILTER_LIST_CHANNELS) { + /* check if filtering by active status */ + if ANIMCHANNEL_ACTIVEOK(linestyle) { + ANIMCHANNEL_NEW_CHANNEL(linestyle, ANIMTYPE_DSLINESTYLE, sce); + } + } + + /* now add the list of collected channels */ + BLI_movelisttolist(anim_data, &tmp_data); + BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); + items += tmp_items; + } + } + } + + /* return the number of items added to the list */ + return items; +} + /* NOTE: owner_id is either material, lamp, or world block, which is the direct owner of the texture stack in question */ static size_t animdata_filter_ds_textures(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, int filter_mode) { @@ -2016,6 +2078,11 @@ static size_t animdata_filter_dopesheet_scene(bAnimContext *ac, ListBase *anim_d if ((ntree) && !(ads->filterflag & ADS_FILTER_NONTREE)) { tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, (ID *)sce, ntree, filter_mode); } + + /* line styles */ + if ((ads->filterflag & ADS_FILTER_NOLINESTYLE) == 0) { + tmp_items += animdata_filter_ds_linestyle(ac, &tmp_data, ads, sce, filter_mode); + } // TODO: one day, when sequencer becomes its own datatype, perhaps it should be included here } diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 4f24d254cbf..6ababe2becb 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -154,6 +154,7 @@ typedef enum eAnim_ChannelType { ANIMTYPE_DSMESH, ANIMTYPE_DSTEX, ANIMTYPE_DSLAT, + ANIMTYPE_DSLINESTYLE, ANIMTYPE_DSSPK, ANIMTYPE_SHAPEKEY, @@ -231,6 +232,7 @@ typedef enum eAnimFilter_Flags { #define EXPANDED_SCEC(sce) ((sce->flag & SCE_DS_COLLAPSED) == 0) /* 'Sub-Scene' channels (flags stored in Data block) */ #define FILTER_WOR_SCED(wo) ((wo->flag & WO_DS_EXPAND)) +#define FILTER_LS_SCED(linestyle) ((linestyle->flag & LS_DS_EXPAND)) /* 'Object' channels */ #define SEL_OBJC(base) ((base->flag & SELECT)) #define EXPANDED_OBJC(ob) ((ob->nlaflag & OB_ADS_COLLAPSED) == 0) diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 257f5c2119c..ca19a8092d0 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -197,6 +197,9 @@ enum { TH_STITCH_PREVIEW_UNSTITCHABLE, TH_STITCH_PREVIEW_ACTIVE, + TH_FREESTYLE_EDGE_MARK, + TH_FREESTYLE_FACE_MARK, + TH_MATCH, /* highlight color for search matches */ TH_SELECT_HIGHLIGHT, /* highlight color for selected outliner item */ diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 59ef0c00283..dee9368bbc6 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -333,6 +333,7 @@ static const char *template_id_browse_tip(StructRNA *type) case ID_BR: return N_("Browse Brush to be linked"); case ID_PA: return N_("Browse Particle System to be linked"); case ID_GD: return N_("Browse Grease Pencil Data to be linked"); + case ID_LS: return N_("Browse Line Style Data to be linked"); } } return N_("Browse ID data to be linked"); @@ -2137,7 +2138,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe uiBlockSetEmboss(block, UI_EMBOSS); uiDefButR(block, OPTION, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, ptr, "use_textures", i, 0, 0, 0, 0, NULL); } - else if (RNA_struct_is_a(itemptr->type, &RNA_SceneRenderLayer)) { + else if (RNA_struct_is_a(itemptr->type, &RNA_SceneRenderLayer) || RNA_struct_is_a(itemptr->type, &RNA_FreestyleLineSet)) { uiItemL(sub, name, icon); uiBlockSetEmboss(block, UI_EMBOSS); uiDefButR(block, OPTION, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "use", 0, 0, 0, 0, 0, NULL); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 5aec4b3c211..027655e393f 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -341,6 +341,10 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo cp = ts->handle_sel_vect; break; case TH_HANDLE_SEL_ALIGN: cp = ts->handle_sel_align; break; + case TH_FREESTYLE_EDGE_MARK: + cp = ts->freestyle_edge_mark; break; + case TH_FREESTYLE_FACE_MARK: + cp = ts->freestyle_face_mark; break; case TH_SYNTAX_B: cp = ts->syntaxb; break; @@ -675,6 +679,8 @@ void ui_theme_init_default(void) rgba_char_args_set(btheme->tv3d.button_text_hi, 255, 255, 255, 255); rgba_char_args_set(btheme->tv3d.button_title, 0, 0, 0, 255); rgba_char_args_set(btheme->tv3d.title, 0, 0, 0, 255); + rgba_char_args_set(btheme->tv3d.freestyle_edge_mark, 0x7f, 0xff, 0x7f, 255); + rgba_char_args_set(btheme->tv3d.freestyle_face_mark, 0x7f, 0xff, 0x7f, 51); btheme->tv3d.facedot_size = 4; @@ -1817,6 +1823,19 @@ void init_userdef_do_versions(void) rgba_char_args_set(btheme->tv3d.skin_root, 180, 77, 77, 255); } + /* Freestyle color settings */ + { + bTheme *btheme; + + for(btheme= U.themes.first; btheme; btheme= btheme->next) { + /* check for alpha==0 is safe, then color was never set */ + if(btheme->tv3d.freestyle_edge_mark[3]==0) { + rgba_char_args_set(btheme->tv3d.freestyle_edge_mark, 0x7f, 0xff, 0x7f, 255); + rgba_char_args_set(btheme->tv3d.freestyle_face_mark, 0x7f, 0xff, 0x7f, 51); + } + } + } + /* GL Texture Garbage Collection (variable abused above!) */ if (U.textimeout == 0) { U.texcollectrate = 60; diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 0a8fe142aaf..5988c9d8d5e 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -685,6 +685,7 @@ static EnumPropertyItem prop_similar_types[] = { {SIMEDGE_BEVEL, "BEVEL", 0, "Bevel", ""}, {SIMEDGE_SEAM, "SEAM", 0, "Seam", ""}, {SIMEDGE_SHARP, "SHARP", 0, "Sharpness", ""}, + {SIMEDGE_FREESTYLE, "FREESTYLE_EDGE", 0, "Freestyle Edge Marks", ""}, {SIMFACE_MATERIAL, "MATERIAL", 0, "Material", ""}, {SIMFACE_IMAGE, "IMAGE", 0, "Image", ""}, @@ -692,6 +693,7 @@ static EnumPropertyItem prop_similar_types[] = { {SIMFACE_PERIMETER, "PERIMETER", 0, "Perimeter", ""}, {SIMFACE_NORMAL, "NORMAL", 0, "Normal", ""}, {SIMFACE_COPLANAR, "COPLANAR", 0, "Co-planar", ""}, + {SIMFACE_FREESTYLE, "FREESTYLE_FACE", 0, "Freestyle Face Marks", ""}, {0, NULL, 0, NULL, NULL} }; @@ -857,7 +859,7 @@ static EnumPropertyItem *select_similar_type_itemf(bContext *C, PointerRNA *UNUS } } else if (em->selectmode & SCE_SELECT_FACE) { - for (a = SIMFACE_MATERIAL; a <= SIMFACE_COPLANAR; a++) { + for (a = SIMFACE_MATERIAL; a <= SIMFACE_FREESTYLE; a++) { RNA_enum_items_add_value(&item, &totitem, prop_similar_types, a); } } @@ -1173,6 +1175,9 @@ static void edgetag_context_set(BMEditMesh *em, Scene *scene, BMEdge *e, int val case EDGE_MODE_TAG_SHARP: BM_elem_flag_set(e, BM_ELEM_SMOOTH, !val); break; + case EDGE_MODE_TAG_FREESTYLE: + BM_elem_flag_set(e, BM_ELEM_FREESTYLE, val); + break; case EDGE_MODE_TAG_CREASE: { float *crease = CustomData_bmesh_get(&em->bm->edata, e->head.data, CD_CREASE); @@ -1197,6 +1202,8 @@ static int edgetag_context_check(Scene *scene, BMEditMesh *em, BMEdge *e) return BM_elem_flag_test(e, BM_ELEM_SEAM); case EDGE_MODE_TAG_SHARP: return !BM_elem_flag_test(e, BM_ELEM_SMOOTH); + case EDGE_MODE_TAG_FREESTYLE: + return !BM_elem_flag_test(e, BM_ELEM_FREESTYLE); case EDGE_MODE_TAG_CREASE: return BM_elem_float_data_get(&em->bm->edata, e, CD_CREASE) ? 1 : 0; case EDGE_MODE_TAG_BEVEL: @@ -1398,6 +1405,9 @@ static int mouse_mesh_shortest_path(bContext *C, int mval[2]) case EDGE_MODE_TAG_BEVEL: me->drawflag |= ME_DRAWBWEIGHTS; break; + case EDGE_MODE_TAG_FREESTYLE: + me->drawflag |= ME_DRAW_FREESTYLE_EDGE; + break; } EDBM_update_generic(C, em, FALSE); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index cad6c23eb74..b7c921cd8af 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -5097,3 +5097,107 @@ void MESH_OT_convex_hull(wmOperatorType *ot) join_triangle_props(ot); } + +static int edbm_mark_freestyle_edge(bContext *C, wmOperator *op) +{ + Object *obedit = CTX_data_edit_object(C); + Mesh *me = ((Mesh *)obedit->data); + BMEditMesh *em = ((Mesh *)obedit->data)->edit_btmesh; + BMEdge *eed; + BMIter iter; + int clear = RNA_boolean_get(op->ptr, "clear"); + + if (em == NULL) return OPERATOR_FINISHED; + + /* auto-enable seams drawing */ + if (clear == 0) { + me->drawflag |= ME_DRAW_FREESTYLE_EDGE; + } + + if (clear) { + BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { + if (BM_elem_flag_test(eed, BM_ELEM_SELECT) && !BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) + BM_elem_flag_disable(eed, BM_ELEM_FREESTYLE); + } + } + else { + BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { + if (BM_elem_flag_test(eed, BM_ELEM_SELECT) && !BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) + BM_elem_flag_enable(eed, BM_ELEM_FREESTYLE); + } + } + + DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + + return OPERATOR_FINISHED; +} + +void MESH_OT_mark_freestyle_edge(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Mark Freestyle Edge"; + ot->description = "(un)mark selected edges as Freestyle feature edges"; + ot->idname = "MESH_OT_mark_freestyle_edge"; + + /* api callbacks */ + ot->exec = edbm_mark_freestyle_edge; + ot->poll = ED_operator_editmesh; + + /* flags */ + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_boolean(ot->srna, "clear", 0, "Clear", ""); +} + +static int edbm_mark_freestyle_face_exec(bContext *C, wmOperator *op) +{ + Object *obedit = CTX_data_edit_object(C); + Mesh *me = ((Mesh *)obedit->data); + BMEditMesh *em = ((Mesh *)obedit->data)->edit_btmesh; + BMFace *efa; + BMIter iter; + int clear = RNA_boolean_get(op->ptr, "clear"); + + if (em == NULL) return OPERATOR_FINISHED; + + /* auto-enable Freestyle face mark drawing */ + if(!clear) { + me->drawflag |= ME_DRAW_FREESTYLE_FACE; + } + + if(clear) { + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { + if (BM_elem_flag_test(efa, BM_ELEM_SELECT) && !BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) + BM_elem_flag_disable(efa, BM_ELEM_FREESTYLE); + } + } else { + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { + if (BM_elem_flag_test(efa, BM_ELEM_SELECT) && !BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) + BM_elem_flag_enable(efa, BM_ELEM_FREESTYLE); + } + } + + DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + + return OPERATOR_FINISHED; +} + +void MESH_OT_mark_freestyle_face(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Mark Freestyle Face"; + ot->description = "(un)mark selected faces for exclusion from Freestyle feature edge detection"; + ot->idname = "MESH_OT_mark_freestyle_face"; + + /* api callbacks */ + ot->exec = edbm_mark_freestyle_face_exec; + ot->poll = ED_operator_editmesh; + + /* flags */ + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_boolean(ot->srna, "clear", 0, "Clear", ""); +} + diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index cf17fce2971..ee74cea48af 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -135,6 +135,7 @@ void MESH_OT_select_random(struct wmOperatorType *ot); void MESH_OT_loop_multi_select(struct wmOperatorType *ot); void MESH_OT_mark_seam(struct wmOperatorType *ot); void MESH_OT_mark_sharp(struct wmOperatorType *ot); +void MESH_OT_mark_freestyle_edge(struct wmOperatorType *ot); void MESH_OT_vertices_smooth(struct wmOperatorType *ot); void MESH_OT_noise(struct wmOperatorType *ot); void MESH_OT_flip_normals(struct wmOperatorType *ot); @@ -182,6 +183,7 @@ void MESH_OT_rip(struct wmOperatorType *ot); void MESH_OT_shape_propagate_to_all(struct wmOperatorType *ot); void MESH_OT_blend_from_shape(struct wmOperatorType *ot); void MESH_OT_sort_elements(struct wmOperatorType *ot); +void MESH_OT_mark_freestyle_face(struct wmOperatorType *ot); /* ******************* mesh_data.c */ diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index dfa1beb614f..7f73851f2a8 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -117,6 +117,7 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_faces_shade_smooth); WM_operatortype_append(MESH_OT_faces_shade_flat); WM_operatortype_append(MESH_OT_sort_elements); + WM_operatortype_append(MESH_OT_mark_freestyle_face); WM_operatortype_append(MESH_OT_delete); WM_operatortype_append(MESH_OT_edge_collapse); @@ -131,6 +132,7 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_loop_multi_select); WM_operatortype_append(MESH_OT_mark_seam); WM_operatortype_append(MESH_OT_mark_sharp); + WM_operatortype_append(MESH_OT_mark_freestyle_edge); WM_operatortype_append(MESH_OT_vertices_smooth); WM_operatortype_append(MESH_OT_noise); WM_operatortype_append(MESH_OT_flip_normals); diff --git a/source/blender/editors/render/CMakeLists.txt b/source/blender/editors/render/CMakeLists.txt index 3c5fd0b4ef7..c9be7d0e5e0 100644 --- a/source/blender/editors/render/CMakeLists.txt +++ b/source/blender/editors/render/CMakeLists.txt @@ -36,6 +36,7 @@ set(INC set(INC_SYS ${GLEW_INCLUDE_PATH} + ../../freestyle ) set(SRC diff --git a/source/blender/editors/render/SConscript b/source/blender/editors/render/SConscript index 0b19ecdab8e..9f769a68ecf 100644 --- a/source/blender/editors/render/SConscript +++ b/source/blender/editors/render/SConscript @@ -5,7 +5,7 @@ sources = env.Glob('*.c') incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf' incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' -incs += ' ../../gpu' +incs += ' ../../gpu ../../freestyle' incs += ' ../../makesrna ../../render/extern/include #/intern/elbeem/extern' incs += ' ../../blenloader ../../bmesh' diff --git a/source/blender/editors/render/render_intern.h b/source/blender/editors/render/render_intern.h index 18ba2b5abf9..eb240d4071e 100644 --- a/source/blender/editors/render/render_intern.h +++ b/source/blender/editors/render/render_intern.h @@ -53,6 +53,21 @@ void MATERIAL_OT_paste(struct wmOperatorType *ot); void SCENE_OT_render_layer_add(struct wmOperatorType *ot); void SCENE_OT_render_layer_remove(struct wmOperatorType *ot); +void SCENE_OT_freestyle_module_add(struct wmOperatorType *ot); +void SCENE_OT_freestyle_module_remove(struct wmOperatorType *ot); +void SCENE_OT_freestyle_module_move(struct wmOperatorType *ot); +void SCENE_OT_freestyle_lineset_add(struct wmOperatorType *ot); +void SCENE_OT_freestyle_lineset_copy(struct wmOperatorType *ot); +void SCENE_OT_freestyle_lineset_paste(struct wmOperatorType *ot); +void SCENE_OT_freestyle_lineset_remove(struct wmOperatorType *ot); +void SCENE_OT_freestyle_lineset_move(struct wmOperatorType *ot); +void SCENE_OT_freestyle_linestyle_new(struct wmOperatorType *ot); +void SCENE_OT_freestyle_color_modifier_add(struct wmOperatorType *ot); +void SCENE_OT_freestyle_alpha_modifier_add(struct wmOperatorType *ot); +void SCENE_OT_freestyle_thickness_modifier_add(struct wmOperatorType *ot); +void SCENE_OT_freestyle_geometry_modifier_add(struct wmOperatorType *ot); +void SCENE_OT_freestyle_modifier_remove(struct wmOperatorType *ot); +void SCENE_OT_freestyle_modifier_move(struct wmOperatorType *ot); void TEXTURE_OT_slot_copy(struct wmOperatorType *ot); diff --git a/source/blender/editors/render/render_ops.c b/source/blender/editors/render/render_ops.c index c9e6dc90515..f94d94178a4 100644 --- a/source/blender/editors/render/render_ops.c +++ b/source/blender/editors/render/render_ops.c @@ -62,6 +62,22 @@ void ED_operatortypes_render(void) WM_operatortype_append(SCENE_OT_render_layer_add); WM_operatortype_append(SCENE_OT_render_layer_remove); + WM_operatortype_append(SCENE_OT_freestyle_module_add); + WM_operatortype_append(SCENE_OT_freestyle_module_remove); + WM_operatortype_append(SCENE_OT_freestyle_module_move); + WM_operatortype_append(SCENE_OT_freestyle_lineset_add); + WM_operatortype_append(SCENE_OT_freestyle_lineset_copy); + WM_operatortype_append(SCENE_OT_freestyle_lineset_paste); + WM_operatortype_append(SCENE_OT_freestyle_lineset_remove); + WM_operatortype_append(SCENE_OT_freestyle_lineset_move); + WM_operatortype_append(SCENE_OT_freestyle_linestyle_new); + WM_operatortype_append(SCENE_OT_freestyle_color_modifier_add); + WM_operatortype_append(SCENE_OT_freestyle_alpha_modifier_add); + WM_operatortype_append(SCENE_OT_freestyle_thickness_modifier_add); + WM_operatortype_append(SCENE_OT_freestyle_geometry_modifier_add); + WM_operatortype_append(SCENE_OT_freestyle_modifier_remove); + WM_operatortype_append(SCENE_OT_freestyle_modifier_move); + #if (defined(WITH_QUICKTIME) && !defined(USE_QTKIT)) WM_operatortype_append(SCENE_OT_render_data_set_quicktime_codec); #endif diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 21cd02c96f2..05d62d0b32d 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -55,6 +55,7 @@ #include "BKE_icons.h" #include "BKE_image.h" #include "BKE_library.h" +#include "BKE_linestyle.h" #include "BKE_main.h" #include "BKE_material.h" #include "BKE_node.h" @@ -69,7 +70,10 @@ #include "GPU_material.h" +#include "FRS_freestyle.h" + #include "RNA_access.h" +#include "RNA_enum_types.h" #include "WM_api.h" #include "WM_types.h" @@ -570,6 +574,566 @@ void SCENE_OT_render_layer_remove(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +static int freestyle_module_add_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene= CTX_data_scene(C); + SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay); + + FRS_add_module(&srl->freestyleConfig); + + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_freestyle_module_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Freestyle Module"; + ot->idname= "SCENE_OT_freestyle_module_add"; + ot->description="Add a style module into the list of modules"; + + /* api callbacks */ + ot->exec= freestyle_module_add_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int freestyle_module_remove_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene= CTX_data_scene(C); + SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay); + PointerRNA ptr= CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings); + FreestyleModuleConfig *module= ptr.data; + + FRS_delete_module(&srl->freestyleConfig, module); + + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_freestyle_module_remove(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Remove Freestyle Module"; + ot->idname= "SCENE_OT_freestyle_module_remove"; + ot->description="Remove the style module from the stack"; + + /* api callbacks */ + ot->exec= freestyle_module_remove_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int freestyle_module_move_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay); + PointerRNA ptr= CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings); + FreestyleModuleConfig *module= ptr.data; + int dir= RNA_enum_get(op->ptr, "direction"); + + if (dir == 1) { + FRS_move_module_up(&srl->freestyleConfig, module); + } else { + FRS_move_module_down(&srl->freestyleConfig, module); + } + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_freestyle_module_move(wmOperatorType *ot) +{ + static EnumPropertyItem direction_items[] = { + {1, "UP", 0, "Up", ""}, + {-1, "DOWN", 0, "Down", ""}, + {0, NULL, 0, NULL, NULL} + }; + + /* identifiers */ + ot->name= "Move Freestyle Module"; + ot->idname= "SCENE_OT_freestyle_module_move"; + ot->description="Change the position of the style module within in the list of style modules"; + + /* api callbacks */ + ot->exec= freestyle_module_move_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* props */ + RNA_def_enum(ot->srna, "direction", direction_items, 0, "Direction", "Direction to move, UP or DOWN"); +} + +static int freestyle_lineset_add_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene= CTX_data_scene(C); + SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay); + + FRS_add_lineset(&srl->freestyleConfig); + + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_freestyle_lineset_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Line Set"; + ot->idname= "SCENE_OT_freestyle_lineset_add"; + ot->description="Add a line set into the list of line sets"; + + /* api callbacks */ + ot->exec= freestyle_lineset_add_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int freestyle_active_lineset_poll(bContext *C) +{ + Scene *scene= CTX_data_scene(C); + SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay); + + return FRS_get_active_lineset(&srl->freestyleConfig) != NULL; +} + +static int freestyle_lineset_copy_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay); + + FRS_copy_active_lineset(&srl->freestyleConfig); + + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_freestyle_lineset_copy(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Copy Line Set"; + ot->idname= "SCENE_OT_freestyle_lineset_copy"; + ot->description="Copy the active line set to a buffer"; + + /* api callbacks */ + ot->exec= freestyle_lineset_copy_exec; + ot->poll= freestyle_active_lineset_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int freestyle_lineset_paste_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay); + + FRS_paste_active_lineset(&srl->freestyleConfig); + + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_freestyle_lineset_paste(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Paste Line Set"; + ot->idname= "SCENE_OT_freestyle_lineset_paste"; + ot->description="Paste the buffer content to the active line set"; + + /* api callbacks */ + ot->exec= freestyle_lineset_paste_exec; + ot->poll= freestyle_active_lineset_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int freestyle_lineset_remove_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene= CTX_data_scene(C); + SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay); + + FRS_delete_active_lineset(&srl->freestyleConfig); + + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_freestyle_lineset_remove(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Remove Line Set"; + ot->idname= "SCENE_OT_freestyle_lineset_remove"; + ot->description="Remove the active line set from the list of line sets"; + + /* api callbacks */ + ot->exec= freestyle_lineset_remove_exec; + ot->poll= freestyle_active_lineset_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int freestyle_lineset_move_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay); + int dir= RNA_enum_get(op->ptr, "direction"); + + if (dir == 1) { + FRS_move_active_lineset_up(&srl->freestyleConfig); + } else { + FRS_move_active_lineset_down(&srl->freestyleConfig); + } + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_freestyle_lineset_move(wmOperatorType *ot) +{ + static EnumPropertyItem direction_items[] = { + {1, "UP", 0, "Up", ""}, + {-1, "DOWN", 0, "Down", ""}, + {0, NULL, 0, NULL, NULL} + }; + + /* identifiers */ + ot->name= "Move Line Set"; + ot->idname= "SCENE_OT_freestyle_lineset_move"; + ot->description="Change the position of the active line set within the list of line sets"; + + /* api callbacks */ + ot->exec= freestyle_lineset_move_exec; + ot->poll= freestyle_active_lineset_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* props */ + RNA_def_enum(ot->srna, "direction", direction_items, 0, "Direction", "Direction to move, UP or DOWN"); +} + +static int freestyle_linestyle_new_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay); + FreestyleLineSet *lineset = FRS_get_active_lineset(&srl->freestyleConfig); + + if (!lineset) { + BKE_report(op->reports, RPT_ERROR, "No active lineset to add a new line style to."); + return OPERATOR_CANCELLED; + } + lineset->linestyle->id.us--; + lineset->linestyle = FRS_copy_linestyle(lineset->linestyle); + + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_freestyle_linestyle_new(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "New Line Style"; + ot->idname= "SCENE_OT_freestyle_linestyle_new"; + ot->description="Create a new line style, reusable by multiple line sets"; + + /* api callbacks */ + ot->exec= freestyle_linestyle_new_exec; + ot->poll= freestyle_active_lineset_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int freestyle_color_modifier_add_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay); + FreestyleLineSet *lineset = FRS_get_active_lineset(&srl->freestyleConfig); + int type= RNA_enum_get(op->ptr, "type"); + + if (!lineset) { + BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to."); + return OPERATOR_CANCELLED; + } + if (FRS_add_linestyle_color_modifier(lineset->linestyle, type) < 0) { + BKE_report(op->reports, RPT_ERROR, "Unknown line color modifier type."); + return OPERATOR_CANCELLED; + } + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_freestyle_color_modifier_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Line Color Modifier"; + ot->idname= "SCENE_OT_freestyle_color_modifier_add"; + ot->description = "Add a line color modifier to the line style associated with the active lineset"; + + /* api callbacks */ + ot->invoke= WM_menu_invoke; + ot->exec= freestyle_color_modifier_add_exec; + ot->poll= freestyle_active_lineset_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + ot->prop= RNA_def_enum(ot->srna, "type", linestyle_color_modifier_type_items, 0, "Type", ""); +} + +static int freestyle_alpha_modifier_add_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay); + FreestyleLineSet *lineset = FRS_get_active_lineset(&srl->freestyleConfig); + int type= RNA_enum_get(op->ptr, "type"); + + if (!lineset) { + BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to."); + return OPERATOR_CANCELLED; + } + if (FRS_add_linestyle_alpha_modifier(lineset->linestyle, type) < 0) { + BKE_report(op->reports, RPT_ERROR, "Unknown alpha transparency modifier type."); + return OPERATOR_CANCELLED; + } + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_freestyle_alpha_modifier_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Alpha Transparency Modifier"; + ot->idname= "SCENE_OT_freestyle_alpha_modifier_add"; + ot->description = "Add an alpha transparency modifier to the line style associated with the active lineset"; + + /* api callbacks */ + ot->invoke= WM_menu_invoke; + ot->exec= freestyle_alpha_modifier_add_exec; + ot->poll= freestyle_active_lineset_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + ot->prop= RNA_def_enum(ot->srna, "type", linestyle_alpha_modifier_type_items, 0, "Type", ""); +} + +static int freestyle_thickness_modifier_add_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay); + FreestyleLineSet *lineset = FRS_get_active_lineset(&srl->freestyleConfig); + int type= RNA_enum_get(op->ptr, "type"); + + if (!lineset) { + BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to."); + return OPERATOR_CANCELLED; + } + if (FRS_add_linestyle_thickness_modifier(lineset->linestyle, type) < 0) { + BKE_report(op->reports, RPT_ERROR, "Unknown line thickness modifier type."); + return OPERATOR_CANCELLED; + } + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_freestyle_thickness_modifier_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Line Thickness Modifier"; + ot->idname= "SCENE_OT_freestyle_thickness_modifier_add"; + ot->description = "Add a line thickness modifier to the line style associated with the active lineset"; + + /* api callbacks */ + ot->invoke= WM_menu_invoke; + ot->exec= freestyle_thickness_modifier_add_exec; + ot->poll= freestyle_active_lineset_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + ot->prop= RNA_def_enum(ot->srna, "type", linestyle_thickness_modifier_type_items, 0, "Type", ""); +} + +static int freestyle_geometry_modifier_add_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay); + FreestyleLineSet *lineset = FRS_get_active_lineset(&srl->freestyleConfig); + int type= RNA_enum_get(op->ptr, "type"); + + if (!lineset) { + BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to."); + return OPERATOR_CANCELLED; + } + if (FRS_add_linestyle_geometry_modifier(lineset->linestyle, type) < 0) { + BKE_report(op->reports, RPT_ERROR, "Unknown stroke geometry modifier type."); + return OPERATOR_CANCELLED; + } + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_freestyle_geometry_modifier_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Stroke Geometry Modifier"; + ot->idname= "SCENE_OT_freestyle_geometry_modifier_add"; + ot->description = "Add a stroke geometry modifier to the line style associated with the active lineset"; + + /* api callbacks */ + ot->invoke= WM_menu_invoke; + ot->exec= freestyle_geometry_modifier_add_exec; + ot->poll= freestyle_active_lineset_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + ot->prop= RNA_def_enum(ot->srna, "type", linestyle_geometry_modifier_type_items, 0, "Type", ""); +} + +static int freestyle_get_modifier_type(PointerRNA *ptr) +{ + if (RNA_struct_is_a(ptr->type, &RNA_LineStyleColorModifier)) + return LS_MODIFIER_TYPE_COLOR; + else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleAlphaModifier)) + return LS_MODIFIER_TYPE_ALPHA; + else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleThicknessModifier)) + return LS_MODIFIER_TYPE_THICKNESS; + else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleGeometryModifier)) + return LS_MODIFIER_TYPE_GEOMETRY; + return -1; +} + +static int freestyle_modifier_remove_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay); + FreestyleLineSet *lineset = FRS_get_active_lineset(&srl->freestyleConfig); + PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_LineStyleModifier); + LineStyleModifier *modifier= ptr.data; + + if (!lineset) { + BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style the modifier belongs to."); + return OPERATOR_CANCELLED; + } + switch (freestyle_get_modifier_type(&ptr)) { + case LS_MODIFIER_TYPE_COLOR: + FRS_remove_linestyle_color_modifier(lineset->linestyle, modifier); + break; + case LS_MODIFIER_TYPE_ALPHA: + FRS_remove_linestyle_alpha_modifier(lineset->linestyle, modifier); + break; + case LS_MODIFIER_TYPE_THICKNESS: + FRS_remove_linestyle_thickness_modifier(lineset->linestyle, modifier); + break; + case LS_MODIFIER_TYPE_GEOMETRY: + FRS_remove_linestyle_geometry_modifier(lineset->linestyle, modifier); + break; + default: + BKE_report(op->reports, RPT_ERROR, "The object the data pointer refers to is not a valid modifier."); + return OPERATOR_CANCELLED; + } + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_freestyle_modifier_remove(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Remove Modifier"; + ot->idname= "SCENE_OT_freestyle_modifier_remove"; + ot->description="Remove the modifier from the list of modifiers"; + + /* api callbacks */ + ot->exec= freestyle_modifier_remove_exec; + ot->poll= freestyle_active_lineset_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int freestyle_modifier_move_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay); + FreestyleLineSet *lineset = FRS_get_active_lineset(&srl->freestyleConfig); + PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_LineStyleModifier); + LineStyleModifier *modifier= ptr.data; + int dir= RNA_enum_get(op->ptr, "direction"); + + if (!lineset) { + BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style the modifier belongs to."); + return OPERATOR_CANCELLED; + } + switch (freestyle_get_modifier_type(&ptr)) { + case LS_MODIFIER_TYPE_COLOR: + FRS_move_linestyle_color_modifier(lineset->linestyle, modifier, dir); + break; + case LS_MODIFIER_TYPE_ALPHA: + FRS_move_linestyle_alpha_modifier(lineset->linestyle, modifier, dir); + break; + case LS_MODIFIER_TYPE_THICKNESS: + FRS_move_linestyle_thickness_modifier(lineset->linestyle, modifier, dir); + break; + case LS_MODIFIER_TYPE_GEOMETRY: + FRS_move_linestyle_geometry_modifier(lineset->linestyle, modifier, dir); + break; + default: + BKE_report(op->reports, RPT_ERROR, "The object the data pointer refers to is not a valid modifier."); + return OPERATOR_CANCELLED; + } + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_freestyle_modifier_move(wmOperatorType *ot) +{ + static EnumPropertyItem direction_items[] = { + {1, "UP", 0, "Up", ""}, + {-1, "DOWN", 0, "Down", ""}, + {0, NULL, 0, NULL, NULL} + }; + + /* identifiers */ + ot->name= "Move Modifier"; + ot->idname= "SCENE_OT_freestyle_modifier_move"; + ot->description="Move the modifier within the list of modifiers"; + + /* api callbacks */ + ot->exec= freestyle_modifier_move_exec; + ot->poll= freestyle_active_lineset_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* props */ + RNA_def_enum(ot->srna, "direction", direction_items, 0, "Direction", "Direction to move, UP or DOWN"); +} + static int texture_slot_move(bContext *C, wmOperator *op) { ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data; diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index e102abeecf0..d1737fcd065 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -370,6 +370,10 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_redraw(sa); sbuts->preview = 1; break; + case NC_LINESTYLE: + ED_area_tag_redraw(sa); + sbuts->preview= 1; + break; } if (wmn->data == ND_KEYS) diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index d84214413da..27f8ae59919 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -1140,7 +1140,7 @@ void filelist_from_main(struct FileList *filelist) if ( filelist->dir[0]==0) { /* make directories */ - filelist->numfiles= 24; + filelist->numfiles= 25; filelist->filelist= (struct direntry *)malloc(filelist->numfiles * sizeof(struct direntry)); for (a=0; a<filelist->numfiles; a++) { @@ -1171,6 +1171,7 @@ void filelist_from_main(struct FileList *filelist) filelist->filelist[21].relname= BLI_strdup("Action"); filelist->filelist[22].relname= BLI_strdup("NodeTree"); filelist->filelist[23].relname= BLI_strdup("Speaker"); + filelist->filelist[24].relname= BLI_strdup("FreestyleLineStyle"); filelist_sort(filelist, FILE_SORT_ALPHA); } else { diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index 63e518e5aaa..be60e47ac8f 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -145,6 +145,7 @@ static int nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA case ANIMTYPE_DSPART: case ANIMTYPE_DSMBALL: case ANIMTYPE_DSARM: + case ANIMTYPE_DSLINESTYLE: case ANIMTYPE_DSSPK: { /* for these channels, we only do AnimData */ diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index e3c831824f1..11a39693168 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -178,6 +178,7 @@ static int mouse_nla_channels(bAnimContext *ac, float x, int channel_index, shor case ANIMTYPE_DSMESH: case ANIMTYPE_DSTEX: case ANIMTYPE_DSLAT: + case ANIMTYPE_DSLINESTYLE: case ANIMTYPE_DSSPK: { /* sanity checking... */ diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index f60c46fed9a..498189321be 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -164,7 +164,7 @@ typedef struct drawDMEdgesSel_userData { } drawDMEdgesSel_userData; typedef struct drawDMFacesSel_userData { - unsigned char *cols[3]; + unsigned char *cols[4]; DerivedMesh *dm; /* BMESH BRANCH ONLY */ BMEditMesh *em; /* BMESH BRANCH ONLY */ @@ -2596,6 +2596,21 @@ static void draw_dm_edges_sharp(BMEditMesh *em, DerivedMesh *dm) dm->drawMappedEdges(dm, draw_dm_edges_sharp__setDrawOptions, em); } +/* Draw only Freestyle feature edges */ +static DMDrawOption draw_dm_edges_freestyle__setDrawOptions(void *userData, int index) +{ + BMEdge *eed = EDBM_edge_at_index(userData, index); + + if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_elem_flag_test(eed, BM_ELEM_FREESTYLE)) + return DM_DRAW_OPTION_NORMAL; + else + return DM_DRAW_OPTION_SKIP; +} + +static void draw_dm_edges_freestyle(BMEditMesh *em, DerivedMesh *dm) +{ + dm->drawMappedEdges(dm, draw_dm_edges_freestyle__setDrawOptions, em); +} /* Draw faces with color set based on selection * return 2 for the active face so it renders with stipple enabled */ @@ -2610,11 +2625,11 @@ static DMDrawOption draw_dm_faces_sel__setDrawOptions(void *userData, int index) if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { if (efa == data->efa_act) { - glColor4ubv(data->cols[2]); + glColor4ubv(data->cols[3]); return DM_DRAW_OPTION_STIPPLE; } else { - col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : 0]; + col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : BM_elem_flag_test(efa, BM_ELEM_FREESTYLE) ? 2 : 0]; if (col[3] == 0) return DM_DRAW_OPTION_SKIP; glColor4ubv(col); @@ -2645,8 +2660,8 @@ static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int if (efa == data->efa_act || next_efa == data->efa_act) return 0; - col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : 0]; - next_col = data->cols[BM_elem_flag_test(next_efa, BM_ELEM_SELECT) ? 1 : 0]; + col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : BM_elem_flag_test(efa, BM_ELEM_FREESTYLE) ? 2 : 0]; + next_col = data->cols[BM_elem_flag_test(next_efa, BM_ELEM_SELECT) ? 1 : BM_elem_flag_test(next_efa, BM_ELEM_FREESTYLE) ? 2 : 0]; if (col[3] == 0 || next_col[3] == 0) return 0; @@ -2656,14 +2671,15 @@ static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int /* also draws the active face */ static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol, - unsigned char *selCol, unsigned char *actCol, BMFace *efa_act) + unsigned char *selCol, unsigned char *markCol, unsigned char *actCol, BMFace *efa_act) { drawDMFacesSel_userData data; data.dm = dm; data.cols[0] = baseCol; data.em = em; data.cols[1] = selCol; - data.cols[2] = actCol; + data.cols[2] = markCol; + data.cols[3] = actCol; data.efa_act = efa_act; data.orig_index = DM_get_tessface_data_layer(dm, CD_ORIGINDEX); @@ -3195,11 +3211,12 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, } if (me->drawflag & ME_DRAWFACES) { /* transp faces */ - unsigned char col1[4], col2[4], col3[4]; + unsigned char col1[4], col2[4], col3[4], col4[4]; UI_GetThemeColor4ubv(TH_FACE, col1); UI_GetThemeColor4ubv(TH_FACE_SELECT, col2); - UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3); + UI_GetThemeColor4ubv(TH_FREESTYLE_FACE_MARK, col3); + UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col4); glEnable(GL_BLEND); glDepthMask(0); // disable write in zbuffer, needed for nice transp @@ -3208,7 +3225,10 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, if (check_object_draw_texture(scene, v3d, dt)) col1[3] = 0; - draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act); + if (!(me->drawflag & ME_DRAW_FREESTYLE_FACE)) + col3[3] = 0; + + draw_dm_faces_sel(em, cageDM, col1, col2, col3, col4, efa_act); glDisable(GL_BLEND); glDepthMask(1); // restore write in zbuffer @@ -3217,14 +3237,14 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, /* even if draw faces is off it would be nice to draw the stipple face * Make all other faces zero alpha except for the active * */ - unsigned char col1[4], col2[4], col3[4]; - col1[3] = col2[3] = 0; /* don't draw */ - UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3); + unsigned char col1[4], col2[4], col3[4], col4[4]; + col1[3] = col2[3] = col3[3] = 0; /* don't draw */ + UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col4); glEnable(GL_BLEND); glDepthMask(0); // disable write in zbuffer, needed for nice transp - draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act); + draw_dm_faces_sel(em, cageDM, col1, col2, col3, col4, efa_act); glDisable(GL_BLEND); glDepthMask(1); // restore write in zbuffer @@ -3260,6 +3280,16 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, glLineWidth(1); } + if(me->drawflag & ME_DRAW_FREESTYLE_EDGE) { + UI_ThemeColor(TH_FREESTYLE_EDGE_MARK); + glLineWidth(2); + + draw_dm_edges_freestyle(em, cageDM); + + glColor3ub(0,0,0); + glLineWidth(1); + } + if (me->drawflag & ME_DRAWCREASES && CustomData_has_layer(&em->bm->edata, CD_CREASE)) { draw_dm_creases(em, cageDM); } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index e955dae0178..2a4b2f06b90 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -690,9 +690,6 @@ int transformEvent(TransInfo *t, wmEvent *event) t->redraw |= handleMouseInput(t, &t->mouse, event); if (event->type == MOUSEMOVE) { - if (t->modifiers & MOD_CONSTRAINT_SELECT) - t->con.mode |= CON_SELECT; - copy_v2_v2_int(t->mval, event->mval); // t->redraw |= TREDRAW_SOFT; /* Use this for soft redraw. Might cause flicker in object mode */ @@ -1807,6 +1804,9 @@ void transformApply(bContext *C, TransInfo *t) t->context = C; if ((t->redraw & TREDRAW_HARD) || (t->draw_handle_apply == NULL && (t->redraw & TREDRAW_SOFT))) { + if (t->modifiers & MOD_CONSTRAINT_SELECT) + t->con.mode |= CON_SELECT; + selectConstraint(t); if (t->transform) { t->transform(t, t->mval); // calls recalcData() diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 91f62291450..e4ba9b94ff7 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -494,7 +494,6 @@ void initTransformOrientation(bContext *C, TransInfo *t) switch (t->current_orientation) { case V3D_MANIP_GLOBAL: - unit_m3(t->spacemtx); strcpy(t->spacename, "global"); break; |