[Bf-blender-cvs] [ab9787e] soc-2013-paint: First round of taking care of code review remarks from sergey

Antony Riakiotakis noreply at git.blender.org
Thu Jul 3 13:26:34 CEST 2014


Commit: ab9787e860d1c7554240c7dd870ec89683ad8ce6
Author: Antony Riakiotakis
Date:   Thu Jul 3 14:26:07 2014 +0300
https://developer.blender.org/rBab9787e860d1c7554240c7dd870ec89683ad8ce6

First round of taking care of code review remarks from sergey

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

M	release/scripts/startup/bl_ui/properties_paint_common.py
M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/blenkernel/BKE_material.h
M	source/blender/blenkernel/intern/brush.c
M	source/blender/blenkernel/intern/depsgraph.c
M	source/blender/blenkernel/intern/material.c
M	source/blender/blenlib/BLI_math_vector.h
M	source/blender/blenlib/intern/math_color_blend_inline.c
M	source/blender/blenlib/intern/math_vector_inline.c
M	source/blender/editors/render/render_update.c
M	source/blender/editors/sculpt_paint/paint_image.c
M	source/blender/editors/sculpt_paint/paint_image_proj.c
M	source/blender/gpu/intern/gpu_buffers.c
M	source/blender/makesrna/intern/rna_brush.c

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

diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index 521fa99..5cdfb2c 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -87,7 +87,7 @@ class UnifiedPaintPanel():
 
 
 def brush_texpaint_common(panel, context, layout, brush, settings):
-    capabilities = brush.imapaint_capabilities
+    capabilities = brush.image_paint_capabilities
 
     col = layout.column()
 
@@ -237,7 +237,6 @@ def brush_mask_texture_settings(layout, brush):
             layout.operator("brush.stencil_fit_image_aspect").mask = True
         layout.operator("brush.stencil_reset_transform").mask = True
 
-
     col = layout.column()
     col.prop(brush, "use_pressure_masking", text="");
     col.label(text="Angle:")
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 36f0a60..e5402cf 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1034,12 +1034,10 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
 
 class TEXTURE_UL_texpaintslots(UIList):
     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
-        # assert(isinstance(item, bpy.types.MaterialTextureSlot)
         ma = data
         ima = item
 
         if self.layout_type in {'DEFAULT', 'COMPACT'}:
-            # layout.label(text=tex.image.name, translate=False)
             layout.label(text=ima.name, translate=False, icon_value=icon)
         elif self.layout_type in {'GRID'}:
             layout.alignment = 'CENTER'
@@ -1608,13 +1606,6 @@ class VIEW3D_PT_tools_projectpaint(View3DPaintPanel, Panel):
 
         col = layout.column()
 
-#        col.label(text="Mirror:")
-#        row = col.row(align=True)
-#        row.prop(ipaint, "use_symmetry_x", text="X", toggle=True)
-#        row.prop(ipaint, "use_symmetry_y", text="Y", toggle=True)
-#        row.prop(ipaint, "use_symmetry_z", text="Z", toggle=True)
-
-#        col.separator()
         col.prop(ipaint, "use_occlude")
         col.prop(ipaint, "use_backface_culling")
 
@@ -1641,8 +1632,6 @@ class VIEW3D_PT_tools_projectpaint(View3DPaintPanel, Panel):
         col = layout.column()
         col.active = (settings.brush.image_tool == 'CLONE')
         col.prop(ipaint, "use_clone_layer", text="Clone from paint slot")
-        #clone_text = mesh.uv_texture_clone.name if mesh.uv_texture_clone else ""
-        #col.menu("VIEW3D_MT_tools_projectpaint_clone", text=clone_text, translate=False)
 
         layout.prop(ipaint, "seam_bleed")
         self.unified_paint_settings(layout, context)
diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h
index 4a91763..420db38 100644
--- a/source/blender/blenkernel/BKE_material.h
+++ b/source/blender/blenkernel/BKE_material.h
@@ -88,10 +88,9 @@ short find_material_index(struct Object *ob, struct Material *ma);
 bool object_add_material_slot(struct Object *ob);
 bool object_remove_material_slot(struct Object *ob);
 
