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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-07-31 16:43:41 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-07-31 16:43:41 +0400
commitc74bb09584371520b9b557cbaa8ae13356bf5e1a (patch)
tree1ab1a63110148b10a4a2808e17078075f71eaf66 /source
parent5b3bb373432d5b0b9c4ab1135a6f344831cb83a9 (diff)
fix for material slot removal (r38879)
- The object ID was being passed to the data_delete_material_index_id() from object_remove_material_slot(), rather then the object data. (so the material slot fix wouldnt run in that case). - add support for fixing text object materials too.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_curve.h1
-rw-r--r--source/blender/blenkernel/intern/curve.c25
-rw-r--r--source/blender/blenkernel/intern/material.c30
-rw-r--r--source/blender/makesrna/intern/rna_ID.c5
4 files changed, 36 insertions, 25 deletions
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index 0491116d199..557ce417b14 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -115,5 +115,6 @@ int minmax_curve(struct Curve *cu, float min[3], float max[3]);
int curve_center_median(struct Curve *cu, float cent[3]);
int curve_center_bounds(struct Curve *cu, float cent[3]);
void curve_translate(struct Curve *cu, float offset[3], int do_keys);
+void curve_delete_material_index(struct Curve *cu, int index);
#endif
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 202a3f28d9a..66ab11938f3 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -3259,3 +3259,28 @@ void curve_translate(Curve *cu, float offset[3], int do_keys)
}
}
}
+
+void curve_delete_material_index(Curve *cu, int index)
+{
+ const int curvetype= curve_type(cu);
+
+ if(curvetype == OB_FONT) {
+ struct CharInfo *info= cu->strinfo;
+ int i;
+ for(i= cu->len-1; i >= 0; i--, info++) {
+ if (info->mat_nr && info->mat_nr>=index) {
+ info->mat_nr--;
+ }
+ }
+ }
+ else {
+ Nurb *nu;
+
+ for (nu= cu->nurb.first; nu; nu= nu->next) {
+ if(nu->mat_nr && nu->mat_nr>=index) {
+ nu->mat_nr--;
+ if (curvetype == OB_CURVE) nu->charidx--;
+ }
+ }
+ }
+}
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 1f2544c9706..9c455e84109 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -517,31 +517,15 @@ short *give_totcolp_id(ID *id)
void data_delete_material_index_id(ID *id, int index)
{
- Mesh *me;
- Curve *cu;
- Nurb *nu;
- int curvetype;
-
switch(GS(id->name)) {
case ID_ME:
- me=(Mesh *)id;
- mesh_delete_material_index(me, index);
+ mesh_delete_material_index((Mesh *)id, index);
break;
case ID_CU:
- cu= (Curve *)id;
- nu= cu->nurb.first;
-
- curvetype=curve_type(cu);
- if (!ELEM(curvetype, OB_CURVE, OB_SURF))
- return;
-
- while (nu) {
- if(nu->mat_nr && nu->mat_nr>=index) {
- nu->mat_nr--;
- if (curvetype == OB_CURVE) nu->charidx--;
- }
- nu= nu->next;
- }
+ curve_delete_material_index((Curve *)id, index);
+ break;
+ case ID_MB:
+ /* meta-elems dont have materials atm */
break;
}
}
@@ -1124,8 +1108,8 @@ int object_remove_material_slot(Object *ob)
}
/* check indices from mesh */
- if (ELEM3(ob->type, OB_MESH, OB_CURVE, OB_SURF)) {
- data_delete_material_index_id(&ob->id, actcol-1);
+ if (ELEM4(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT)) {
+ data_delete_material_index_id((ID *)ob->data, actcol-1);
freedisplist(&ob->disp);
}
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 6d7fc0ee57b..8d57403ec35 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -35,6 +35,7 @@
#include "DNA_ID.h"
#include "DNA_vfont_types.h"
+#include "DNA_material_types.h"
#include "DNA_object_types.h"
#include "WM_types.h"
@@ -416,9 +417,9 @@ static void rna_def_ID_materials(BlenderRNA *brna)
func= RNA_def_function(srna, "pop", "material_pop_id");
RNA_def_function_ui_description(func, "Remove a material from the data block.");
- parm= RNA_def_int(func, "index", 0, 0, INT_MAX, "", "Index of material to remove.", 0, INT_MAX);
+ parm= RNA_def_int(func, "index", 0, 0, MAXMAT, "", "Index of material to remove.", 0, MAXMAT);
RNA_def_property_flag(parm, PROP_REQUIRED);
- RNA_def_boolean(func, "remove_material_slot", 1, "", "Remove the material slot and assign 1st material to old faces.");
+ RNA_def_boolean(func, "update_data", 0, "", "Update data by re-adjusting the material slots assigned.");
parm= RNA_def_pointer(func, "material", "Material", "", "Material to remove.");
RNA_def_function_return(func, parm);
}