[Bf-blender-cvs] [f1e26a85ca3] soc-2016-pbvh-painting: Cleanup: move inline ViewContext out of vpaint structs

Campbell Barton noreply at git.blender.org
Mon Apr 10 05:13:51 CEST 2017


Commit: f1e26a85ca3f2027c29d1ae9c2e67ebf68b147c3
Author: Campbell Barton
Date:   Mon Apr 10 13:10:53 2017 +1000
Branches: soc-2016-pbvh-painting
https://developer.blender.org/rBf1e26a85ca3f2027c29d1ae9c2e67ebf68b147c3

Cleanup: move inline ViewContext out of vpaint structs

This required a bunch of indirect includes,
change this for neater includes and a single allocation here isn't causing performance problems.

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

M	source/blender/editors/sculpt_paint/paint_image.c
M	source/blender/editors/sculpt_paint/paint_image_2d.c
M	source/blender/editors/sculpt_paint/paint_intern.h
M	source/blender/editors/sculpt_paint/paint_ops.c
M	source/blender/editors/sculpt_paint/paint_undo.c
M	source/blender/editors/sculpt_paint/paint_vertex.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_undo.c
M	source/blender/editors/sculpt_paint/sculpt_uv.c

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

diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 890693e8068..fc6b0122ed2 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -1482,8 +1482,9 @@ static int brush_colors_flip_poll(bContext *C)
 	}
 	else {
 		Object *ob = CTX_data_active_object(C);
-		if (ob && (ob->mode & OB_MODE_VERTEX_PAINT))
+		if (ob && (ob->mode & OB_MODE_VERTEX_PAINT)) {
 			return 1;
+		}
 	}
 	return 0;
 }
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index 03f1e47336a..4f93c12385d 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -54,7 +54,6 @@
 
 #include "ED_paint.h"
 #include "ED_screen.h"