-void refresh_texpaint_slot_cache(struct Material *ma, bool use_nodes);
-struct MTex *give_current_texpaint_slot(struct Material *ma);
-void refresh_object_texpaint_slots(struct Object *ob, bool use_nodes);
-void clear_texpaint_slots(struct Material *ma);
+void BKE_refresh_texpaint_slot_cache(struct Material *ma, bool use_nodes);
+void BKE_refresh_object_texpaint_slots(struct Object *ob, bool use_nodes);
+void BKE_clear_texpaint_slots(struct Material *ma);
 
 /* rna api */
 void BKE_material_resize_id(struct ID *id, short totcol, bool do_id_user);
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index a7ce754..84cfe92 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -186,13 +186,13 @@ Brush *BKE_brush_copy(Brush *brush)
 void BKE_brush_free(Brush *brush)
 {
 	if (brush->mtex.tex)
-		brush->mtex.tex->id.us--;
+		id_us_min(&brush->mtex.tex->id);
 
 	if (brush->mask_mtex.tex)
-		brush->mask_mtex.tex->id.us--;
+		id_us_min(&brush->mask_mtex.tex->id);
 
 	if (brush->paint_curve)
-		brush->paint_curve->id.us--;
+		id_us_min(&brush->paint_curve->id);
 
 	if (brush->icon_imbuf)
 		IMB_freeImBuf(brush->icon_imbuf);
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 4b2b0a6..f628ff4 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -2477,7 +2477,7 @@ static void dag_id_flush_update(Main *bmain, Scene *sce, ID *id)
 			for (obt = bmain->object.first; obt; obt = obt->id.next) {
 				if (obt->mode & OB_MODE_TEXTURE_PAINT) {
 					obt->recalc |= OB_RECALC_DATA;
-					refresh_object_texpaint_slots(obt, new_shading_nodes);
+					BKE_refresh_object_texpaint_slots(obt, new_shading_nodes);
 					lib_id_recalc_data_tag(bmain, &obt->id);
 				}
 			}
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index f42aae5..39624f5 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -111,10 +111,8 @@ void BKE_material_free_ex(Material *ma, bool do_id_user)
 		MEM_freeN(ma->nodetree);
 	}
 
-	if (ma->texpaintslot) {
+	if (ma->texpaintslot)
 		MEM_freeN(ma->texpaintslot);
-		ma->tot_slots = 0;
-	}
 
 	if (ma->gpumaterial.first)
 		GPU_material_free(ma);
@@ -1306,7 +1304,7 @@ bool object_remove_material_slot(Object *ob)
 	return true;
 }
 
-void clear_texpaint_slots(struct Material *ma)
+void BKE_clear_texpaint_slots(struct Material *ma)
 {
 
 	if (ma->texpaintslot) {
@@ -1326,7 +1324,7 @@ static bool get_mtex_slot_valid_texpaint(struct MTex *mtex)
 	        mtex->tex->ima);
 }
 
-void refresh_texpaint_slot_cache(Material *ma, bool use_nodes)
+void BKE_refresh_texpaint_slot_cache(Material *ma, bool use_nodes)
 {
 	MTex **mtex;
 	short count = 0;
@@ -1337,7 +1335,7 @@ void refresh_texpaint_slot_cache(Material *ma, bool use_nodes)
 
 	/* blender internal  calculation goes here */
 	if (ma->texpaintslot) {
-		MEM_freeN (ma->texpaintslot);
+		MEM_freeN(ma->texpaintslot);
 		ma->texpaintslot = NULL;
 	}
 
@@ -1405,7 +1403,7 @@ void refresh_texpaint_slot_cache(Material *ma, bool use_nodes)
 	return;
 }
 
-void refresh_object_texpaint_slots(struct Object *ob, bool use_nodes)
+void BKE_refresh_object_texpaint_slots(struct Object *ob, bool use_nodes)
 {
 	int i;
 
@@ -1414,33 +1412,10 @@ void refresh_object_texpaint_slots(struct Object *ob, bool use_nodes)
 
 	for (i = 1; i < ob->totcol + 1; i++) {
 		Material *ma = give_current_material(ob, i);
-		refresh_texpaint_slot_cache(ma, use_nodes);
+		BKE_refresh_texpaint_slot_cache(ma, use_nodes);
 	}
 }
 
