Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/gpencil/gpencil_add_lineart.c
| Show All 15 Lines | |||||
| #include "BKE_brush.h" | #include "BKE_brush.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_gpencil.h" | #include "BKE_gpencil.h" | ||||
| #include "BKE_gpencil_geom.h" | #include "BKE_gpencil_geom.h" | ||||
| #include "BKE_lib_id.h" | #include "BKE_lib_id.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_material.h" | #include "BKE_material.h" | ||||
| #include "BLT_translation.h" | |||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "ED_gpencil.h" | #include "ED_gpencil.h" | ||||
| /* Definition of the most important info from a color */ | /* Definition of the most important info from a color */ | ||||
| typedef struct ColorTemplate { | typedef struct ColorTemplate { | ||||
| const char *name; | const char *name; | ||||
| float line[4]; | float line[4]; | ||||
| float fill[4]; | float fill[4]; | ||||
| } ColorTemplate; | } ColorTemplate; | ||||
| /* Add color an ensure duplications (matched by name) */ | /* Add color an ensure duplications (matched by name) */ | ||||
| static int gpencil_lineart_material(Main *bmain, | static int gpencil_lineart_material(Main *bmain, | ||||
| Object *ob, | Object *ob, | ||||
| const ColorTemplate *pct, | const ColorTemplate *pct, | ||||
| const bool fill) | const bool fill) | ||||
| { | { | ||||
| int index; | int index; | ||||
| Material *ma = BKE_gpencil_object_material_ensure_by_name(bmain, ob, pct->name, &index); | Material *ma = BKE_gpencil_object_material_ensure_by_name(bmain, ob, DATA_(pct->name), &index); | ||||
| copy_v4_v4(ma->gp_style->stroke_rgba, pct->line); | copy_v4_v4(ma->gp_style->stroke_rgba, pct->line); | ||||
| srgb_to_linearrgb_v4(ma->gp_style->stroke_rgba, ma->gp_style->stroke_rgba); | srgb_to_linearrgb_v4(ma->gp_style->stroke_rgba, ma->gp_style->stroke_rgba); | ||||
| copy_v4_v4(ma->gp_style->fill_rgba, pct->fill); | copy_v4_v4(ma->gp_style->fill_rgba, pct->fill); | ||||
| srgb_to_linearrgb_v4(ma->gp_style->fill_rgba, ma->gp_style->fill_rgba); | srgb_to_linearrgb_v4(ma->gp_style->fill_rgba, ma->gp_style->fill_rgba); | ||||
| if (fill) { | if (fill) { | ||||
| ma->gp_style->flag |= GP_MATERIAL_FILL_SHOW; | ma->gp_style->flag |= GP_MATERIAL_FILL_SHOW; | ||||
| } | } | ||||
| return index; | return index; | ||||
| } | } | ||||
| /* ***************************************************************** */ | /* ***************************************************************** */ | ||||
| /* Color Data */ | /* Color Data */ | ||||
| static const ColorTemplate gp_stroke_material_black = { | static const ColorTemplate gp_stroke_material_black = { | ||||
| "Black", | N_("Black"), | ||||
| {0.0f, 0.0f, 0.0f, 1.0f}, | {0.0f, 0.0f, 0.0f, 1.0f}, | ||||
| {0.0f, 0.0f, 0.0f, 0.0f}, | {0.0f, 0.0f, 0.0f, 0.0f}, | ||||
| }; | }; | ||||
| /* ***************************************************************** */ | /* ***************************************************************** */ | ||||
| /* LineArt API */ | /* LineArt API */ | ||||
| void ED_gpencil_create_lineart(bContext *C, Object *ob) | void ED_gpencil_create_lineart(bContext *C, Object *ob) | ||||
| Show All 21 Lines | |||||