[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44304] trunk/blender/source/blender/ blenkernel: Remove unused code left from old multires interpolation stuff

Sergey Sharybin sergey.vfx at gmail.com
Tue Feb 21 18:24:22 CET 2012


Revision: 44304
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44304
Author:   nazgul
Date:     2012-02-21 17:24:21 +0000 (Tue, 21 Feb 2012)
Log Message:
-----------
Remove unused code left from old multires interpolation stuff

- Removed validate() callback for MDisps layer. It wouldn't actually work
  correct from CustomData layer and all needed data might be validated from
  BMesh interpolation level. Also this callback was never actually used in
  BMesh, so can't see why we'll want to have it in structures.
- Removed layrInterp_mdisps callback. Interpolation now happens from
  another level (bmesh_interp) and this callback isn't needed anymore.
- Removed all function from multires.c which were used by old interpolation
  stuff and seems to be useless for other usages.
- multires_topology_changed is still marked as a TODO, Probably it's not
  needed anymore, buy better to keep for now until it'll be 100% clear this
  function isn't needed and all needed re-allocations happens in bmesh_interp.
  Otherwise, it'll be needed to be ported to new system.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_multires.h
    trunk/blender/source/blender/blenkernel/intern/customdata.c
    trunk/blender/source/blender/blenkernel/intern/multires.c

Modified: trunk/blender/source/blender/blenkernel/BKE_multires.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_multires.h	2012-02-21 17:24:05 UTC (rev 44303)
+++ trunk/blender/source/blender/blenkernel/BKE_multires.h	2012-02-21 17:24:21 UTC (rev 44304)
@@ -88,19 +88,13 @@
 void multiresModifier_prepare_join(struct Scene *scene, struct Object *ob, struct Object *to_ob);
 
 int multires_mdisp_corners(struct MDisps *s);
-void multires_mdisp_smooth_bounds(struct MDisps *disps);
 
 /* update multires data after topology changing */
 void multires_topology_changed(struct Scene *scene, struct Object *ob);
 
 /**** interpolation stuff ****/
 void old_mdisps_bilinear(float out[3], float (*disps)[3], const int st, float u, float v);
-void mdisp_rot_crn_to_face(const int S, const int corners, const int face_side, const float x, const float y, float *u, float *v);
 int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u, const float v, float *x, float *y);
-int mdisp_rot_face_to_quad_crn(const int corners, const int face_side, const float u, const float v, float *x, float *y);
-void mdisp_apply_weight(const int S, const int corners, int x, int y, const int face_side, float crn_weight[4][2], float *u_r, float *v_r);
-void mdisp_flip_disp(const int S, const int corners, const float axis_x[2], const float axis_y[2], float disp[3]);
-void mdisp_join_tris(struct MDisps *dst, struct MDisps *tri1, struct MDisps *tri2);
 
 #endif // __BKE_MULTIRES_H__
 

Modified: trunk/blender/source/blender/blenkernel/intern/customdata.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/customdata.c	2012-02-21 17:24:05 UTC (rev 44303)
+++ trunk/blender/source/blender/blenkernel/intern/customdata.c	2012-02-21 17:24:21 UTC (rev 44304)
@@ -120,11 +120,6 @@
 
 	/* a function to determine file size */
 	size_t (*filesize)(CDataFile *cdf, void *data, int count);
-
-	/* a function to validate layer contents depending on
-	 * sub-elements count
-	 */
-	void (*validate)(void *source, int sub_elements);
 } LayerTypeInfo;
 
 static void layerCopy_mdeformvert(const void *source, void *dest,
@@ -445,142 +440,6 @@
 	}
 }
 
