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:
-rw-r--r--source/blender/blenkernel/BKE_material.h3
-rw-r--r--source/blender/blenkernel/intern/material.c20
-rw-r--r--source/blender/include/butspace.h2
-rw-r--r--source/blender/src/buttons_editing.c58
4 files changed, 70 insertions, 13 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;
diff --git a/source/blender/include/butspace.h b/source/blender/include/butspace.h
index eb756fd932e..debac14f63e 100644
--- a/source/blender/include/butspace.h
+++ b/source/blender/include/butspace.h
@@ -370,6 +370,7 @@ void curvemap_buttons(struct uiBlock *block, struct CurveMapping *cumap, char la
#define B_DOCENTER 2015
#define B_DOCENTERNEW 2016
#define B_DOCENTERCURSOR 2017
+#define B_MATASS_BROWSE 2018
/* 20 values! */
#define B_OBLAY 2019
@@ -381,6 +382,7 @@ void curvemap_buttons(struct uiBlock *block, struct CurveMapping *cumap, char la
#define B_PREVKEY 2045
#define B_NEXTKEY 2046
#define B_LOCKKEY 2047
+#define B_MATCOL2 2048
#define B_MESHBUTS 2090
diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c
index f356c97c987..7dfd6a956cd 100644
--- a/source/blender/src/buttons_editing.c
+++ b/source/blender/src/buttons_editing.c
@@ -141,6 +141,7 @@
#include "BKE_DerivedMesh.h"
#include "BKE_effect.h"
#include "BKE_font.h"
+#include "BKE_icons.h"
#include "BKE_image.h"
#include "BKE_ipo.h"
#include "BKE_lattice.h"
@@ -388,6 +389,7 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
EditFace *efa;
Base *base;
Object *ob= OBACT;
+ Material *ma;
Nurb *nu;
Curve *cu;
BezTriple *bezt;
@@ -400,8 +402,7 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
case B_MATWICH:
if(G.obedit && G.obedit->actcol>0) {
if(G.obedit->type == OB_MESH) {
- efa= em->faces.first;
- while(efa) {
+ for(efa= em->faces.first; efa; efa= efa->next) {
if(efa->f & SELECT) {
if(index== -1) index= efa->mat_nr;
else if(index!=efa->mat_nr) {
@@ -476,6 +477,30 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
BIF_undo_push("Assign material index");
}
break;
+ case B_MATASS_BROWSE:
+ /* if slot available, make that index active, and assign */
+ /* else, make new slot, and assign */
+ ma= BLI_findlink(&G.main->mat, G.buts->menunr-1);
+ if(ma) {
+ ob->actcol= find_material_index(ob, ma);
+ if(ob->actcol==0) {
+ assign_material(ob, ma, ob->totcol);
+ ob->actcol= ob->totcol;
+ }
+ }
+ else {
+ do_common_editbuts(B_MATNEW);
+ }
+ do_common_editbuts(B_MATASS);
+ break;
+
+ case B_MATCOL2:
+ ma= give_current_material(ob, ob->actcol);
+ BKE_icon_changed(BKE_icon_getid((ID *)ma));
+ allqueue(REDRAWVIEW3D, 0);
+ allqueue(REDRAWBUTSEDIT, 0);
+ break;
+
case B_MATSEL:
case B_MATDESEL:
if(G.obedit) {
@@ -4904,23 +4929,30 @@ static void editing_panel_links(Object *ob)
if(ob->totcol) min= 1.0; else min= 0.0;
ma= give_current_material(ob, ob->actcol);
- if(ma) uiDefBut(block, LABEL, 0, ma->id.name+2, 318,153, 103, 20, 0, 0, 0, 0, 0, "");
+ if(G.obedit) {
+ char *str= NULL;
+ IDnames_to_pupstring(&str, NULL, "ADD NEW %x 32767", &G.main->mat, NULL, NULL);
+ uiDefButS(block, MENU, B_MATASS_BROWSE, str, 292,150,20,20, &G.buts->menunr, 0, 0, 0, 0, "Browses existing choices and assign");
+ MEM_freeN(str);
+ }
+
+ if(ma) uiDefBut(block, LABEL, 0, ma->id.name+2, 318,150, 103, 20, 0, 0, 0, 0, 0, "");
uiBlockBeginAlign(block);
- if(ma) uiDefButF(block, COL, B_REDR, "", 292,123,31,30, &(ma->r), 0, 0, 0, 0, "");
- uiDefButC(block, NUM, B_ACTCOL, str, 324,123,100,30, &ob->actcol, min, (float)(ob->totcol), 0, 0, "Displays total number of material indices and the current index");
- uiDefBut(block, BUT,B_MATWICH, "?", 424,123,30,30, 0, 0, 0, 0, 0, "In EditMode, sets the active material index from selected faces");
+ if(ma) uiDefButF(block, COL, B_MATCOL2, "", 292,113,31,30, &(ma->r), 0, 0, 0, 0, "");
+ uiDefButC(block, NUM, B_ACTCOL, str, 324,113,100,30, &ob->actcol, min, (float)(ob->totcol), 0, 0, "Displays total number of material indices and the current index");
+ uiDefBut(block, BUT,B_MATWICH, "?", 424,113,30,30, 0, 0, 0, 0, 0, "In EditMode, sets the active material index from selected faces");
uiBlockBeginAlign(block);
- uiDefBut(block, BUT,B_MATNEW, "New", 292,98,80,20, 0, 0, 0, 0, 0, "Adds a new Material index");
- uiDefBut(block, BUT,B_MATDEL, "Delete", 374,98,80,20, 0, 0, 0, 0, 0, "Deletes this Material index");
- uiDefBut(block, BUT,B_MATSEL, "Select", 292,76,80,20, 0, 0, 0, 0, 0, "In EditMode, selects faces that have the active index");
- uiDefBut(block, BUT,B_MATDESEL, "Deselect", 374,76,80,20, 0, 0, 0, 0, 0, "Deselects everything with current indexnumber");
- uiDefBut(block, BUT,B_MATASS, "Assign", 292,47,162,26, 0, 0, 0, 0, 0, "In EditMode, assigns the active index to selected faces");
+ uiDefBut(block, BUT,B_MATNEW, "New", 292,90,80,20, 0, 0, 0, 0, 0, "Adds a new Material index");
+ uiDefBut(block, BUT,B_MATDEL, "Delete", 372,90,80,20, 0, 0, 0, 0, 0, "Deletes this Material index");
+ uiDefBut(block, BUT,B_MATSEL, "Select", 292,70,80,20, 0, 0, 0, 0, 0, "In EditMode, selects faces that have the active index");
+ uiDefBut(block, BUT,B_MATDESEL, "Deselect", 372,70,80,20, 0, 0, 0, 0, 0, "Deselects everything with current indexnumber");
+ uiDefBut(block, BUT,B_MATASS, "Assign", 292,50,160,20, 0, 0, 0, 0, 0, "In EditMode, assigns the active index to selected faces");
uiBlockBeginAlign(block);
- uiDefBut(block, BUT,B_SETSMOOTH,"Set Smooth", 291,15,80,20, 0, 0, 0, 0, 0, "In EditMode, sets 'smooth' rendering of selected faces");
- uiDefBut(block, BUT,B_SETSOLID, "Set Solid", 373,15,80,20, 0, 0, 0, 0, 0, "In EditMode, sets 'solid' rendering of selected faces");
+ uiDefBut(block, BUT,B_SETSMOOTH,"Set Smooth", 292,15,80,20, 0, 0, 0, 0, 0, "In EditMode, sets 'smooth' rendering of selected faces");
+ uiDefBut(block, BUT,B_SETSOLID, "Set Solid", 372,15,80,20, 0, 0, 0, 0, 0, "In EditMode, sets 'solid' rendering of selected faces");
uiBlockEndAlign(block);