[Bf-blender-cvs] [792bd2a9f13] greasepencil-object: WIP: More work in the huge material refactor
Antonio Vazquez
noreply at git.blender.org
Thu Apr 26 12:35:58 CEST 2018
Commit: 792bd2a9f13091d80e19d8add979ff1cf3ed8864
Author: Antonio Vazquez
Date: Thu Apr 26 11:33:37 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rB792bd2a9f13091d80e19d8add979ff1cf3ed8864
WIP: More work in the huge material refactor
The Monkey primitive, colorpicker and basic color handle operators working.
Still a big problem with save/load that produces a segment fault with any undo operation.
===================================================================
M release/scripts/startup/bl_ui/properties_material_gpencil.py
M source/blender/blenkernel/intern/gpencil.c
M source/blender/blenloader/intern/readfile.c
M source/blender/editors/gpencil/gpencil_add_monkey.c
M source/blender/editors/gpencil/gpencil_colorpick.c
M source/blender/editors/gpencil/gpencil_data.c
M source/blender/editors/gpencil/gpencil_utils.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_material_gpencil.py b/release/scripts/startup/bl_ui/properties_material_gpencil.py
index 55ba2246532..7e6fc1f52ad 100644
--- a/release/scripts/startup/bl_ui/properties_material_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_material_gpencil.py
@@ -63,7 +63,7 @@ class MATERIAL_PT_gpencil_slots(Panel):
@classmethod
def poll(cls, context):
- return context.object and context.object.type == 'GPENCIL' and context.object.active_material
+ return context.object and context.object.type == 'GPENCIL'
@staticmethod
def draw(self, context):
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index f4d5fc05a08..dd9b83c3640 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -1059,7 +1059,7 @@ Material *BKE_gpencil_color_ensure(Main *bmain, Object *ob)
assign_material(ob, ma, ob->totcol, BKE_MAT_ASSIGN_EXISTING);
}
else {
- mat = give_current_material(ob, ob->actcol + 1);
+ mat = give_current_material(ob, ob->actcol);
}
return mat;
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 8cfc8d6a976..0b7b09bf18a 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -4110,6 +4110,7 @@ static void lib_link_material(FileData *fd, Main *main)
}
/* relink grease pencil settings */
+ ma->gpcolor = newdataadr(fd, ma->gpcolor);
if (ma->gpcolor != NULL) {
GpencilColorData *gpcolor = ma->gpcolor;
if (gpcolor->sima != NULL) {
@@ -6334,7 +6335,6 @@ static void direct_link_gpencil(FileData *fd, bGPdata *gpd)
bGPDframe *gpf;
bGPDstroke *gps;
bGPDspoint *pt;
- bGPDpalette *palette;
/* we must firstly have some grease-pencil data to link! */
if (gpd == NULL)
@@ -9389,9 +9389,6 @@ static void expand_material(FileData *fd, Main *mainvar, Material *ma)
if (ma->nodetree)
expand_nodetree(fd, mainvar, ma->nodetree);
- if (ma->gpcolor)
- expand_doit(fd, mainvar, ma->gpcolor);
-
}
static void expand_lamp(FileData *fd, Main *mainvar, Lamp *la)
diff --git a/source/blender/editors/gpencil/gpencil_add_monkey.c b/source/blender/editors/gpencil/gpencil_add_monkey.c
index ba8f3bbce60..60746070ea8 100644
--- a/source/blender/editors/gpencil/gpencil_add_monkey.c
+++ b/source/blender/editors/gpencil/gpencil_add_monkey.c
@@ -50,12 +50,12 @@ typedef struct ColorTemplate {
} ColorTemplate;
/* Add color an ensure duplications (matched by name) */
-static int gpencil_monkey_color(Main *bmain, Object *ob, ColorTemplate *pct)
+static int gpencil_monkey_color(Main *bmain, Object *ob, const ColorTemplate *pct)
{
Material *ma = NULL;
Material ***matar = give_matarar(ob);
short *totcol = give_totcolp(ob);
- for (int i = 0; i < totcol; i++) {
+ for (short i = 0; i < *totcol; i++) {
ma = (*matar)[i];
if (STREQ(ma->id.name, pct->name)) {
return i;
diff --git a/source/blender/editors/gpencil/gpencil_colorpick.c b/source/blender/editors/gpencil/gpencil_colorpick.c
index 095671ee11c..5fd9a9f07f2 100644
--- a/source/blender/editors/gpencil/gpencil_colorpick.c
+++ b/source/blender/editors/gpencil/gpencil_colorpick.c
@@ -319,10 +319,11 @@ static tGPDpick *gpencil_colorpick_init(bContext *C, wmOperator *op, const wmEve
ED_region_visible_rect(tgpk->ar, &tgpk->rect);
/* get current material */
- tgpk->mat = give_current_material(tgpk->ob, tgpk->ob->actcol + 1);
+ tgpk->mat = give_current_material(tgpk->ob, tgpk->ob->actcol);
/* allocate color table */
- tgpk->totcolor = give_totcolp(tgpk->ob);
+ short *totcolp = give_totcolp(tgpk->ob);
+ tgpk->totcolor = *totcolp;
tgpk->curindex = tgpk->ob->actcol - 1;
if (tgpk->totcolor > 0) {
tgpk->colors = MEM_callocN(sizeof(tGPDpickColor) * tgpk->totcolor, "gp_colorpicker");
@@ -387,7 +388,7 @@ static tGPDpick *gpencil_colorpick_init(bContext *C, wmOperator *op, const wmEve
int t = 0;
Material ***matar = give_matarar(tgpk->ob);
short *totcol = give_totcolp(tgpk->ob);
- for (int i = 0; i < totcol; i++) {
+ for (short i = 0; i < *totcol; i++) {
Material *tmp = (*matar)[i];
GpencilColorData *gpcolor = tmp->gpcolor;
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index d6596037913..591fa6bd788 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -1087,7 +1087,7 @@ static int gp_stroke_change_color_exec(bContext *C, wmOperator *UNUSED(op))
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
Object *ob = CTX_data_active_object(C);
- Material *mat = give_current_material(ob, ob->actcol + 1);
+ Material *mat = give_current_material(ob, ob->actcol);
int idx = BKE_object_material_slot_find_index(ob, mat) - 1;
/* sanity checks */
@@ -2046,8 +2046,8 @@ static int gpencil_color_isolate_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
Object *ob = CTX_data_active_object(C);
- Material *active_mat = give_current_material(ob, ob->actcol + 1);
- GpencilColorData *active_color = BKE_material_gpencil_settings_get(ob, ob->actcol + 1);
+ Material *active_mat = give_current_material(ob, ob->actcol);
+ GpencilColorData *active_color = BKE_material_gpencil_settings_get(ob, ob->actcol);
GpencilColorData *gpcolor;
int flags = GPC_COLOR_LOCKED;
@@ -2133,7 +2133,7 @@ void GPENCIL_OT_color_isolate(wmOperatorType *ot)
static int gpencil_color_hide_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
- GpencilColorData *active_color = BKE_material_gpencil_settings_get(ob, ob->actcol + 1);
+ GpencilColorData *active_color = BKE_material_gpencil_settings_get(ob, ob->actcol);
bool unselected = RNA_boolean_get(op->ptr, "unselected");
@@ -2244,7 +2244,7 @@ static int gpencil_color_lock_all_exec(bContext *C, wmOperator *UNUSED(op))
for (short i = 0; i < *totcol; i++) {
mat = (*matar)[i];
gpcolor = mat->gpcolor;
- gpcolor->flag &= ~GPC_COLOR_LOCKED;
+ gpcolor->flag |= GPC_COLOR_LOCKED;
}
/* notifiers */
@@ -2317,7 +2317,7 @@ static int gpencil_color_select_exec(bContext *C, wmOperator *UNUSED(op))
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
Object *ob = CTX_data_active_object(C);
- GpencilColorData *gpcolor = BKE_material_gpencil_settings_get(ob, ob->actcol + 1);
+ GpencilColorData *gpcolor = BKE_material_gpencil_settings_get(ob, ob->actcol);
/* sanity checks */
if (ELEM(NULL, gpd, gpcolor))
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 3c3f2266ac0..33055c39042 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -1132,7 +1132,7 @@ void ED_gpencil_add_defaults(bContext *C)
bGPdata *gpd = CTX_data_gpencil_data(C);
/* ensure color exist */
- BKE_gpencil_color_ensure(bmain, ob);
+ //BKE_gpencil_color_ensure(bmain, ob);
Paint *paint = BKE_brush_get_gpencil_paint(ts);
/* if not exist, create a new one */
More information about the Bf-blender-cvs
mailing list