-#if 1 /* BMESH_TODO: place holder function, dont actually interp */
-static void layerInterp_mdisps(void **sources, float *UNUSED(weights),
-				float *UNUSED(sub_weights), int UNUSED(count), void *dest)
-{
-#if 0
-	MDisps *d = dest;
-
-	/* happens when flipping normals of newly created mesh */
-	if(!d->totdisp) {
-		d->totdisp = ((MDisps*)sources[0])->totdisp;
-	}
-
-	if (!d->disps && d->totdisp)
-		d->disps = MEM_callocN(sizeof(float)*3*d->totdisp, "blank mdisps in layerInterp_mdisps");
-#else
-	(void) sources;
-	(void) dest;
-#endif
-}
-
-#else // BMESH_TODO
-
-static void layerInterp_mdisps(void **sources, float *UNUSED(weights),
-				float *sub_weights, int count, void *dest)
-{
-	MDisps *d = dest;
-	MDisps *s = NULL;
-	int st, stl;
-	int i, x, y;
-	int side, S, dst_corners, src_corners;
-	float crn_weight[4][2];
-	float (*sw)[4] = (void*)sub_weights;
-	float (*disps)[3], (*out)[3];
-
-	/* happens when flipping normals of newly created mesh */
-	if(!d->totdisp)
-		return;
-
-	s = sources[0];
-	dst_corners = multires_mdisp_corners(d);
-	src_corners = multires_mdisp_corners(s);
-
-	if(sub_weights && count == 2 && src_corners == 3) {
-		src_corners = multires_mdisp_corners(sources[1]);
-
-		/* special case -- converting two triangles to quad */
-		if(src_corners == 3 && dst_corners == 4) {
-			MDisps tris[2];
-			int vindex[4] = {0};
-
-			for(i = 0; i < 2; i++)
-				for(y = 0; y < 4; y++)
-					for(x = 0; x < 4; x++)
-						if(sw[x+i*4][y])
-							vindex[x] = y;
-
-			for(i = 0; i < 2; i++) {
-				float sw_m4[4][4] = {{0}};
-				int a = 7 & ~(1 << vindex[i*2] | 1 << vindex[i*2+1]);
-
-				sw_m4[0][vindex[i*2+1]] = 1;
-				sw_m4[1][vindex[i*2]] = 1;
-
-				for(x = 0; x < 3; x++)
-					if(a & (1 << x))
-						sw_m4[2][x] = 1;
-
-				tris[i] = *((MDisps*)sources[i]);
-				tris[i].disps = MEM_dupallocN(tris[i].disps);
-				layerInterp_mdisps(&sources[i], NULL, (float*)sw_m4, 1, &tris[i]);
-			}
-
-			mdisp_join_tris(d, &tris[0], &tris[1]);
-
-			for(i = 0; i < 2; i++)
-				MEM_freeN(tris[i].disps);
-
-			return;
-		}
-	}
-
-	/* For now, some restrictions on the input */
-	if(count != 1 || !sub_weights) {
-		for(i = 0; i < d->totdisp; ++i)
-			zero_v3(d->disps[i]);
-
-		return;
-	}
-
-	/* Initialize the destination */
-	disps = MEM_callocN(3*d->totdisp*sizeof(float), "iterp disps");
-
-	side = sqrt(d->totdisp / dst_corners);
-	st = (side<<1)-1;
-	stl = st - 1;
-
-	sw= (void*)sub_weights;
-	for(i = 0; i < 4; ++i) {
-		crn_weight[i][0] = 0 * sw[i][0] + stl * sw[i][1] + stl * sw[i][2] + 0 * sw[i][3];
-		crn_weight[i][1] = 0 * sw[i][0] + 0 * sw[i][1] + stl * sw[i][2] + stl * sw[i][3];
-	}
-
-	multires_mdisp_smooth_bounds(s);
-
-	out = disps;
-	for(S = 0; S < dst_corners; S++) {
-		float base[2], axis_x[2], axis_y[2];
-
-		mdisp_apply_weight(S, dst_corners, 0, 0, st, crn_weight, &base[0], &base[1]);
-		mdisp_apply_weight(S, dst_corners, side-1, 0, st, crn_weight, &axis_x[0], &axis_x[1]);
-		mdisp_apply_weight(S, dst_corners, 0, side-1, st, crn_weight, &axis_y[0], &axis_y[1]);
-
-		sub_v2_v2(axis_x, base);
-		sub_v2_v2(axis_y, base);
-		normalize_v2(axis_x);
-		normalize_v2(axis_y);
-
-		for(y = 0; y < side; ++y) {
-			for(x = 0; x < side; ++x, ++out) {
-				int crn;
-				float face_u, face_v, crn_u, crn_v;
-
-				mdisp_apply_weight(S, dst_corners, x, y, st, crn_weight, &face_u, &face_v);
-				crn = mdisp_rot_face_to_quad_crn(src_corners, st, face_u, face_v, &crn_u, &crn_v);
-
-				old_mdisps_bilinear((*out), &s->disps[crn*side*side], side, crn_u, crn_v);
-				mdisp_flip_disp(crn, dst_corners, axis_x, axis_y, *out);
-			}
-		}
-	}
-
-	MEM_freeN(d->disps);
-	d->disps = disps;
-}
-#endif // BMESH_TODO
-
 static void layerCopy_mdisps(const void *source, void *dest, int count)
 {
 	int i;
@@ -600,25 +459,6 @@
 	}
 }
 
