From b7f085d9c128f31d576c732c6439b5a71e8922ee Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Sat, 3 May 2014 18:51:53 +0900 Subject: Patch D246: Texture Marks for freestyle strokes, written and contributed by Paolo Acampora. Reviewers: brecht, kjym3, #freestyle Reviewed By: brecht, kjym3 Differential Revision: https://developer.blender.org/D246 --- source/blender/blenkernel/intern/texture.c | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'source/blender/blenkernel/intern/texture.c') diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 75f2fd121dc..3e95da622ac 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -51,6 +51,7 @@ #include "DNA_node_types.h" #include "DNA_color_types.h" #include "DNA_particle_types.h" +#include "DNA_linestyle_types.h" #include "IMB_imbuf.h" @@ -999,6 +1000,41 @@ void set_current_lamp_texture(Lamp *la, Tex *newtex) } } +Tex *give_current_linestyle_texture(FreestyleLineStyle *linestyle) +{ + MTex *mtex = NULL; + Tex *tex = NULL; + + if (linestyle) { + mtex = linestyle->mtex[(int)(linestyle->texact)]; + if (mtex) tex = mtex->tex; + } + + return tex; +} + +void set_current_linestyle_texture(FreestyleLineStyle *linestyle, Tex *newtex) +{ + int act = linestyle->texact; + + if (linestyle->mtex[act] && linestyle->mtex[act]->tex) + id_us_min(&linestyle->mtex[act]->tex->id); + + if (newtex) { + if (!linestyle->mtex[act]) { + linestyle->mtex[act] = add_mtex(); + linestyle->mtex[act]->texco = TEXCO_STROKE; + } + + linestyle->mtex[act]->tex = newtex; + id_us_plus(&newtex->id); + } + else if (linestyle->mtex[act]) { + MEM_freeN(linestyle->mtex[act]); + linestyle->mtex[act] = NULL; + } +} + bNode *give_current_material_texture_node(Material *ma) { if (ma && ma->use_nodes && ma->nodetree) @@ -1048,6 +1084,10 @@ bool give_active_mtex(ID *id, MTex ***mtex_ar, short *act) *mtex_ar = ((Lamp *)id)->mtex; if (act) *act = (((Lamp *)id)->texact); break; + case ID_LS: + *mtex_ar = ((FreestyleLineStyle *)id)->mtex; + if (act) *act = (((FreestyleLineStyle *)id)->texact); + break; case ID_PA: *mtex_ar = ((ParticleSettings *)id)->mtex; if (act) *act = (((ParticleSettings *)id)->texact); @@ -1076,6 +1116,9 @@ void set_active_mtex(ID *id, short act) case ID_LA: ((Lamp *)id)->texact = act; break; + case ID_LS: + ((FreestyleLineStyle *)id)->texact = act; + break; case ID_PA: ((ParticleSettings *)id)->texact = act; break; -- cgit v1.2.3