-#include "ED_view3d.h"  /* For paint_intern.h */
 
 #include "IMB_imbuf.h"
 #include "IMB_imbuf_types.h"
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index 865462f3bfc..dcbe7bc5961 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -142,7 +142,7 @@ typedef struct WeightPaintInfo {
 
 /* paint_vertex.c */
 typedef struct VPaintData {
-	struct ViewContext vc;
+	struct ViewContext *vc;
 	unsigned int paintcol;
 	int *indexar;
 
@@ -163,7 +163,7 @@ typedef struct VPaintData {
 } VPaintData;
 
 typedef struct WPaintData {
-	struct ViewContext vc;
+	struct ViewContext *vc;
 	int *indexar;
 
 	struct WeightPaintGroupData active, mirror;
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 7d9dfd4114c..32156dee562 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -43,7 +43,6 @@
 #include "ED_paint.h"
 #include "ED_screen.h"
 #include "ED_image.h"
-#include "ED_view3d.h"  /* For paint_intern.h */
 
 #include "UI_resources.h"
 
diff --git a/source/blender/editors/sculpt_paint/paint_undo.c b/source/blender/editors/sculpt_paint/paint_undo.c
index b29ed485efa..27d3f6648a2 100644
--- a/source/blender/editors/sculpt_paint/paint_undo.c
+++ b/source/blender/editors/sculpt_paint/paint_undo.c
@@ -39,7 +39,6 @@
 #include "BKE_global.h"
 
 #include "ED_paint.h"
-#include "ED_view3d.h"  /* For paint_intern.h */
 
 #include "paint_intern.h"
 
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 19a92823985..c3eb5288276 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -2078,9 +2078,10 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo
 
 	/* ALLOCATIONS! no return after this line */
 	/* make mode data storage */
-	wpd = MEM_callocN(sizeof(struct WPaintData), "WPaintData");
+	wpd = MEM_callocN(sizeof(WPaintData), "WPaintData");
+	wpd->vc = MEM_callocN(sizeof(*wpd->vc), __func__);
 	paint_stroke_set_mode_data(stroke, wpd);
-	view3d_set_viewcontext(C, &wpd->vc);
+	view3d_set_viewcontext(C, wpd->vc);
 
 	wpd->active.index = vgroup_index.active;
 	wpd->mirror.index = vgroup_index.mirror;
@@ -2131,7 +2132,7 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo
 	ob->sculpt->modes.vwpaint.building_vp_handle = false;
 
 	/* imat for normals */
-	mul_m4_m4m4(mat, wpd->vc.rv3d->viewmat, ob->obmat);
+	mul_m4_m4m4(mat, wpd->vc->rv3d->viewmat, ob->obmat);
 	invert_m4_m4(imat, mat);
 	copy_m3_m4(wpd->wpimat, imat);
 
@@ -2693,7 +2694,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
 		return;
 	}
 
-	vc = &wpd->vc;
+	vc = wpd->vc;
 	ob = vc->obact;
 	
 	view3d_operator_needs_opengl(C);
@@ -2729,7 +2730,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
 
 	DAG_id_tag_update(ob->data, 0);
 	WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
-	swap_m4m4(wpd->vc.rv3d->persmat, mat);
+	swap_m4m4(wpd->vc->rv3d->persmat, mat);
 
 	rcti r;
 	if (sculpt_get_redraw_rect(vc->ar, CTX_wm_region_view3d(C), ob, &r)) {
@@ -2761,7 +2762,9 @@ static void wpaint_stroke_done(const bContext *C, struct PaintStroke *stroke)
 	
 	if (wpd) {
 		ED_vpaint_proj_handle_free(wpd->vp_handle);
-		
+
+		MEM_freeN(wpd->vc);
+
 		if (wpd->defbase_sel)
 			MEM_freeN((void *)wpd->defbase_sel);
 		if (wpd->vgroup_validmap)
@@ -3043,9 +3046,10 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f
 		return false;
 
 	/* make mode data storage */
-	vpd = MEM_callocN(sizeof(struct VPaintData), "VPaintData");
+	vpd = MEM_callocN(sizeof(VPaintData), "VPaintData");
+	vpd->vc = MEM_callocN(sizeof(*vpd->vc), __func__);
 	paint_stroke_set_mode_data(stroke, vpd);
-	view3d_set_viewcontext(C, &vpd->vc);
+	view3d_set_viewcontext(C, vpd->vc);
 	
 	vpd->paintcol = vpaint_get_current_col(scene, vp);
 
@@ -3075,7 +3079,7 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f
 
 
 	/* some old cruft to sort out later */
-	mul_m4_m4m4(mat, vpd->vc.rv3d->viewmat, ob->obmat);
+	mul_m4_m4m4(mat, vpd->vc->rv3d->viewmat, ob->obmat);
 	invert_m4_m4(imat, mat);
 	copy_m3_m4(vpd->vpimat, imat);
 
@@ -3146,7 +3150,7 @@ static void handle_texture_brush(SculptThreadedTaskData *data, PBVHVertexIter vd
 	float rgba[4];
 	float rgba_br[3];
 
-	*alpha = calc_vp_alpha_col_dl(data->vp, &data->vpd->vc, data->vpd->vpimat,
+	*alpha = calc_vp_alpha_col_dl(data->vp, data->vpd->vc, data->vpd->vpimat,
 	                              &data->vpd->vertexcosnos[vertexIndex], ss->cache->mouse, size_pressure, alpha_pressure, rgba);
 	rgb_uchar_to_float(rgba_br, (const unsigned char *)&data->vpd->paintcol);
 	mul_v3_v3(rgba_br, rgba);
@@ -3524,7 +3528,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
 	ToolSettings *ts = CTX_data_tool_settings(C);
 	VPaintData *vpd = paint_stroke_mode_data(stroke);
 	VPaint *vp = ts->vpaint;
-	ViewContext *vc = &vpd->vc;
+	ViewContext *vc = vpd->vc;
 	Object *ob = vc->obact;
 	Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
 
@@ -3564,9 +3568,11 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
 static void vpaint_stroke_done(const bContext *C, struct PaintStroke *stroke)
 {
 	struct VPaintData *vpd = paint_stroke_mode_data(stroke);
-	ViewContext *vc = &vpd->vc;
+	ViewContext *vc = vpd->vc;
 	Object *ob = vc->obact;
-	
+
+	MEM_freeN(vpd->vc);
+
 	if (vpd->mlooptag)
 		MEM_freeN(vpd->mlooptag);
 
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index cc9dbd99110..08443d89ab5 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -74,7 +74,6 @@
 #include "ED_sculpt.h"
 #include "ED_object.h"
 #include "ED_screen.h"
-#include "ED_view3d.h"  /* For paint_intern.h */
 
 #include "paint_intern.h"
 #include "sculpt_intern.h"
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index be27b3d6746..2a8af934c6e 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -63,7 +63,6 @@
 #include "GPU_buffers.h"
 
 #include "ED_paint.h"
-#include "ED_view3d.h"  /* For paint_intern.h */
 
 #include "bmesh.h"
 #include "paint_intern.h"
diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c
index 854e71717ee..fd2a0b15cb9 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -54,7 +54,6 @@
 #include "ED_screen.h"
 #include "ED_image.h"
 #include "ED_mesh.h"
-#include "ED_view3d.h"  /* For paint_intern.h */
 
 #include "WM_api.h"
 #include "WM_types.h"




More information about the Bf-blender-cvs mailing list