[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13456] trunk/blender/source/blender/src/ meshlaplacian.c:
Brecht Van Lommel
brechtvanlommel at pandora.be
Tue Jan 29 20:19:21 CET 2008
Revision: 13456
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13456
Author: blendix
Date: 2008-01-29 20:19:21 +0100 (Tue, 29 Jan 2008)
Log Message:
-----------
Fix for bug #8029: heat weighting clamps values below a threshold,
which could give discontinuities, now it does a blend instead.
Modified Paths:
--------------
trunk/blender/source/blender/src/meshlaplacian.c
Modified: trunk/blender/source/blender/src/meshlaplacian.c
===================================================================
--- trunk/blender/source/blender/src/meshlaplacian.c 2008-01-29 18:47:40 UTC (rev 13455)
+++ trunk/blender/source/blender/src/meshlaplacian.c 2008-01-29 19:19:21 UTC (rev 13456)
@@ -380,7 +380,8 @@
Ilya Baran and Jovan Popovic, SIGGRAPH 2007 */
#define C_WEIGHT 1.0f
-#define WEIGHT_LIMIT 0.05f
+#define WEIGHT_LIMIT_START 0.05f
+#define WEIGHT_LIMIT_END 0.025f
#define DISTANCE_EPSILON 1e-4f
/* Raytracing for vertex to bone visibility */
@@ -601,6 +602,21 @@
heat_set_H(sys, a);
}
+static float heat_limit_weight(float weight)
+{
+ float t;
+
+ if(weight < WEIGHT_LIMIT_END) {
+ return 0.0f;
+ }
+ else if(weight < WEIGHT_LIMIT_START) {
+ t= (weight - WEIGHT_LIMIT_END)/(WEIGHT_LIMIT_START - WEIGHT_LIMIT_END);
+ return t*WEIGHT_LIMIT_START;
+ }
+ else
+ return weight;
+}
+
void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numbones, bDeformGroup **dgrouplist, bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3], int *selected)
{
LaplacianSystem *sys;
@@ -673,8 +689,9 @@
WEIGHT_ADD);
}
else {
- if(solution > WEIGHT_LIMIT)
- add_vert_to_defgroup(ob, dgrouplist[j], a, solution,
+ weight= heat_limit_weight(solution);
+ if(weight > 0.0f)
+ add_vert_to_defgroup(ob, dgrouplist[j], a, weight,
WEIGHT_REPLACE);
else
remove_vert_defgroup(ob, dgrouplist[j], a);
@@ -688,9 +705,10 @@
solution, WEIGHT_ADD);
}
else {
- if(solution > WEIGHT_LIMIT)
+ weight= heat_limit_weight(solution);
+ if(weight > 0.0f)
add_vert_to_defgroup(ob, dgroupflip[j], vertsflipped[a],
- solution, WEIGHT_REPLACE);
+ weight, WEIGHT_REPLACE);
else
remove_vert_defgroup(ob, dgroupflip[j], vertsflipped[a]);
}
@@ -708,12 +726,14 @@
if(bbone && lastsegment) {
for(a=0; a<me->totvert; a++) {
weight= get_vert_defgroup(ob, dgrouplist[j], a);
- if(weight > 0.0f && weight <= WEIGHT_LIMIT)
+ weight= heat_limit_weight(weight);
+ if(weight <= 0.0f)
remove_vert_defgroup(ob, dgrouplist[j], a);
if(vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0) {
weight= get_vert_defgroup(ob, dgroupflip[j], vertsflipped[a]);
- if(weight > 0.0f && weight <= WEIGHT_LIMIT)
+ weight= heat_limit_weight(weight);
+ if(weight <= 0.0f)
remove_vert_defgroup(ob, dgroupflip[j], vertsflipped[a]);
}
}
More information about the Bf-blender-cvs
mailing list