OgreXML MeshAnimation Bug

I don't actually have access to the repo but I thought I'd post a bug fix:



Apparently the way the animation was iterating over the vertices to add the bone weights, it was overrunning its bounds. If you do the math - if you keep the index buffer and weight buffer in the loop, it would skip to the "next four weights" for each weight access. This seems counterintuitive. If you have a variable called "fourminusmaxweights" then I'd assume you'd want to do that after accessing all weights in that block. I moved it out of the loop and all my multiple weight per vertex animations worked.



Thanks for looking this over and possibly committing it!







Index: MeshAnimationController.java
===================================================================
--- MeshAnimationController.java   (revision 4531)
+++ MeshAnimationController.java   (working copy)
@@ -364,9 +364,11 @@
 //                resultNorm.y += temp.y * weight;
 //                resultNorm.z += temp.z * weight;
 
-                ib.position(ib.position()+fourMinusMaxWeights);
-                wb.position(wb.position()+fourMinusMaxWeights);
+
             }
+           
+            ib.position(ib.position()+fourMinusMaxWeights);
+            wb.position(wb.position()+fourMinusMaxWeights);
 
             // overwrite vertex with transformed pos
             vb.position(vb.position()-3);


This has already been mentioned before and a fix was comitted on July31/2009 -



http://www.jmonkeyengine.com/forum/index.php?topic=11790.0


Whoops. Sorry - should have updated first I guess :stuck_out_tongue:

no problem, at least it shows you care  :smiley:

It's also filed under Issue 46 in the Issue Tracker, now marked as fixed :slight_smile: