[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60802] branches/vgroup_modifiers/source/ blender/gpu/intern/gpu_buffers.c: Yeah, sharp edges preview in viewport!

Bastien Montagne montagne29 at wanadoo.fr
Wed Oct 16 16:44:53 CEST 2013


Revision: 60802
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60802
Author:   mont29
Date:     2013-10-16 14:44:53 +0000 (Wed, 16 Oct 2013)
Log Message:
-----------
Yeah, sharp edges preview in viewport!

Ok, now the "bad news"! :P
*Only works in Object mode (not Edit, uses a different draw code), and no Legacy mode supported (at least, I think).
*Smooth/sharp faces, when set in Edit mode, does not work for some reason - as far as I can say, the MPoly ME_SMOOTH flag is not correctly updated, even switching back and force between Object and Edit modes does not fix that.
*That BMesh segfault is still present. Things are OK when you only deform existing geometry, but as soon as you change it, you get some kind of memory corruption. Probably have to take a closer look at CDlayers handling inside BMesh...

Note that I do not intend to develop further loopnormal preview in viewport for now, for two reasons:
*The important point is having valid, useable loop normals in tessellated data. This currently seems to work OKish, though there is probably more work to be done here.
*Converting those tessellated loop normals in GPU stuff is really the same as when using vertex/face normals. Further more, our draw code may be heavyly refactored in the near future (there is a GSOC on this topic), so I?\226?\128?\153d rather add as few as possible changes here for now.

Modified Paths:
--------------
    branches/vgroup_modifiers/source/blender/gpu/intern/gpu_buffers.c

Modified: branches/vgroup_modifiers/source/blender/gpu/intern/gpu_buffers.c
===================================================================
--- branches/vgroup_modifiers/source/blender/gpu/intern/gpu_buffers.c	2013-10-16 13:21:52 UTC (rev 60801)
+++ branches/vgroup_modifiers/source/blender/gpu/intern/gpu_buffers.c	2013-10-16 14:44:53 UTC (rev 60802)
@@ -683,6 +683,7 @@
 	float f_no[3];
 
 	float *nors = dm->getTessFaceDataArray(dm, CD_NORMAL);
+	float (*tlnors)[3] = dm->getTessFaceDataArray(dm, CD_TESSLOOPNORMAL);
 	MVert *mvert = dm->getVertArray(dm);
 	MFace *f = dm->getTessFaceArray(dm);
 
@@ -693,7 +694,20 @@
 		start = index[mat_orig_to_new[f->mat_nr]];
 		index[mat_orig_to_new[f->mat_nr]] += f->v4 ? 18 : 9;
 
-		if (smoothnormal) {
+		if (tlnors) {
+			float (*tlnor)[3] = &tlnors[i * 4];
+			/* Copy loop normals */
+			copy_v3_v3(&varray[start], tlnor[0]);
+			copy_v3_v3(&varray[start + 3], tlnor[1]);
+			copy_v3_v3(&varray[start + 6], tlnor[2]);
+
+			if (f->v4) {
+				copy_v3_v3(&varray[start + 9], tlnor[2]);
+				copy_v3_v3(&varray[start + 12], tlnor[3]);
+				copy_v3_v3(&varray[start + 15], tlnor[0]);
+			}
+		}
+		else if (smoothnormal) {
 			/* copy vertex normal */
 			normal_short_to_float_v3(&varray[start], mvert[f->v1].no);
 			normal_short_to_float_v3(&varray[start + 3], mvert[f->v2].no);




More information about the Bf-blender-cvs mailing list