Skip to content

Commit

Permalink
always normalize bone weights
Browse files Browse the repository at this point in the history
  • Loading branch information
flyover committed Dec 23, 2016
1 parent c3eb2a7 commit 25c9c6e
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions demo/render-webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,23 +284,24 @@ RenderWebGL.prototype.loadData = function(spine_data, atlas_data, images) {
}

// sort the blender array descending by weight
blender_array = blender_array.sort(function(a, b) {
blender_array.sort(function(a, b) {
return b.weight - a.weight;
});

// clamp blender array and adjust weights
if (blender_array.length > render.gl_skin_shader_blenders_count) {
console.log("blend array length for", attachment_key, "is", blender_array.length, "so clamp to", render.gl_skin_shader_blenders_count);
blender_array.length = render.gl_skin_shader_blenders_count;
var weight_sum = 0;
blender_array.forEach(function(blend) {
weight_sum += blend.weight;
});
blender_array.forEach(function(blend) {
blend.weight /= weight_sum;
});
}

var weight_sum = 0;
blender_array.forEach(function(blend) {
weight_sum += blend.weight;
});
blender_array.forEach(function(blend) {
blend.weight /= weight_sum;
});

var position_x = 0;
var position_y = 0;
var blend_position = new spine.Vector();
Expand Down

0 comments on commit 25c9c6e

Please sign in to comment.