Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/material.c')
-rw-r--r--source/blender/blenkernel/intern/material.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 1545ae4f48f..cc9be2c5dda 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -71,6 +71,7 @@
/* used in UI and render */
Material defmaterial;
+Material defgpencil_material;
static CLG_LogRef LOG = {"bke.material"};
@@ -78,6 +79,13 @@ static CLG_LogRef LOG = {"bke.material"};
void init_def_material(void)
{
BKE_material_init(&defmaterial);
+ BKE_material_gpencil_init(&defgpencil_material);
+}
+
+/* Free the GPencil data of the deafult material, creator.c */
+void BKE_material_gpencil_default_free(void)
+{
+ MEM_SAFE_FREE(defgpencil_material.gp_style);
}
/** Free (or release) any data used by this material (does not free the material itself). */
@@ -144,6 +152,16 @@ void BKE_material_init(Material *ma)
ma->blend_shadow = MA_BS_SOLID;
}
+void BKE_material_gpencil_init(Material *ma)
+{
+ BKE_material_init(ma);
+
+ /* grease pencil settings */
+ strcpy(ma->id.name, "MADefault GPencil");
+ BKE_material_init_gpencil_settings(ma);
+ add_v3_fl(&ma->gp_style->stroke_rgba[0], 0.6f);
+}
+
Material *BKE_material_add(Main *bmain, const char *name)
{
Material *ma;
@@ -580,6 +598,17 @@ Material *give_current_material(Object *ob, short act)
return ma_p ? *ma_p : NULL;
}
+Material *BKE_material_gpencil_get(Object *ob, short act)
+{
+ Material *ma = give_current_material(ob, act);
+ if (ma != NULL) {
+ return ma;
+ }
+ else {
+ return &defgpencil_material;
+ }
+}
+
MaterialGPencilStyle *BKE_material_gpencil_settings_get(Object *ob, short act)
{
Material *ma = give_current_material(ob, act);
@@ -591,7 +620,7 @@ MaterialGPencilStyle *BKE_material_gpencil_settings_get(Object *ob, short act)
return ma->gp_style;
}
else {
- return NULL;
+ return defgpencil_material.gp_style;
}
}
@@ -1070,10 +1099,6 @@ bool BKE_object_material_slot_remove(Main *bmain, Object *ob)
}
/* check indices from gpencil */
else if (ob->type == OB_GPENCIL) {
- /* need one color */
- if (ob->totcol == 0) {
- BKE_gpencil_object_material_ensure_from_active_input_material(bmain, ob);
- }
BKE_gpencil_material_index_reassign((bGPdata *)ob->data, ob->totcol, actcol - 1);
}