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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-10-12 17:12:45 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-10-12 17:12:45 +0400
commitf1a0df22df7b929601db58db5ecb77ed82bf8361 (patch)
tree106260cd3e3753debf685a0434078a3a3f1cf238 /source/blender/blenkernel/intern/texture.c
parente36003e8e73e42e7b559d4cec19b9004d14fefa6 (diff)
Bugfix: texture nodes header was still showing wrong texture
when using node materials.
Diffstat (limited to 'source/blender/blenkernel/intern/texture.c')
-rw-r--r--source/blender/blenkernel/intern/texture.c105
1 files changed, 105 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index f09abf93bb8..d1c26b5a1b4 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -840,6 +840,28 @@ Tex *give_current_lamp_texture(Lamp *la)
return tex;
}
+void set_current_lamp_texture(Lamp *la, Tex *newtex)
+{
+ int act= la->texact;
+
+ if(la->mtex[act] && la->mtex[act]->tex)
+ id_us_min(&la->mtex[act]->tex->id);
+
+ if(newtex) {
+ if(!la->mtex[act]) {
+ la->mtex[act]= add_mtex();
+ la->mtex[act]->texco= TEXCO_GLOB;
+ }
+
+ la->mtex[act]->tex= newtex;
+ id_us_plus(&newtex->id);
+ }
+ else if(la->mtex[act]) {
+ MEM_freeN(la->mtex[act]);
+ la->mtex[act]= NULL;
+ }
+}
+
Tex *give_current_material_texture(Material *ma)
{
MTex *mtex= NULL;
@@ -867,6 +889,47 @@ Tex *give_current_material_texture(Material *ma)
return tex;
}
+void set_current_material_texture(Material *ma, Tex *newtex)
+{
+ Tex *tex= NULL;
+ bNode *node;
+
+ if(ma && ma->use_nodes && ma->nodetree) {
+ node= nodeGetActiveID(ma->nodetree, ID_TE);
+
+ if(node) {
+ tex= (Tex *)node->id;
+ id_us_min(&tex->id);
+ node->id= &newtex->id;
+ id_us_plus(&newtex->id);
+ ma= NULL;
+ }
+ else {
+ node= nodeGetActiveID(ma->nodetree, ID_MA);
+ if(node)
+ ma= (Material*)node->id;
+ }
+ }
+ if(ma) {
+ int act= (int)ma->texact;
+
+ tex= (ma->mtex[act])? ma->mtex[act]->tex: NULL;
+ id_us_min(&tex->id);
+
+ if(newtex) {
+ if(!ma->mtex[act])
+ ma->mtex[act]= add_mtex();
+
+ ma->mtex[act]->tex= newtex;
+ id_us_plus(&newtex->id);
+ }
+ else if(ma->mtex[act]) {
+ MEM_freeN(ma->mtex[act]);
+ ma->mtex[act]= NULL;
+ }
+ }
+}
+
Tex *give_current_world_texture(World *world)
{
MTex *mtex= NULL;
@@ -880,6 +943,28 @@ Tex *give_current_world_texture(World *world)
return tex;
}
+void set_current_world_texture(World *wo, Tex *newtex)
+{
+ int act= wo->texact;
+
+ if(wo->mtex[act] && wo->mtex[act]->tex)
+ id_us_min(&wo->mtex[act]->tex->id);
+
+ if(newtex) {
+ if(!wo->mtex[act]) {
+ wo->mtex[act]= add_mtex();
+ wo->mtex[act]->texco= TEXCO_VIEW;
+ }
+
+ wo->mtex[act]->tex= newtex;
+ id_us_plus(&newtex->id);
+ }
+ else if(wo->mtex[act]) {
+ MEM_freeN(wo->mtex[act]);
+ wo->mtex[act]= NULL;
+ }
+}
+
Tex *give_current_brush_texture(Brush *br)
{
MTex *mtex= NULL;
@@ -893,6 +978,26 @@ Tex *give_current_brush_texture(Brush *br)
return tex;
}
+void set_current_brush_texture(Brush *br, Tex *newtex)
+{
+ int act= br->texact;
+
+ if(br->mtex[act] && br->mtex[act]->tex)
+ id_us_min(&br->mtex[act]->tex->id);
+
+ if(newtex) {
+ if(!br->mtex[act])
+ br->mtex[act]= add_mtex();
+
+ br->mtex[act]->tex= newtex;
+ id_us_plus(&newtex->id);
+ }
+ else if(br->mtex[act]) {
+ MEM_freeN(br->mtex[act]);
+ br->mtex[act]= NULL;
+ }
+}
+
/* ------------------------------------------------------------------------- */
EnvMap *BKE_add_envmap(void)