Commit: 1f3c8466a827f4851bd7babec18b58fc148d85cc
Author: Brecht Van Lommel
Date:   Sat Jul 19 14:24:34 2014 +0200
https://developer.blender.org/rB1f3c8466a827f4851bd7babec18b58fc148d85cc

Fix T41100: draw other object UVs doesn't work when both objects have no image.

===================================================================

M       source/blender/editors/uvedit/uvedit_draw.c

===================================================================

diff --git a/source/blender/editors/uvedit/uvedit_draw.c 
b/source/blender/editors/uvedit/uvedit_draw.c
index a1cc23f..177b442 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -403,20 +403,28 @@ static void draw_uvs_other_mesh_new_shading(Object *ob, 
const Image *curimage)
        int a;
        BLI_bitmap *mat_test_array;
        bool ok = false;
+       int totcol = 0;
 
        if (me->mloopuv == NULL) {
                return;
        }
 
-       if (ob->totcol == 0) {
+       if (curimage && ob->totcol == 0) {
                return;
        }
 
-       mat_test_array = BLI_BITMAP_NEW_ALLOCA(ob->totcol);
+       totcol = max_ii(ob->totcol, 1);
+       mat_test_array = BLI_BITMAP_NEW_ALLOCA(totcol);
 
-       for (a = 0; a < ob->totcol; a++) {
+       for (a = 0; a < totcol; a++) {
                Image *image;
-               ED_object_get_active_image(ob, a + 1, &image, NULL, NULL);
+               
+               /* if no materials, assume a default material with no image */
+               if(ob->totcol)
+                       ED_object_get_active_image(ob, a + 1, &image, NULL, 
NULL);
+               else
+                       image = NULL;
+
                if (image == curimage) {
                        BLI_BITMAP_ENABLE(mat_test_array, a);
                        ok = true;
@@ -429,7 +437,7 @@ static void draw_uvs_other_mesh_new_shading(Object *ob, 
const Image *curimage)
 
        for (a = me->totpoly; a != 0; a--, mpoly++) {
                const int mat_nr = mpoly->mat_nr;
-               if ((mat_nr >= ob->totcol) ||
+               if ((mat_nr >= totcol) ||
                    (BLI_BITMAP_TEST(mat_test_array, mat_nr)) == 0)
                {
                        continue;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to