From c74bb09584371520b9b557cbaa8ae13356bf5e1a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 31 Jul 2011 12:43:41 +0000 Subject: 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. --- source/blender/blenkernel/intern/curve.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source/blender/blenkernel/intern/curve.c') 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--; + } + } + } +} -- cgit v1.2.3