Cleanup: BKE_gpencil naming
- The ambiguous term 'handle' was used where 'ensure' is typically used (get or add when missing). - Rename `current` to `active`, all `current` functions which were also ensuring. - Clarify what is being operated on, using `BKE_gpencil_object_*` for objects, `BKE_gpencil_brush_*` for brushes.
This commit is contained in:
@@ -86,7 +86,6 @@ void BKE_gpencil_frame_delete_laststroke(struct bGPDlayer *gpl, struct bGPDframe
|
||||
/* materials */
|
||||
void BKE_gpencil_material_index_remove(struct bGPdata *gpd, int index);
|
||||
void BKE_gpencil_material_remap(struct bGPdata *gpd, const unsigned int *remap, unsigned int remap_len);
|
||||
int BKE_gpencil_get_material_index(struct Object *ob, struct Material *ma);
|
||||
|
||||
/* statistics functions */
|
||||
void BKE_gpencil_stats_update(struct bGPdata *gpd);
|
||||
@@ -131,23 +130,29 @@ struct bGPDlayer *BKE_gpencil_layer_getactive(struct bGPdata *gpd);
|
||||
void BKE_gpencil_layer_setactive(struct bGPdata *gpd, struct bGPDlayer *active);
|
||||
void BKE_gpencil_layer_delete(struct bGPdata *gpd, struct bGPDlayer *gpl);
|
||||
|
||||
struct Material *BKE_gpencil_get_material_from_brush(struct Brush *brush);
|
||||
void BKE_gpencil_brush_set_material(struct Brush *brush, struct Material *material);
|
||||
/* Brush */
|
||||
struct Material *BKE_gpencil_brush_material_get(struct Brush *brush);
|
||||
void BKE_gpencil_brush_material_set(struct Brush *brush, struct Material *material);
|
||||
|
||||
struct Material *BKE_gpencil_handle_brush_material(struct Main *bmain, struct Object *ob, struct Brush *brush);
|
||||
int BKE_gpencil_handle_material(struct Main *bmain, struct Object *ob, struct Material *material);
|
||||
/* Object */
|
||||
struct Material *BKE_gpencil_object_material_ensure_active(struct Main *bmain, struct Object *ob);
|
||||
struct Material *BKE_gpencil_object_material_ensure_from_brush(struct Main *bmain, struct Object *ob, struct Brush *brush);
|
||||
int BKE_gpencil_object_material_ensure(struct Main *bmain, struct Object *ob, struct Material *material);
|
||||
|
||||
struct Material *BKE_gpencil_handle_new_material(struct Main *bmain, struct Object *ob, const char *name, int *r_index);
|
||||
struct Material *BKE_gpencil_object_material_new(struct Main *bmain, struct Object *ob, const char *name, int *r_index);
|
||||
|
||||
struct Material *BKE_gpencil_get_material_for_brush(struct Object *ob, struct Brush *brush);
|
||||
int BKE_gpencil_get_material_index_for_brush(struct Object *ob, struct Brush *brush);
|
||||
int BKE_gpencil_object_material_get_index(struct Object *ob, struct Material *ma);
|
||||
|
||||
struct Material *BKE_gpencil_current_input_toolsettings_material(struct Main *bmain, struct Object *ob, struct ToolSettings *ts);
|
||||
struct Material *BKE_gpencil_current_input_brush_material(struct Main *bmain, struct Object *ob, struct Brush *brush);
|
||||
struct Material *BKE_gpencil_current_input_material(struct Main *bmain, struct Object *ob);
|
||||
struct Material *BKE_gpencil_object_material_get_from_brush(struct Object *ob, struct Brush *brush);
|
||||
int BKE_gpencil_object_material_get_index_from_brush(struct Object *ob, struct Brush *brush);
|
||||
|
||||
struct Material *BKE_gpencil_object_material_ensure_from_active_input_toolsettings(
|
||||
struct Main *bmain, struct Object *ob, struct ToolSettings *ts);
|
||||
struct Material *BKE_gpencil_object_material_ensure_from_active_input_brush(
|
||||
struct Main *bmain, struct Object *ob, struct Brush *brush);
|
||||
struct Material *BKE_gpencil_object_material_ensure_from_active_input_material(
|
||||
struct Main *bmain, struct Object *ob);
|
||||
|
||||
struct Material *BKE_gpencil_material_ensure(struct Main *bmain, struct Object *ob);
|
||||
|
||||
/* object boundbox */
|
||||
bool BKE_gpencil_data_minmax(
|
||||
|
||||
@@ -985,7 +985,7 @@ void BKE_gpencil_layer_delete(bGPdata *gpd, bGPDlayer *gpl)
|
||||
BLI_freelinkN(&gpd->layers, gpl);
|
||||
}
|
||||
|
||||
Material *BKE_gpencil_get_material_from_brush(Brush *brush)
|
||||
Material *BKE_gpencil_brush_material_get(Brush *brush)
|
||||
{
|
||||
Material *ma = NULL;
|
||||
|
||||
@@ -998,7 +998,7 @@ Material *BKE_gpencil_get_material_from_brush(Brush *brush)
|
||||
return ma;
|
||||
}
|
||||
|
||||
void BKE_gpencil_brush_set_material(Brush *brush, Material *ma)
|
||||
void BKE_gpencil_brush_material_set(Brush *brush, Material *ma)
|
||||
{
|
||||
BLI_assert(brush);
|
||||
BLI_assert(brush->gpencil_settings);
|
||||
@@ -1014,13 +1014,13 @@ void BKE_gpencil_brush_set_material(Brush *brush, Material *ma)
|
||||
}
|
||||
|
||||
/* Adds the pinned material to the object if necessary. */
|
||||
Material *BKE_gpencil_handle_brush_material(Main *bmain, Object *ob, Brush *brush)
|
||||
Material *BKE_gpencil_object_material_ensure_from_brush(Main *bmain, Object *ob, Brush *brush)
|
||||
{
|
||||
if (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) {
|
||||
Material *ma = BKE_gpencil_get_material_from_brush(brush);
|
||||
Material *ma = BKE_gpencil_brush_material_get(brush);
|
||||
|
||||
/* check if the material is already on object material slots and add it if missing */
|
||||
if (ma && BKE_gpencil_get_material_index(ob, ma) < 0) {
|
||||
if (ma && BKE_gpencil_object_material_get_index(ob, ma) < 0) {
|
||||
BKE_object_material_slot_add(bmain, ob);
|
||||
assign_material(bmain, ob, ma, ob->totcol, BKE_MAT_ASSIGN_USERPREF);
|
||||
}
|
||||
@@ -1034,12 +1034,12 @@ Material *BKE_gpencil_handle_brush_material(Main *bmain, Object *ob, Brush *brus
|
||||
}
|
||||
|
||||
/* Assigns the material to object (if not already present) and returns its index (mat_nr). */
|
||||
int BKE_gpencil_handle_material(Main *bmain, Object *ob, Material *material)
|
||||
int BKE_gpencil_object_material_ensure(Main *bmain, Object *ob, Material *material)
|
||||
{
|
||||
if (!material) {
|
||||
return -1;
|
||||
}
|
||||
int index = BKE_gpencil_get_material_index(ob, material);
|
||||
int index = BKE_gpencil_object_material_get_index(ob, material);
|
||||
if (index < 0) {
|
||||
BKE_object_material_slot_add(bmain, ob);
|
||||
assign_material(bmain, ob, material, ob->totcol, BKE_MAT_ASSIGN_USERPREF);
|
||||
@@ -1052,7 +1052,7 @@ int BKE_gpencil_handle_material(Main *bmain, Object *ob, Material *material)
|
||||
*
|
||||
* \param *r_index: value is set to zero based index of the new material if r_index is not NULL
|
||||
*/
|
||||
Material *BKE_gpencil_handle_new_material(Main *bmain, Object *ob, const char *name, int *r_index)
|
||||
Material *BKE_gpencil_object_material_new(Main *bmain, Object *ob, const char *name, int *r_index)
|
||||
{
|
||||
Material *ma = BKE_material_add_gpencil(bmain, name);
|
||||
id_us_min(&ma->id); /* no users yet */
|
||||
@@ -1067,10 +1067,10 @@ Material *BKE_gpencil_handle_new_material(Main *bmain, Object *ob, const char *n
|
||||
}
|
||||
|
||||
/* Returns the material for a brush with respect to its pinned state. */
|
||||
Material *BKE_gpencil_get_material_for_brush(Object *ob, Brush *brush)
|
||||
Material *BKE_gpencil_object_material_get_from_brush(Object *ob, Brush *brush)
|
||||
{
|
||||
if (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) {
|
||||
Material *ma = BKE_gpencil_get_material_from_brush(brush);
|
||||
Material *ma = BKE_gpencil_brush_material_get(brush);
|
||||
return ma;
|
||||
}
|
||||
else {
|
||||
@@ -1079,10 +1079,10 @@ Material *BKE_gpencil_get_material_for_brush(Object *ob, Brush *brush)
|
||||
}
|
||||
|
||||
/* Returns the material index for a brush with respect to its pinned state. */
|
||||
int BKE_gpencil_get_material_index_for_brush(Object *ob, Brush *brush)
|
||||
int BKE_gpencil_object_material_get_index_from_brush(Object *ob, Brush *brush)
|
||||
{
|
||||
if (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) {
|
||||
return BKE_gpencil_get_material_index(ob, brush->gpencil_settings->material);
|
||||
return BKE_gpencil_object_material_get_index(ob, brush->gpencil_settings->material);
|
||||
}
|
||||
else {
|
||||
return ob->actcol - 1;
|
||||
@@ -1090,21 +1090,21 @@ int BKE_gpencil_get_material_index_for_brush(Object *ob, Brush *brush)
|
||||
}
|
||||
|
||||
/* Guaranteed to return a material assigned to object. Returns never NULL. */
|
||||
Material *BKE_gpencil_current_input_toolsettings_material(Main *bmain, Object *ob, ToolSettings *ts)
|
||||
Material *BKE_gpencil_object_material_ensure_from_active_input_toolsettings(Main *bmain, Object *ob, ToolSettings *ts)
|
||||
{
|
||||
if (ts && ts->gp_paint && ts->gp_paint->paint.brush) {
|
||||
return BKE_gpencil_current_input_brush_material(bmain, ob, ts->gp_paint->paint.brush);
|
||||
return BKE_gpencil_object_material_ensure_from_active_input_brush(bmain, ob, ts->gp_paint->paint.brush);
|
||||
}
|
||||
else {
|
||||
return BKE_gpencil_current_input_brush_material(bmain, ob, NULL);
|
||||
return BKE_gpencil_object_material_ensure_from_active_input_brush(bmain, ob, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* Guaranteed to return a material assigned to object. Returns never NULL. */
|
||||
Material *BKE_gpencil_current_input_brush_material(Main *bmain, Object *ob, Brush *brush)
|
||||
Material *BKE_gpencil_object_material_ensure_from_active_input_brush(Main *bmain, Object *ob, Brush *brush)
|
||||
{
|
||||
if (brush) {
|
||||
Material *ma = BKE_gpencil_handle_brush_material(bmain, ob, brush);
|
||||
Material *ma = BKE_gpencil_object_material_ensure_from_brush(bmain, ob, brush);
|
||||
if (ma) {
|
||||
return ma;
|
||||
}
|
||||
@@ -1113,21 +1113,21 @@ Material *BKE_gpencil_current_input_brush_material(Main *bmain, Object *ob, Brus
|
||||
brush->gpencil_settings->flag &= ~GP_BRUSH_MATERIAL_PINNED;
|
||||
}
|
||||
}
|
||||
return BKE_gpencil_current_input_material(bmain, ob);
|
||||
return BKE_gpencil_object_material_ensure_from_active_input_material(bmain, ob);
|
||||
}
|
||||
|
||||
/* Guaranteed to return a material assigned to object. Returns never NULL. Only use this for materials unrelated to user input */
|
||||
Material *BKE_gpencil_current_input_material(Main *bmain, Object *ob)
|
||||
Material *BKE_gpencil_object_material_ensure_from_active_input_material(Main *bmain, Object *ob)
|
||||
{
|
||||
Material *ma = give_current_material(ob, ob->actcol);
|
||||
if (ma) {
|
||||
return ma;
|
||||
}
|
||||
return BKE_gpencil_handle_new_material(bmain, ob, "Material", NULL);
|
||||
return BKE_gpencil_object_material_new(bmain, ob, "Material", NULL);
|
||||
}
|
||||
|
||||
/* Get active color, and add all default settings if we don't find anything */
|
||||
Material *BKE_gpencil_material_ensure(Main *bmain, Object *ob)
|
||||
Material *BKE_gpencil_object_material_ensure_active(Main *bmain, Object *ob)
|
||||
{
|
||||
Material *ma = NULL;
|
||||
|
||||
@@ -1135,7 +1135,7 @@ Material *BKE_gpencil_material_ensure(Main *bmain, Object *ob)
|
||||
if (ELEM(NULL, bmain, ob))
|
||||
return NULL;
|
||||
|
||||
ma = BKE_gpencil_current_input_material(bmain, ob);
|
||||
ma = BKE_gpencil_object_material_ensure_from_active_input_material(bmain, ob);
|
||||
if (ma->gp_style == NULL) {
|
||||
BKE_material_init_gpencil_settings(ma);
|
||||
}
|
||||
@@ -1662,7 +1662,7 @@ void BKE_gpencil_stats_update(bGPdata *gpd)
|
||||
}
|
||||
|
||||
/* get material index (0-based like mat_nr not actcol) */
|
||||
int BKE_gpencil_get_material_index(Object *ob, Material *ma)
|
||||
int BKE_gpencil_object_material_get_index(Object *ob, Material *ma)
|
||||
{
|
||||
short *totcol = give_totcolp(ob);
|
||||
Material *read_ma = NULL;
|
||||
|
||||
@@ -1355,7 +1355,7 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data, void *vedata, T
|
||||
float obscale = mat4_to_scale(ob->obmat);
|
||||
|
||||
/* use the brush material */
|
||||
Material *ma = BKE_gpencil_get_material_for_brush(ob, brush);
|
||||
Material *ma = BKE_gpencil_object_material_get_from_brush(ob, brush);
|
||||
if (ma != NULL) {
|
||||
gp_style = ma->gp_style;
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ void GPENCIL_cache_init(void *vedata)
|
||||
if (obact && (obact->type == OB_GPENCIL) && (obact->data)) {
|
||||
obact_gpd = (bGPdata *)obact->data;
|
||||
/* use the brush material */
|
||||
Material *ma = BKE_gpencil_get_material_for_brush(obact, brush);
|
||||
Material *ma = BKE_gpencil_object_material_get_from_brush(obact, brush);
|
||||
if (ma != NULL) {
|
||||
gp_style = ma->gp_style;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ static int gpencil_monkey_color(
|
||||
int idx;
|
||||
|
||||
/* create a new one */
|
||||
ma = BKE_gpencil_handle_new_material(bmain, ob, pct->name, &idx);
|
||||
ma = BKE_gpencil_object_material_new(bmain, ob, pct->name, &idx);
|
||||
|
||||
copy_v4_v4(ma->gp_style->stroke_rgba, pct->line);
|
||||
copy_v4_v4(ma->gp_style->fill_rgba, pct->fill);
|
||||
|
||||
@@ -63,7 +63,7 @@ static int gp_stroke_material(
|
||||
int idx;
|
||||
|
||||
/* create a new one */
|
||||
ma = BKE_gpencil_handle_new_material(bmain, ob, pct->name, &idx);
|
||||
ma = BKE_gpencil_object_material_new(bmain, ob, pct->name, &idx);
|
||||
|
||||
copy_v4_v4(ma->gp_style->stroke_rgba, pct->line);
|
||||
copy_v4_v4(ma->gp_style->fill_rgba, pct->fill);
|
||||
|
||||
@@ -1101,7 +1101,7 @@ static void gp_brush_clone_add(bContext *C, tGP_BrushEditData *gso)
|
||||
|
||||
/* Fix color references */
|
||||
Material *ma = BLI_ghash_lookup(data->new_colors, &new_stroke->mat_nr);
|
||||
gps->mat_nr = BKE_gpencil_get_material_index(ob, ma);
|
||||
gps->mat_nr = BKE_gpencil_object_material_get_index(ob, ma);
|
||||
if (!ma || gps->mat_nr) {
|
||||
gps->mat_nr = 0;
|
||||
}
|
||||
|
||||
@@ -521,7 +521,7 @@ static int gp_layer_duplicate_object_exec(bContext *C, wmOperator *op)
|
||||
* otherwise add the slot with the material
|
||||
*/
|
||||
Material *ma_src = give_current_material(ob_src, gps_src->mat_nr + 1);
|
||||
int idx = BKE_gpencil_handle_material(bmain, ob_dst, ma_src);
|
||||
int idx = BKE_gpencil_object_material_ensure(bmain, ob_dst, ma_src);
|
||||
|
||||
/* reasign the stroke material to the right slot in destination object */
|
||||
gps_dst->mat_nr = idx;
|
||||
@@ -1379,7 +1379,7 @@ static int gp_stroke_change_color_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
}
|
||||
/* try to find slot */
|
||||
int idx = BKE_gpencil_get_material_index(ob, ma);
|
||||
int idx = BKE_gpencil_object_material_get_index(ob, ma);
|
||||
if (idx < 0) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
@@ -2054,7 +2054,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
|
||||
|
||||
for (short i = 0; i < *totcol; i++) {
|
||||
Material *tmp_ma = give_current_material(ob_src, i + 1);
|
||||
BKE_gpencil_handle_material(bmain, ob_dst, tmp_ma);
|
||||
BKE_gpencil_object_material_ensure(bmain, ob_dst, tmp_ma);
|
||||
}
|
||||
|
||||
/* duplicate bGPDlayers */
|
||||
@@ -2089,7 +2089,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* reasign material. Look old material and try to find in dst */
|
||||
ma_src = give_current_material(ob_src, gps->mat_nr + 1);
|
||||
gps->mat_nr = BKE_gpencil_handle_material(bmain, ob_dst, ma_src);
|
||||
gps->mat_nr = BKE_gpencil_object_material_ensure(bmain, ob_dst, ma_src);
|
||||
|
||||
bGPDspoint *pt;
|
||||
int i;
|
||||
|
||||
@@ -1080,7 +1080,7 @@ GHash *gp_copybuf_validate_colormap(bContext *C)
|
||||
char *ma_name = BLI_ghashIterator_getValue(&gh_iter);
|
||||
Material *ma = BLI_ghash_lookup(name_to_ma, ma_name);
|
||||
|
||||
BKE_gpencil_handle_material(bmain, ob, ma);
|
||||
BKE_gpencil_object_material_ensure(bmain, ob, ma);
|
||||
|
||||
/* Store this mapping (for use later when pasting) */
|
||||
if (!BLI_ghash_haskey(new_colors, POINTER_FROM_INT(*key))) {
|
||||
@@ -1334,7 +1334,7 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* Remap material */
|
||||
Material *ma = BLI_ghash_lookup(new_colors, POINTER_FROM_INT(new_stroke->mat_nr));
|
||||
new_stroke->mat_nr = BKE_gpencil_get_material_index(ob, ma);
|
||||
new_stroke->mat_nr = BKE_gpencil_object_material_get_index(ob, ma);
|
||||
BLI_assert(new_stroke->mat_nr >= 0); /* have to add the material first */
|
||||
}
|
||||
}
|
||||
@@ -3957,7 +3957,7 @@ static int gp_stroke_separate_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* add duplicate materials */
|
||||
ma = give_current_material(ob, gps->mat_nr + 1); /* XXX same material can be in multiple slots */
|
||||
idx = BKE_gpencil_handle_material(bmain, ob_dst, ma);
|
||||
idx = BKE_gpencil_object_material_ensure(bmain, ob_dst, ma);
|
||||
|
||||
/* selected points mode */
|
||||
if (mode == GP_SEPARATE_POINT) {
|
||||
@@ -4029,7 +4029,7 @@ static int gp_stroke_separate_exec(bContext *C, wmOperator *op)
|
||||
continue;
|
||||
}
|
||||
ma = give_current_material(ob, gps->mat_nr + 1);
|
||||
gps->mat_nr = BKE_gpencil_handle_material(bmain, ob_dst, ma);
|
||||
gps->mat_nr = BKE_gpencil_object_material_ensure(bmain, ob_dst, ma);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1017,7 +1017,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
|
||||
gps->flag |= GP_STROKE_CYCLIC;
|
||||
gps->flag |= GP_STROKE_3DSPACE;
|
||||
|
||||
gps->mat_nr = BKE_gpencil_handle_material(tgpf->bmain, tgpf->ob, tgpf->mat);
|
||||
gps->mat_nr = BKE_gpencil_object_material_ensure(tgpf->bmain, tgpf->ob, tgpf->mat);
|
||||
|
||||
/* allocate memory for storage points */
|
||||
gps->totpoints = tgpf->sbuffer_size;
|
||||
@@ -1222,7 +1222,7 @@ static tGPDfill *gp_session_init_fill(bContext *C, wmOperator *UNUSED(op))
|
||||
int totcol = tgpf->ob->totcol;
|
||||
|
||||
/* get color info */
|
||||
Material *ma = BKE_gpencil_current_input_brush_material(bmain, tgpf->ob, brush);
|
||||
Material *ma = BKE_gpencil_object_material_ensure_from_active_input_brush(bmain, tgpf->ob, brush);
|
||||
|
||||
tgpf->mat = ma;
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ static int gpencil_convert_old_files_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
for (bGPDpalettecolor *palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
|
||||
|
||||
/* create material slot */
|
||||
Material *ma = BKE_gpencil_handle_new_material(bmain, ob, palcolor->info, NULL);
|
||||
Material *ma = BKE_gpencil_object_material_new(bmain, ob, palcolor->info, NULL);
|
||||
|
||||
/* copy color settings */
|
||||
MaterialGPencilStyle *gp_style = ma->gp_style;
|
||||
|
||||
@@ -1223,7 +1223,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
|
||||
}
|
||||
|
||||
/* Save material index */
|
||||
gps->mat_nr = BKE_gpencil_get_material_index_for_brush(p->ob, p->brush);
|
||||
gps->mat_nr = BKE_gpencil_object_material_get_index_from_brush(p->ob, p->brush);
|
||||
|
||||
/* calculate UVs along the stroke */
|
||||
ED_gpencil_calc_stroke_uv(obact, gps);
|
||||
@@ -1832,7 +1832,7 @@ static void gp_init_colors(tGPsdata *p)
|
||||
MaterialGPencilStyle *gp_style = NULL;
|
||||
|
||||
/* use brush material */
|
||||
p->material = BKE_gpencil_current_input_brush_material(p->bmain, p->ob, brush);
|
||||
p->material = BKE_gpencil_object_material_ensure_from_active_input_brush(p->bmain, p->ob, brush);
|
||||
|
||||
/* assign color information to temp tGPsdata */
|
||||
gp_style = p->material->gp_style;
|
||||
|
||||
@@ -140,7 +140,7 @@ static void gp_init_colors(tGPDprimitive *p)
|
||||
MaterialGPencilStyle *gp_style = NULL;
|
||||
|
||||
/* use brush material */
|
||||
p->mat = BKE_gpencil_current_input_brush_material(p->bmain, p->ob, brush);
|
||||
p->mat = BKE_gpencil_object_material_ensure_from_active_input_brush(p->bmain, p->ob, brush);
|
||||
|
||||
/* assign color information to temp data */
|
||||
gp_style = p->mat->gp_style;
|
||||
@@ -331,7 +331,7 @@ static void gp_primitive_set_initdata(bContext *C, tGPDprimitive *tgpi)
|
||||
|
||||
gps->flag |= GP_STROKE_3DSPACE;
|
||||
|
||||
gps->mat_nr = BKE_gpencil_get_material_index(tgpi->ob, tgpi->mat);
|
||||
gps->mat_nr = BKE_gpencil_object_material_get_index(tgpi->ob, tgpi->mat);
|
||||
|
||||
/* allocate memory for storage points, but keep empty */
|
||||
gps->totpoints = 0;
|
||||
@@ -1111,7 +1111,7 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op)
|
||||
tgpi->gpd->runtime.tot_cp_points = 0;
|
||||
|
||||
/* getcolor info */
|
||||
tgpi->mat = BKE_gpencil_current_input_toolsettings_material(bmain, tgpi->ob, ts);
|
||||
tgpi->mat = BKE_gpencil_object_material_ensure_from_active_input_toolsettings(bmain, tgpi->ob, ts);
|
||||
|
||||
/* set parameters */
|
||||
tgpi->type = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
@@ -1332,7 +1332,7 @@ void ED_gpencil_add_defaults(bContext *C, Object *ob)
|
||||
}
|
||||
|
||||
/* ensure a color exists and is assigned to object */
|
||||
BKE_gpencil_current_input_toolsettings_material(bmain, ob, ts);
|
||||
BKE_gpencil_object_material_ensure_from_active_input_toolsettings(bmain, ob, ts);
|
||||
|
||||
/* ensure multiframe falloff curve */
|
||||
if (ts->gp_sculpt.cur_falloff == NULL) {
|
||||
@@ -1701,7 +1701,7 @@ static void gp_brush_cursor_draw(bContext *C, int x, int y, void *customdata)
|
||||
}
|
||||
|
||||
/* get current drawing color */
|
||||
ma = BKE_gpencil_get_material_for_brush(ob, brush);
|
||||
ma = BKE_gpencil_object_material_get_from_brush(ob, brush);
|
||||
|
||||
if (ma) {
|
||||
gp_style = ma->gp_style;
|
||||
|
||||
@@ -188,7 +188,7 @@ void gpencil_apply_modifier_material(
|
||||
DEG_id_tag_update(&newmat->id, ID_RECALC_COPY_ON_WRITE);
|
||||
}
|
||||
/* reasign color index */
|
||||
int idx = BKE_gpencil_get_material_index(ob, newmat);
|
||||
int idx = BKE_gpencil_object_material_get_index(ob, newmat);
|
||||
gps->mat_nr = idx - 1;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -713,10 +713,10 @@ static void rna_BrushGpencilSettings_use_material_pin_update(bContext *C, Pointe
|
||||
|
||||
if (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) {
|
||||
Material *material = give_current_material(ob, ob->actcol);
|
||||
BKE_gpencil_brush_set_material(brush, material);
|
||||
BKE_gpencil_brush_material_set(brush, material);
|
||||
}
|
||||
else {
|
||||
BKE_gpencil_brush_set_material(brush, NULL);
|
||||
BKE_gpencil_brush_material_set(brush, NULL);
|
||||
}
|
||||
|
||||
/* number of material users changed */
|
||||
|
||||
Reference in New Issue
Block a user