diff options
author | Ton Roosendaal <ton@blender.org> | 2006-04-08 19:58:49 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2006-04-08 19:58:49 +0400 |
commit | 1e0037045d71623c24796e5cf7781a5e401c25d0 (patch) | |
tree | a49b1f8b0f888ca6c849454c0a0a89410107330e | |
parent | f27870096b57e41635813d86dd9c222e0e6d1b6b (diff) |
Bugfix #3961
When using CTRL+L for materials, you can end up with non-existing material
indices in faces. The drawing code then was still happily drawing the old
situation (or something random, its a static array).
This commit checks the maximum amount of materials on an object, and draws
the last available material for a non-existing index. It uses an ugly
global yes, but this code is bad anyway. :)
-rw-r--r-- | source/blender/src/drawobject.c | 5 | ||||
-rw-r--r-- | source/blender/src/editobject.c | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index 88fe4dacf91..b78dca9227c 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -132,12 +132,16 @@ static void draw_bounding_volume(Object *ob); // Materials start counting at # one.... #define MAXMATBUF (MAXMAT + 1) static float matbuf[MAXMATBUF][2][4]; +static int totmat_gl= 0; static int set_gl_material(int nr) { static int last_gl_matnr= -1; static int last_ret_val= 1; + /* prevent index to use un-initialized array items */ + if(nr>totmat_gl) nr= totmat_gl; + if(nr<0) { last_gl_matnr= -1; last_ret_val= 1; @@ -215,6 +219,7 @@ static int init_gl_materials(Object *ob, int check_alpha) } } + totmat_gl= ob->totcol; set_gl_material(-1); // signal for static variable return has_alpha; } diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index 85979160986..9a81a1958f3 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -3185,7 +3185,7 @@ void make_links(short event) matar2= MEM_dupallocN(*obmatarar); } else { - matar1= matar2= 0; + matar1= matar2= NULL; } /* remove links from obt */ |