-/* no caching - slow, but not as useful as image */
-struct MTex *give_current_texpaint_slot(Material *ma)
-{
-	MTex **mtex, *validmtex = NULL;
-
-	short index = 0, i = 0;
-
-	for (mtex = ma->mtex; i < MAX_MTEX; i++, mtex++) {
-		if (get_mtex_slot_valid_texpaint(*mtex)) {
-			if (index++ == ma->paint_active_slot)
-				return (*mtex);
-
-			validmtex = *mtex;
-		}
-	}
-
-	/* possible to not have selected anything as active texture. Just set to a valid index */
-	if (index > 0) {
-		ma->paint_active_slot = index;
-	}
-
-	return validmtex;
-}
 
 /* r_col = current value, col = new value, (fac == 0) is no change */
 void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 71a67ed..e9b32c9 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -65,6 +65,8 @@ MINLINE void swap_v4_v4(float a[4], float b[4]);
 MINLINE void copy_v2_v2_char(char r[2], const char a[2]);
 MINLINE void copy_v3_v3_char(char r[3], const char a[3]);
 MINLINE void copy_v4_v4_char(char r[4], const char a[4]);
+MINLINE void copy_v4_v4_uchar(unsigned char r[4], const unsigned char a[4]);
+
 /* short */
 MINLINE void copy_v2_v2_short(short r[2], const short a[2]);
 MINLINE void copy_v3_v3_short(short r[3], const short a[3]);
diff --git a/source/blender/blenlib/intern/math_color_blend_inline.c b/source/blender/blenlib/intern/math_color_blend_inline.c
index 90321c7..901076e 100644
--- a/source/blender/blenlib/intern/math_color_blend_inline.c
+++ b/source/blender/blenlib/intern/math_color_blend_inline.c
@@ -30,6 +30,7 @@
 #include "BLI_math_base.h"
 #include "BLI_math_color.h"
 #include "BLI_math_color_blend.h"
+#include "BLI_math_vector.h"
 #include "BLI_utildefines.h"
 
 #ifndef __MATH_COLOR_BLEND_INLINE_C__
@@ -71,10 +72,7 @@ MINLINE void blend_color_mix_byte(unsigned char dst[4], const unsigned char src1
 	}
 	else {
 		/* no op */
-		dst[0] = src1[0];
-		dst[1] = src1[1];
-		dst[2] = src1[2];
-		dst[3] = src1[3];
+		copy_v4_v4_uchar(dst, src1);
 	}
 }
 
@@ -96,10 +94,7 @@ MINLINE void blend_color_add_byte(unsigned char dst[4], const unsigned char src1
 	}
 	else {
 		/* no op */
-		dst[0] = src1[0];
-		dst[1] = src1[1];
-		dst[2] = src1[2];
-		dst[3] = src1[3];
+		copy_v4_v4_uchar(dst, src1);
 	}
 }
 
@@ -121,10 +116,7 @@ MINLINE void blend_color_sub_byte(unsigned char dst[4], const unsigned char src1
 	}
 	else {
 		/* no op */
-		dst[0] = src1[0];
-		dst[1] = src1[1];
-		dst[2] = src1[2];
-		dst[3] = src1[3];
+		copy_v4_v4_uchar(dst, src1);
 	}
 }
 
@@ -147,10 +139,7 @@ MINLINE void blend_color_mul_byte(unsigned char dst[4], const unsigned char src1
 	}
 	else {
 		/* no op */
-		dst[0] = src1[0];
-		dst[1] = src1[1];
-		dst[2] = src1[2];
-		dst[3] = src1[3];
+		copy_v4_v4_uchar(dst, src1);
 	}
 }
 
@@ -173,10 +162,7 @@ MINLINE void blend_color_lighten_byte(unsigned char dst[4], const unsigned char
 	}
 	else {
 		/* no op */
-		dst[0] = src1[0];
-		dst[1] = src1[1];
-		dst[2] = src1[2];
-		dst[3] = src1[3];
+		copy_v4_v4_uchar(dst, src1);
 	}
 }
 
@@ -199,10 +185,7 @@ MINLINE void blend_color_darken_byte(unsigned char dst[4], const unsigned char s
 	}
 	else {
 		/* no op */
-		dst[0] = src1[0];
-		dst[1] = src1[1];
-		dst[2] = src1[2];
-

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list