[Bf-blender-cvs] [b95e826] master: Code cleanup: remove unused functions and convert int -> bool

Campbell Barton noreply at git.blender.org
Mon Apr 7 09:05:16 CEST 2014


Commit: b95e8268412eebffdf9c6b9d6ba63aab780bec06
Author: Campbell Barton
Date:   Mon Apr 7 17:00:08 2014 +1000
https://developer.blender.org/rBb95e8268412eebffdf9c6b9d6ba63aab780bec06

Code cleanup: remove unused functions and convert int -> bool

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

M	source/blender/blenkernel/BKE_paint.h
M	source/blender/blenkernel/BKE_pbvh.h
M	source/blender/blenkernel/intern/paint.c
M	source/blender/blenkernel/intern/pbvh_bmesh.c
M	source/blender/editors/include/ED_sculpt.h
M	source/blender/editors/sculpt_paint/paint_intern.h
M	source/blender/editors/sculpt_paint/paint_utils.c
M	source/blender/editors/sculpt_paint/sculpt.c

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

diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 12c4e0b..60c4486 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -126,7 +126,7 @@ typedef struct SculptSession {
 	struct MPoly *mpoly;
 	struct MLoop *mloop;
 	int totvert, totpoly;
-	float *face_normals;
+	float (*face_normals)[3];
 	struct KeyBlock *kb;
 	float *vmask;
 	
@@ -135,7 +135,7 @@ typedef struct SculptSession {
 
 	/* BMesh for dynamic topology sculpting */
 	struct BMesh *bm;
-	int bm_smooth_shading;
+	bool bm_smooth_shading;
 	/* Undo/redo log for dynamic topology sculpting */
 	struct BMLog *bm_log;
 
@@ -144,13 +144,13 @@ typedef struct SculptSession {
 	bool show_diffuse_color;
 
 	/* Paiting on deformed mesh */
-	int modifiers_active; /* object is deformed with some modifiers */
+	bool modifiers_active; /* object is deformed with some modifiers */
 	float (*orig_cos)[3]; /* coords of undeformed mesh */
 	float (*deform_cos)[3]; /* coords of deformed mesh but without stroke displacement */
 	float (*deform_imats)[3][3]; /* crazyspace deformation matrices */
 
 	/* Partial redraw */
-	int partial_redraw;
+	bool partial_redraw;
 	
 	/* Used to cache the render of the active texture */
 	unsigned int texcache_side, *texcache, texcache_actual;
@@ -163,7 +163,7 @@ typedef struct SculptSession {
 	struct StrokeCache *cache;
 
 	/* last paint/sculpt stroke location */
-	int last_stroke_valid;
+	bool last_stroke_valid;
 	float last_stroke[3];
 
 	float average_stroke_accum[3];
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index b6f7a2b..73ca60d 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -67,8 +67,7 @@ void BKE_pbvh_build_grids(PBVH *bvh, struct CCGElem **grid_elems,
                           struct DMGridAdjacency *gridadj, int totgrid,
                           struct CCGKey *key, void **gridfaces, struct DMFlagMat *flagmats,
                           unsigned int **grid_hidden);
-void BKE_pbvh_build_bmesh(PBVH *bvh, struct BMesh *bm, int smooth_shading,
-                          struct BMLog *log);
+void BKE_pbvh_build_bmesh(PBVH *bvh, struct BMesh *bm, bool smooth_shading, struct BMLog *log);
 
 void BKE_pbvh_free(PBVH *bvh);
 void BKE_pbvh_free_layer_disp(PBVH *bvh);
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index d7ae8e3..1189b57 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -413,8 +413,7 @@ static void sculptsession_bm_to_me_update_data_only(Object *ob, bool reorder)
 			BMIter iter;
 			BMFace *efa;
 			BM_ITER_MESH (efa, &iter, ss->bm, BM_FACES_OF_MESH) {
-				BM_elem_flag_set(efa, BM_ELEM_SMOOTH,
-				                 ss->bm_smooth_shading);
+				BM_elem_flag_set(efa, BM_ELEM_SMOOTH, ss->bm_smooth_shading);
 			}
 			if (reorder)
 				BM_log_mesh_elems_reorder(ss->bm, ss->bm_log);
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 8680b3e..ae2f9b2 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -1140,8 +1140,7 @@ void pbvh_bmesh_normals_update(PBVHNode **nodes, int totnode)
 /***************************** Public API *****************************/
 
 /* Build a PBVH from a BMesh */
-void BKE_pbvh_build_bmesh(PBVH *bvh, BMesh *bm, int smooth_shading,
-                          BMLog *log)
+void BKE_pbvh_build_bmesh(PBVH *bvh, BMesh *bm, bool smooth_shading, BMLog *log)
 {
 	BMIter iter;
 	BMFace *f;
diff --git a/source/blender/editors/include/ED_sculpt.h b/source/blender/editors/include/ED_sculpt.h
index 6105db1..ab8a65e 100644
--- a/source/blender/editors/include/ED_sculpt.h
+++ b/source/blender/editors/include/ED_sculpt.h
@@ -45,7 +45,7 @@ void ED_operatortypes_sculpt(void);
 void sculpt_get_redraw_planes(float planes[4][4], struct ARegion *ar,
                               struct RegionView3D *rv3d, struct Object *ob);
 void ED_sculpt_get_average_stroke(struct Object *ob, float stroke[3]);
-int ED_sculpt_minmax(struct bContext *C, float min[3], float max[3]);
+bool ED_sculpt_minmax(struct bContext *C, float min[3], float max[3]);
 int ED_sculpt_mask_layers_ensure(struct Object *ob,
                                   struct MultiresModifierData *mmd);
 int do_sculpt_mask_box_select(struct ViewContext *vc, struct rcti *rect, bool select, bool extend);
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index af9ac6d..cae7859 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -181,12 +181,12 @@ void SCULPT_OT_uv_sculpt_stroke(struct wmOperatorType *ot);
 /* Convert the object-space axis-aligned bounding box (expressed as
  * its minimum and maximum corners) into a screen-space rectangle,
  * returns zero if the result is empty */
-int paint_convert_bb_to_rect(struct rcti *rect,
-                             const float bb_min[3],
-                             const float bb_max[3],
-                             const struct ARegion *ar,
-                             struct RegionView3D *rv3d,
-                             struct Object *ob);
+bool paint_convert_bb_to_rect(struct rcti *rect,
+                              const float bb_min[3],
+                              const float bb_max[3],
+                              const struct ARegion *ar,
+                              struct RegionView3D *rv3d,
+                              struct Object *ob);
 
 /* Get four planes in object-space that describe the projection of
  * screen_rect from screen into object-space (essentially converting a
@@ -200,8 +200,6 @@ void paint_calc_redraw_planes(float planes[4][4],
 float paint_calc_object_space_radius(struct ViewContext *vc, const float center[3], float pixel_radius);
 float paint_get_tex_pixel(struct MTex *mtex, float u, float v, struct ImagePool *pool, int thread);
 void paint_get_tex_pixel_col(struct MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread);
-int imapaint_pick_face(struct ViewContext *vc, const int mval[2], unsigned int *index, unsigned int totface);
-void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, const int xy[2], float uv[2]);
 void brush_drawcursor_texpaint_uvsculpt(struct bContext *C, int x, int y, void *customdata);
 
 void paint_sample_color(const struct bContext *C, struct ARegion *ar, int x, int y);
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 5364ac6..4c86862 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -75,12 +75,12 @@
 /* Convert the object-space axis-aligned bounding box (expressed as
  * its minimum and maximum corners) into a screen-space rectangle,
  * returns zero if the result is empty */
-int paint_convert_bb_to_rect(rcti *rect,
-                             const float bb_min[3],
-                             const float bb_max[3],
-                             const ARegion *ar,
-                             RegionView3D *rv3d,
-                             Object *ob)
+bool paint_convert_bb_to_rect(rcti *rect,
+                              const float bb_min[3],
+                              const float bb_max[3],
+                              const ARegion *ar,
+                              RegionView3D *rv3d,
+                              Object *ob)
 {
 	float projection_mat[4][4];
 	int i, j, k;
@@ -195,153 +195,6 @@ void paint_get_tex_pixel_col(MTex *mtex, float u, float v, float rgba[4], struct
 	CLAMP(rgba[3], 0.0f, 1.0f);
 }
 
-/* 3D Paint */
-
-static void imapaint_project(Object *ob, float model[4][4], float proj[4][4], const float co[3], float pco[4])
-{
-	copy_v3_v3(pco, co);
-	pco[3] = 1.0f;
-
-	mul_m4_v3(ob->obmat, pco);
-	mul_m4_v3(model, pco);
-	mul_m4_v4(proj, pco);
-}
-
-static void imapaint_tri_weights(Object *ob,
-                                 const float v1[3], const float v2[3], const float v3[3],
-                                 const float co[2], float w[3])
-{
-	float pv1[4], pv2[4], pv3[4], h[3], divw;
-	float model[4][4], proj[4][4], wmat[3][3], invwmat[3][3];
-	GLint view[4];
-
-	/* compute barycentric coordinates */
-
-	/* get the needed opengl matrices */
-	glGetIntegerv(GL_VIEWPORT, view);
-	glGetFloatv(GL_MODELVIEW_MATRIX,  (float *)model);
-	glGetFloatv(GL_PROJECTION_MATRIX, (float *)proj);
-	view[0] = view[1] = 0;
-
-	/* project the verts */
-	imapaint_project(ob, model, proj, v1, pv1);
-	imapaint_project(ob, model, proj, v2, pv2);
-	imapaint_project(ob, model, proj, v3, pv3);
-
-	/* do inverse view mapping, see gluProject man page */
-	h[0] = (co[0] - view[0]) * 2.0f / view[2] - 1;
-	h[1] = (co[1] - view[1]) * 2.0f / view[3] - 1;
-	h[2] = 1.0f;
-
-	/* solve for (w1,w2,w3)/perspdiv in:
-	 * h * perspdiv = Project * Model * (w1 * v1 + w2 * v2 + w3 * v3) */
-
-	wmat[0][0] = pv1[0];  wmat[1][0] = pv2[0];  wmat[2][0] = pv3[0];
-	wmat[0][1] = pv1[1];  wmat[1][1] = pv2[1];  wmat[2][1] = pv3[1];
-	wmat[0][2] = pv1[3];  wmat[1][2] = pv2[3];  wmat[2][2] = pv3[3];
-
-	invert_m3_m3(invwmat, wmat);
-	mul_m3_v3(invwmat, h);
-
-	copy_v3_v3(w, h);
-
-	/* w is still divided by perspdiv, make it sum to one */
-	divw = w[0] + w[1] + w[2];
-	if (divw != 0.0f) {
-		mul_v3_fl(w, 1.0f / divw);
-	}
-}
-
-/* compute uv coordinates of mouse in face */
-void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const int xy[2], float uv[2])
-{
-	DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
-	MTFace *tface = dm->getTessFaceDataArray(dm, CD_MTFACE), *tf;
-	int numfaces = dm->getNumTessFaces(dm), a, findex;
-	float p[2], w[3], absw, minabsw;
-	MFace mf;
-	MVert mv[4];
-
-	/* double lookup */
-	const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
-	const int *index_mp_to_orig  = dm->getPolyDataArray(dm, CD_ORIGINDEX);
-	if (index_mf_to_mpoly == NULL) {
-		index_mp_to_orig = NULL;
-	}
-


@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list