Fix for [#21718] Shrinkwrap's "Project" mode with offset gives wrong results.
authorJanne Karhu <jhkarh@gmail.com>
Wed, 22 Sep 2010 09:38:11 +0000 (09:38 +0000)
committerJanne Karhu <jhkarh@gmail.com>
Wed, 22 Sep 2010 09:38:11 +0000 (09:38 +0000)
* normal offset not taken properly into account
* wrong usage of BVHTree (epsilon != radius) caused massive slowdowns in calculations, for example just opening test file took about 30 s on my machine, after fix about 0.5 s :)

source/blender/blenkernel/intern/shrinkwrap.c

index 01652aaa7139e5a33668e94bb0e6b8978b7a2779..f64854f90de08dcf28649b3d04bcaf0696205615 100644 (file)
@@ -337,7 +337,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct S
        }
 
        //After sucessufuly build the trees, start projection vertexs
-       if( bvhtree_from_mesh_faces(&treeData, calc->target, calc->keepDist, 4, 6)
+       if( bvhtree_from_mesh_faces(&treeData, calc->target, 0.0, 4, 6)
        &&  (auxMesh == NULL || bvhtree_from_mesh_faces(&auxData, auxMesh, 0.0, 4, 6)))
        {
 
@@ -383,6 +383,9 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct S
                                        normal_projection_project_vertex(0, tmp_co, tmp_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData);
 
                                normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, tmp_no, &calc->local2target, treeData.tree, &hit, treeData.raycast_callback, &treeData);
+
+                               if(hit.index != -1)
+                                       madd_v3_v3v3fl(hit.co, hit.co, tmp_no, -calc->keepDist);
                        }
 
                        //Project over negative direction of axis
@@ -395,6 +398,9 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct S
                                        normal_projection_project_vertex(0, tmp_co, inv_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData);
 
                                normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, inv_no, &calc->local2target, treeData.tree, &hit, treeData.raycast_callback, &treeData);
+
+                               if(hit.index != -1)
+                                       madd_v3_v3v3fl(hit.co, hit.co, tmp_no, calc->keepDist);
                        }