[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34986] trunk/blender/source/blender/ blenkernel/intern/shrinkwrap.c: fix for string wrap backface culling not working when one of the objects was rotated .

Campbell Barton ideasman42 at gmail.com
Sat Feb 19 10:01:29 CET 2011


Revision: 34986
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34986
Author:   campbellbarton
Date:     2011-02-19 09:01:28 +0000 (Sat, 19 Feb 2011)
Log Message:
-----------
fix for string wrap backface culling not working when one of the objects was rotated.
also skip calculating the dot product if its not needed.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/shrinkwrap.c

Modified: trunk/blender/source/blender/blenkernel/intern/shrinkwrap.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/shrinkwrap.c	2011-02-19 04:28:07 UTC (rev 34985)
+++ trunk/blender/source/blender/blenkernel/intern/shrinkwrap.c	2011-02-19 09:01:28 UTC (rev 34986)
@@ -255,22 +255,26 @@
 
 	BLI_bvhtree_ray_cast(tree, co, no, 0.0f, &hit_tmp, callback, userdata);
 
-	if(hit_tmp.index != -1)
-	{
-		float dot = INPR( dir, hit_tmp.no);
+	if(hit_tmp.index != -1) {
+		/* invert the normal first so face culling works on rotated objects */
+		if(transf) {
+			space_transform_invert_normal(transf, hit_tmp.no);
+		}
 
-		if(((options & MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE) && dot <= 0.0f)
-		|| ((options & MOD_SHRINKWRAP_CULL_TARGET_BACKFACE) && dot >= 0.0f))
-			return FALSE; //Ignore hit
+		if (options & (MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE|MOD_SHRINKWRAP_CULL_TARGET_BACKFACE)) {
+			/* apply backface */
+			const float dot= dot_v3v3(dir, hit_tmp.no);
+			if(	((options & MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE) && dot <= 0.0f) ||
+				((options & MOD_SHRINKWRAP_CULL_TARGET_BACKFACE) && dot >= 0.0f)
+			) {
+				return FALSE; /* Ignore hit */
+			}
+		}
 
-
-		//Inverting space transform (TODO make coeherent with the initial dist readjust)
-		if(transf)
-		{
-			space_transform_invert( transf, hit_tmp.co );
-			space_transform_invert_normal( transf, hit_tmp.no );
-
-			hit_tmp.dist = len_v3v3( (float*)vert, hit_tmp.co );
+		if(transf) {
+			/* Inverting space transform (TODO make coeherent with the initial dist readjust) */
+			space_transform_invert(transf, hit_tmp.co);
+			hit_tmp.dist = len_v3v3((float *)vert, hit_tmp.co);
 		}
 
 		memcpy(hit, &hit_tmp, sizeof(hit_tmp) );




More information about the Bf-blender-cvs mailing list