Commit: 85aa2b445d9e0180976e6db0b2c2ad3dee0e234b
Author: Lukas Tönne
Date:   Tue Feb 3 10:49:51 2015 +0100
Branches: temp_hair_modifiers
https://developer.blender.org/rB85aa2b445d9e0180976e6db0b2c2ad3dee0e234b

Generalized the low-level `meshdeform_matrix_solve` function to make it
independent from the MeshDeform modifier.

The modifier is just used for error reports here, so can easily be
replaced by a callback.

===================================================================

M       source/blender/editors/armature/meshlaplacian.c

===================================================================

diff --git a/source/blender/editors/armature/meshlaplacian.c 
b/source/blender/editors/armature/meshlaplacian.c
index b7d14e0..ad5e2bf 100644
--- a/source/blender/editors/armature/meshlaplacian.c
+++ b/source/blender/editors/armature/meshlaplacian.c
@@ -1091,6 +1091,8 @@ typedef struct MeshDeformBind {
        
        BVHTree *bvhtree;
        BVHTreeFromMesh bvhdata;
+
+       void (*report_error)(void *userdata, const char *message);
 } MeshDeformBind;
 
 typedef struct MeshDeformIsect {
@@ -1604,7 +1606,7 @@ static void 
meshdeform_matrix_add_exterior_phi(MeshDeformBind *mdb, int x, int y
                mdb->phi[acenter] = phi / totweight;
 }
 
-static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, 
MeshDeformBind *mdb)
+static void meshdeform_matrix_solve(void *userdata, MeshDeformBind *mdb)
 {
        NLContext *context;
        float vec[3], gridvec[3];
@@ -1706,7 +1708,8 @@ static void 
meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
                        }
                }
                else {
-                       modifier_setError(&mmd->modifier, "Failed to find bind 
solution (increase precision?)");
+                       if (mdb->report_error)
+                               mdb->report_error(userdata, "Failed to find 
bind solution (increase precision?)");
                        error("Mesh Deform: failed to find bind solution.");
                        break;
                }
@@ -1941,6 +1944,12 @@ static void heat_weighting_bind(Scene *scene, 
DerivedMesh *dm, MeshDeformModifie
 }
 #endif
 
+static void mesh_deform_modifier_report_error(void *vmd, const char *message)
+{
+       ModifierData *md = vmd;
+       modifier_setError(md, "%s", message);
+}
+
 void mesh_deform_bind(Scene *scene, MeshDeformModifierData *mmd, float 
*vertexcos, int totvert, float cagemat[4][4])
 {
        MeshDeformBind mdb;
@@ -1952,6 +1961,8 @@ void mesh_deform_bind(Scene *scene, 
MeshDeformModifierData *mmd, float *vertexco
 
        memset(&mdb, 0, sizeof(MeshDeformBind));
 
+       mdb.report_error = mesh_deform_modifier_report_error;
+
        /* get mesh and cage mesh */
        mdb.vertexcos = MEM_callocN(sizeof(float) * 3 * totvert, 
"MeshDeformCos");
        mdb.totvert = totvert;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to