[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53032] trunk/blender/source/blender: use struct type for VPaintData.vertexcosnos rather then float*.

Campbell Barton ideasman42 at gmail.com
Sat Dec 15 17:13:32 CET 2012


Revision: 53032
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53032
Author:   campbellbarton
Date:     2012-12-15 16:13:27 +0000 (Sat, 15 Dec 2012)
Log Message:
-----------
use struct type for VPaintData.vertexcosnos rather then float*.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_DerivedMesh.h
    trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c

Modified: trunk/blender/source/blender/blenkernel/BKE_DerivedMesh.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_DerivedMesh.h	2012-12-15 15:59:25 UTC (rev 53031)
+++ trunk/blender/source/blender/blenkernel/BKE_DerivedMesh.h	2012-12-15 16:13:27 UTC (rev 53032)
@@ -105,6 +105,11 @@
  *       Also, the mface origindex layer indexes mpolys, not mfaces.
  */
 
+typedef struct DMCoNo {
+	float co[3];
+	float no[3];
+} DMCoNo;
+
 typedef struct DMGridAdjacency {
 	int index[4];
 	int rotation[4];
@@ -603,7 +608,7 @@
 /** Simple function to get me->totvert amount of vertices/normals,
  * correctly deformed and subsurfered. Needed especially when vertexgroups are involved.
  * In use now by vertex/weight paint and particles */
-float *mesh_get_mapped_verts_nors(struct Scene *scene, struct Object *ob);
+DMCoNo *mesh_get_mapped_verts_nors(struct Scene *scene, struct Object *ob);
 
 /* */
 DerivedMesh *mesh_get_derived_final(struct Scene *scene, struct Object *ob,

Modified: trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c	2012-12-15 15:59:25 UTC (rev 53031)
+++ trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c	2012-12-15 16:13:27 UTC (rev 53032)
@@ -2334,29 +2334,29 @@
 /* it stores the normals as floats, but they can still be scaled as shorts (32767 = unit) */
 /* in use now by vertex/weight paint and particle generating */
 
-float *mesh_get_mapped_verts_nors(Scene *scene, Object *ob)
+DMCoNo *mesh_get_mapped_verts_nors(Scene *scene, Object *ob)
 {
 	Mesh *me = ob->data;
 	DerivedMesh *dm;
-	float *vertexcosnos;
+	DMCoNo *vertexcosnos;
 	
 	/* lets prevent crashing... */
 	if (ob->type != OB_MESH || me->totvert == 0)
 		return NULL;
 	
 	dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
-	vertexcosnos = MEM_callocN(6 * sizeof(float) * me->totvert, "vertexcosnos map");
+	vertexcosnos = MEM_callocN(sizeof(DMCoNo) * me->totvert, "vertexcosnos map");
 	
 	if (dm->foreachMappedVert) {
 		dm->foreachMappedVert(dm, make_vertexcosnos__mapFunc, vertexcosnos);
 	}
 	else {
-		float *fp = vertexcosnos;
+		DMCoNo *v_co_no = vertexcosnos;
 		int a;
 		
-		for (a = 0; a < me->totvert; a++, fp += 6) {
-			dm->getVertCo(dm, a, fp);
-			dm->getVertNo(dm, a, fp + 3);
+		for (a = 0; a < me->totvert; a++, v_co_no++) {
+			dm->getVertCo(dm, a, v_co_no->co);
+			dm->getVertNo(dm, a, v_co_no->no);
 		}
 	}
 	

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c	2012-12-15 15:59:25 UTC (rev 53031)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c	2012-12-15 16:13:27 UTC (rev 53032)
@@ -851,12 +851,12 @@
 }
 
 /* whats _dl mean? */
-static float calc_vp_strength_dl(VPaint *vp, ViewContext *vc, const float vert_nor[3],
+static float calc_vp_strength_dl(VPaint *vp, ViewContext *vc, const float co[3],
                                  const float mval[2], const float brush_size_pressure)
 {
 	float vertco[2];
 
-	if (ED_view3d_project_float_global(vc->ar, vert_nor, vertco, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
+	if (ED_view3d_project_float_global(vc->ar, co, vertco, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
 		float delta[2];
 		float dist_squared;
 
@@ -873,24 +873,23 @@
 }
 
 static float calc_vp_alpha_dl(VPaint *vp, ViewContext *vc,
-                              float vpimat[3][3], const float *vert_nor,
+                              float vpimat[3][3], const DMCoNo *v_co_no,
                               const float mval[2],
                               const float brush_size_pressure, const float brush_alpha_pressure)
 {
-	float strength = calc_vp_strength_dl(vp, vc, vert_nor, mval, brush_size_pressure);
+	float strength = calc_vp_strength_dl(vp, vc, v_co_no->co, mval, brush_size_pressure);
 
 	if (strength > 0.0f) {
 		float alpha = brush_alpha_pressure * strength;
 
 		if (vp->flag & VP_NORMALS) {
 			float dvec[3];
-			const float *no = vert_nor + 3;
 
 			/* transpose ! */
-			dvec[2] = dot_v3v3(vpimat[2], no);
+			dvec[2] = dot_v3v3(vpimat[2], v_co_no->no);
 			if (dvec[2] > 0.0f) {
-				dvec[0] = dot_v3v3(vpimat[0], no);
-				dvec[1] = dot_v3v3(vpimat[1], no);
+				dvec[0] = dot_v3v3(vpimat[0], v_co_no->no);
+				dvec[1] = dot_v3v3(vpimat[1], v_co_no->no);
 
 				alpha *= dvec[2] / len_v3(dvec);
 			}
@@ -2038,7 +2037,7 @@
 	int *indexar;
 	int vgroup_active;
 	int vgroup_mirror;
-	float *vertexcosnos;
+	DMCoNo *vertexcosnos;
 	float wpimat[3][3];
 	
 	/* variables for auto normalize */
@@ -2286,7 +2285,7 @@
 				ml = me->mloop + mpoly->loopstart;
 				for (i = 0; i < mpoly->totloop; i++, ml++) {
 					unsigned int vidx = ml->v;
-					const float fac = calc_vp_strength_dl(wp, vc, wpd->vertexcosnos + 6 * vidx, mval, brush_size_pressure);
+					const float fac = calc_vp_strength_dl(wp, vc, wpd->vertexcosnos[vidx].co, mval, brush_size_pressure);
 					if (fac > 0.0f) {
 						dw = dw_func(&me->dvert[vidx], wpi.vgroup_active);
 						paintweight += dw ? (dw->weight * fac) : 0.0f;
@@ -2312,7 +2311,7 @@
 				unsigned int vidx = ml->v;
 
 				if (me->dvert[vidx].flag) {
-					alpha = calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos + 6 * vidx,
+					alpha = calc_vp_alpha_dl(wp, vc, wpd->wpimat, &wpd->vertexcosnos[vidx],
 					                         mval, brush_size_pressure, brush_alpha_pressure);
 					if (alpha) {
 						do_weight_paint_vertex(wp, ob, &wpi, vidx, alpha, paintweight);
@@ -2548,7 +2547,7 @@
 	ViewContext vc;
 	unsigned int paintcol;
 	int *indexar;
-	float *vertexcosnos;
+	DMCoNo *vertexcosnos;
 	float vpimat[3][3];
 
 	/* modify 'me->mcol' directly, since the derived mesh is drawing from this array,
@@ -2696,7 +2695,7 @@
 	ml = me->mloop + mpoly->loopstart;
 	for (i = 0; i < mpoly->totloop; i++, ml++) {
 		alpha = calc_vp_alpha_dl(vp, vc, vpd->vpimat,
-		                         vpd->vertexcosnos + 6 * ml->v, mval,
+		                         &vpd->vertexcosnos[ml->v], mval,
 		                         brush_size_pressure, brush_alpha_pressure);
 		if (alpha > 0.0f) {
 			const int alpha_i = (int)(alpha * 255.0f);




More information about the Bf-blender-cvs mailing list