Commit: 61e7968555b34607c1e7e98622eac93125bcfe6e
Author: Campbell Barton
Date:   Sat Jul 12 21:02:37 2014 +1000
https://developer.blender.org/rB61e7968555b34607c1e7e98622eac93125bcfe6e

Better fix for texture name lookup

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

M       source/blender/editors/sculpt_paint/paint_image_proj.c

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

diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c 
b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 7442bce..1f0b2c8 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -4798,8 +4798,6 @@ void PAINT_OT_image_from_view(wmOperatorType *ot)
 
 /* Add layer operator */
 
-#define TEXNAME_MAX 30
-
 static EnumPropertyItem layer_type_items[] = {
        {MAP_COL, "DIFFUSE_COLOR", 0, "Diffuse Color", ""},
        {MAP_REF, "DIFFUSE_INTENSITY", 0, "Diffuse Intensity", ""},
@@ -4853,23 +4851,20 @@ bool proj_paint_add_slot(bContext *C, int type, 
Material *ma)
 
                        /* successful creation of mtex layer, now create set */
                        if (mtex) {
-                               char imagename[FILE_MAX];
-                               char name[TEXNAME_MAX];
                                Main *bmain = CTX_data_main(C);
                                Image *ima;
+                               const char *name;
 
                                /* get the name of the texture layer type */
-                               for (i = 0; i < ARRAY_SIZE(layer_type_items); 
i++) {
-                                       if (type == layer_type_items[i].value) {
-                                               BLI_strncpy(name, 
layer_type_items[i].name, TEXNAME_MAX);
-                                               break;
-                                       }
-                               }
+                               i = RNA_enum_from_value(layer_type_items, type);
+                               BLI_assert(i != -1);
+                               name = layer_type_items[i].name;
 
                                mtex->tex = add_texture(bmain, DATA_(name));
                                mtex->mapto = type;
 
                                if (mtex->tex) {
+                                       char imagename[FILE_MAX];
                                        float color[4];
                                        bool use_float = type == MAP_NORM;

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

Reply via email to