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-09 13:50:49 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-10-09 13:50:49 +0400
commit2226a5139a2ad78d4de2eaaf09e734adf1ce0ae4 (patch)
tree788e76978dcc715819544c2a3abce5636ed1d6e5 /source/blender/blenkernel/intern/texture.c
parent9ebcd9c5e46c8addd80c8adb97fcee91a1916d57 (diff)
Fix some issues with showing the current textures when using
material nodes and texture nodes. Made it all use the same give_current_*_texture functions now.
Diffstat (limited to 'source/blender/blenkernel/intern/texture.c')
-rw-r--r--source/blender/blenkernel/intern/texture.c102
1 files changed, 60 insertions, 42 deletions
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 3b8ae9a6c7f..f09abf93bb8 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -809,72 +809,90 @@ void autotexname(Tex *tex)
/* ------------------------------------------------------------------------- */
-Tex *give_current_texture(Object *ob, int act)
+Tex *give_current_object_texture(Object *ob)
{
- Material ***matarar, *ma;
- Lamp *la = 0;
- MTex *mtex = 0;
- Tex *tex = 0;
- bNode *node;
+ Material *ma;
+ Tex *tex= NULL;
if(ob==0) return 0;
if(ob->totcol==0 && !(ob->type==OB_LAMP)) return 0;
if(ob->type==OB_LAMP) {
- la=(Lamp *)ob->data;
- if(la) {
- mtex= la->mtex[(int)(la->texact)];
- if(mtex) tex= mtex->tex;
- }
+ tex= give_current_lamp_texture(ob->data);
} else {
- if(act>ob->totcol) act= ob->totcol;
- else if(act==0) act= 1;
-
- if(ob->matbits[act-1]) { /* in object */
- ma= ob->mat[act-1];
- }
- else { /* in data */
- matarar= give_matarar(ob);
-
- if(matarar && *matarar) ma= (*matarar)[act-1];
- else ma= 0;
- }
+ ma= give_current_material(ob, ob->actcol);
+ tex= give_current_material_texture(ma);
+ }
+
+ return tex;
+}
- if(ma && ma->use_nodes && ma->nodetree) {
- node= nodeGetActiveID(ma->nodetree, ID_TE);
+Tex *give_current_lamp_texture(Lamp *la)
+{
+ MTex *mtex= NULL;
+ Tex *tex= NULL;
- if(node) {
- tex= (Tex *)node->id;
- ma= NULL;
- }
- else {
- node= nodeGetActiveID(ma->nodetree, ID_MA);
- if(node)
- ma= (Material*)node->id;
- }
+ if(la) {
+ mtex= la->mtex[(int)(la->texact)];
+ if(mtex) tex= mtex->tex;
+ }
+
+ return tex;
+}
+
+Tex *give_current_material_texture(Material *ma)
+{
+ MTex *mtex= NULL;
+ Tex *tex= NULL;
+ bNode *node;
+
+ if(ma && ma->use_nodes && ma->nodetree) {
+ node= nodeGetActiveID(ma->nodetree, ID_TE);
+
+ if(node) {
+ tex= (Tex *)node->id;
+ ma= NULL;
}
- if(ma) {
- mtex= ma->mtex[(int)(ma->texact)];
- if(mtex) tex= mtex->tex;
+ else {
+ node= nodeGetActiveID(ma->nodetree, ID_MA);
+ if(node)
+ ma= (Material*)node->id;
}
}
+ if(ma) {
+ mtex= ma->mtex[(int)(ma->texact)];
+ if(mtex) tex= mtex->tex;
+ }
return tex;
}
-Tex *give_current_world_texture(Scene *scene)
+Tex *give_current_world_texture(World *world)
{
- MTex *mtex = 0;
- Tex *tex = 0;
+ MTex *mtex= NULL;
+ Tex *tex= NULL;
- if(!(scene->world)) return 0;
+ if(!world) return 0;
- mtex= scene->world->mtex[(int)(scene->world->texact)];
+ mtex= world->mtex[(int)(world->texact)];
if(mtex) tex= mtex->tex;
return tex;
}
+Tex *give_current_brush_texture(Brush *br)
+{
+ MTex *mtex= NULL;
+ Tex *tex= NULL;
+
+ if(br) {
+ mtex= br->mtex[(int)(br->texact)];
+ if(mtex) tex= mtex->tex;
+ }
+
+ return tex;
+}
+
/* ------------------------------------------------------------------------- */
EnvMap *BKE_add_envmap(void)