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:
authorTon Roosendaal <ton@blender.org>2007-11-28 21:43:09 +0300
committerTon Roosendaal <ton@blender.org>2007-11-28 21:43:09 +0300
commitce52384e9f7d5dee531edf50b76a9edbe982863b (patch)
treef815dd17dfb23d205c073f3d79ee464cd3d0871c /source/blender/blenkernel
parentd6ce9e4abe54e3901c963a2d63abd1195a21dd33 (diff)
Small material assigning feature:
in EditButtons, panel "Links and Materials", there's now a browse button to directly assign a material to selected faces. It does: - check if material was already in one of the 'slots' of the object - if so, then use this as index to assign - if not, then add a new slot, and assign the new index
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_material.h3
-rw-r--r--source/blender/blenkernel/intern/material.c20
2 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h
index 2add4b95080..0c93e4e32a2 100644
--- a/source/blender/blenkernel/BKE_material.h
+++ b/source/blender/blenkernel/BKE_material.h
@@ -57,6 +57,9 @@ struct ID *material_from(struct Object *ob, int act);
void assign_material(struct Object *ob, struct Material *ma, int act);
void new_material_to_objectdata(struct Object *ob);
+int find_material_index(struct Object *ob, struct Material *ma);
+
+
void init_render_material(struct Material *, int, float *);
void init_render_materials(int, float *);
void end_render_material(struct Material *);
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 49d3021090e..ed5fe58d06f 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -581,6 +581,26 @@ void assign_material(Object *ob, Material *ma, int act)
test_object_materials(ob->data);
}
+int find_material_index(Object *ob, Material *ma)
+{
+ Material ***matarar;
+ short a, *totcolp;
+
+ if(ma==NULL) return 0;
+
+ totcolp= give_totcolp(ob);
+ matarar= give_matarar(ob);
+
+ if(totcolp==NULL || matarar==NULL) return 0;
+
+ for(a=0; a<*totcolp; a++)
+ if((*matarar)[a]==ma)
+ break;
+ if(a<*totcolp)
+ return a+1;
+ return 0;
+}
+
void new_material_to_objectdata(Object *ob)
{
Material *ma;