option to lock alpha while projection painting.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 16 Mar 2010 18:05:53 +0000 (18:05 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 16 Mar 2010 18:05:53 +0000 (18:05 +0000)
(commit 27538 by Campbell from render25 branch)

release/scripts/ui/space_view3d_toolbar.py
source/blender/editors/sculpt_paint/paint_image.c
source/blender/makesdna/DNA_brush_types.h
source/blender/makesrna/intern/rna_brush.c

index a4b908bf1d1ff53f0e227e79d6da349c31c14855..10718883c3c04e508f3fdcb39f1e44d6c1c92097 100644 (file)
@@ -592,6 +592,11 @@ class VIEW3D_PT_tools_brush(PaintPanel):
 
             col.prop(brush, "blend", text="Blend")
 
+            col = layout.column()
+            col.active = (brush.blend not in ('ERASE_ALPHA', 'ADD_ALPHA'))
+            col.prop(brush, "use_alpha")
+            
+
         # Weight Paint Mode #
 
         elif context.weight_paint_object and brush:
index 6137d83e77ed9f6a1ba7620b62e7cb5fe3f238ee..9fc858a191f4843d6e10c7561d09559e44710837 100644 (file)
@@ -3705,6 +3705,7 @@ static void *do_projectpaint_thread(void *ph_v)
        float mask = 1.0f; /* airbrush wont use mask */
        unsigned short mask_short;
        float size_half = ((float)ps->brush->size) * 0.5f;
+       short lock_alpha= ELEM(ps->brush->blend, IMB_BLEND_ERASE_ALPHA, IMB_BLEND_ADD_ALPHA) ? 0 : ps->brush->flag & BRUSH_LOCK_ALPHA;
        
        LinkNode *smearPixels = NULL;
        LinkNode *smearPixels_f = NULL;
@@ -3833,6 +3834,12 @@ static void *do_projectpaint_thread(void *ph_v)
                                                                break;
                                                        }
                                                }
+
+                                               if(lock_alpha) {
+                                                       if (is_floatbuf)        projPixel->pixel.f_pt[3]= projPixel->origColor.f[3];
+                                                       else                            projPixel->pixel.ch_pt[3]= projPixel->origColor.ch[3];
+                                               }
+
                                                /* done painting */
                                        }
                                }
index 163c8122fb7f39ee19d07477cadff52b876b62ce..14930f85e632775db82b26641403d654ffa10aa3 100644 (file)
@@ -86,6 +86,7 @@ typedef struct Brush {
 #define BRUSH_SMOOTH_STROKE            2048
 #define BRUSH_PERSISTENT               4096
 #define BRUSH_ACCUMULATE               8192
+#define BRUSH_LOCK_ALPHA               16384
 
 /* Brush.sculpt_tool */
 #define SCULPT_TOOL_DRAW    1
index 2d81a9d66c180291d4c7abe1c41cd92175914a4c..df08dc7b861e1c9f3994716799b633b44a7523b8 100644 (file)
@@ -279,6 +279,12 @@ static void rna_def_brush(BlenderRNA *brna)
        RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_FIXED_TEX);
        RNA_def_property_ui_text(prop, "Fixed Texture", "Keep texture origin in fixed position");
        RNA_def_property_update(prop, 0, "rna_Brush_update"); */
+       
+       /* only for projection paint, TODO, other paint modes */
+       prop= RNA_def_property(srna, "use_alpha", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BRUSH_LOCK_ALPHA);
+       RNA_def_property_ui_text(prop, "Alpha", "When this is disabled, lock alpha while painting");
+       RNA_def_property_update(prop, 0, "rna_Brush_update");
 
        prop= RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE);
        RNA_def_property_flag(prop, PROP_NEVER_NULL);