-static void layerValidate_mdisps(void *data, int sub_elements)
-{
-#if 1 /*BMESH_TODO*/
-	(void)data;
-	(void)sub_elements;
-#else
-	MDisps *disps = data;
-	if(disps->disps) {
-		int corners = multires_mdisp_corners(disps);
-
-		if(corners != sub_elements) {
-			MEM_freeN(disps->disps);
-			disps->totdisp = disps->totdisp / corners * sub_elements;
-			disps->disps = MEM_callocN(3*disps->totdisp*sizeof(float), "layerValidate_mdisps");
-		}
-	}
-#endif
-}
-
 static void layerFree_mdisps(void *data, int count, int UNUSED(size))
 {
 	int i;
@@ -1124,9 +964,9 @@
 	{sizeof(float)*4*4, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
 	/* 19: CD_MDISPS */
 	{sizeof(MDisps), "MDisps", 1, NULL, layerCopy_mdisps,
-	 layerFree_mdisps, layerInterp_mdisps, layerSwap_mdisps, NULL,
+	 layerFree_mdisps, NULL, layerSwap_mdisps, NULL,
 	 NULL, NULL, NULL, NULL, NULL, NULL, 
-	 layerRead_mdisps, layerWrite_mdisps, layerFilesize_mdisps, layerValidate_mdisps},
+	 layerRead_mdisps, layerWrite_mdisps, layerFilesize_mdisps},
 	/* 20: CD_WEIGHT_MCOL */
 	{sizeof(MCol)*4, "MCol", 4, "WeightCol", NULL, NULL, layerInterp_mcol,
 	 layerSwap_mcol, layerDefault_mcol},

Modified: trunk/blender/source/blender/blenkernel/intern/multires.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/multires.c	2012-02-21 17:24:05 UTC (rev 44303)
+++ trunk/blender/source/blender/blenkernel/intern/multires.c	2012-02-21 17:24:21 UTC (rev 44304)
@@ -1948,225 +1948,8 @@
 }
 #endif // BMESH_TODO
 
-/* makes displacement along grid boundary symmetrical */
-void multires_mdisp_smooth_bounds(MDisps *disps)
-{
-	int x, y, side, S, corners;
-	float (*out)[3];
-
-	corners = multires_mdisp_corners(disps);
-	side = sqrt(disps->totdisp / corners);
-
-	out = disps->disps;
-	for(S = 0; S < corners; S++) {
-		for(y = 0; y < side; ++y) {
-			for(x = 0; x < side; ++x, ++out) {
-				float (*dispgrid)[3];
-				float *data;
-
-				if(x != 0 && y != 0) continue;
-
-				if(corners == 4) {
-					if(S == 0) {
-						if(y == 0) {
-							dispgrid = &disps->disps[1*side*side];
-							data = dispgrid[side * x + 0];
-
-							(*out)[0] = (*out)[0] + data[1];
-							(*out)[1] = (*out)[1] - data[0];
-							(*out)[2] = (*out)[2] + data[2];
-
-							mul_v3_fl(*out, 0.5);
-
-							data[0] = -(*out)[1];
-							data[1] = (*out)[0];
-							data[2] = (*out)[2];
-						} else if (x == 0) {
-							dispgrid = &disps->disps[3 * side * side];
-							data = dispgrid[side * 0 + y];
-
-							(*out)[0] = (*out)[0] - data[1];
-							(*out)[1] = (*out)[1] + data[0];
-							(*out)[2] = (*out)[2] + data[2];
-
-							mul_v3_fl(*out, 0.5);
-
-							data[0] = (*out)[1];
-							data[1] = -(*out)[0];
-							data[2] = (*out)[2];
-						}
-					} else if (S == 2) {
-						if(y == 0) {
-							dispgrid = &disps->disps[3 * side * side];
-							data = dispgrid[side * x + 0];
-
-							(*out)[0] = (*out)[0] + data[1];
-							(*out)[1] = (*out)[1] - data[0];
-							(*out)[2] = (*out)[2] + data[2];
-
-							mul_v3_fl(*out, 0.5);
-
-							data[0] = -(*out)[1];
-							data[1] = (*out)[0];
-							data[2] = (*out)[2];
-						} else if(x == 0) {
-							dispgrid = &disps->disps[1 * side * side];
-							data = dispgrid[side * 0 + y];
-
-							(*out)[0] = (*out)[0] - data[1];
-							(*out)[1] = (*out)[1] + data[0];
-							(*out)[2] = (*out)[2] + data[2];
-
-							mul_v3_fl(*out, 0.5);
-
-							data[0] = (*out)[1];
-							data[1] = -(*out)[0];
-							data[2] = (*out)[2];
-						}
-					}
-				} else if (corners == 3) {
-					if(S == 0) {
-						if(y == 0) {
-							dispgrid = &disps->disps[1*side*side];
-							data = dispgrid[side * x + 0];
-
-							(*out)[0] = (*out)[0] + data[1];
-							(*out)[1] = (*out)[1] - data[0];
-							(*out)[2] = (*out)[2] + data[2];
-
-							mul_v3_fl(*out, 0.5);
-
-							data[0] = -(*out)[1];
-							data[1] = (*out)[0];
-							data[2] = (*out)[2];
-						} else if (x == 0) {
-							dispgrid = &disps->disps[2 * side * side];
-							data = dispgrid[side * 0 + y];
-
-							(*out)[0] = (*out)[0] - data[1];
-							(*out)[1] = (*out)[1] + data[0];
-							(*out)[2] = (*out)[2] + data[2];
-
-							mul_v3_fl(*out, 0.5);
-
-							data[0] = (*out)[1];
-							data[1] = -(*out)[0];
-							data[2] = (*out)[2];
-						}
-					} else if (S == 2) {
-						if(x == 0) {
-							dispgrid = &disps->disps[1 * side * side];
-							data = dispgrid[side * 0 + y];
-
-							(*out)[0] = (*out)[0] - data[1];
-							(*out)[1] = (*out)[1] + data[0];

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list