The % operator in Java is not a modulo operator but a remainder

operator.  As such, the result can be negative.  I've added a check to 
prevent our next frame index from becoming negative.


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@141 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Mark Johnson
2007-02-01 23:01:46 +00:00
parent a8e905f419
commit a32f3a65e5
@@ -1009,7 +1009,11 @@ public class Model extends ModelNode
_nidx = Math.max(0, Math.min(_nidx + _fdir, nframes - 1));
} else if (_anim.repeatType == Controller.RT_WRAP) {
// % is not a modulo operator, so is not guaranteed to be positive
_nidx = (_nidx + _fdir) % nframes;
if (_nidx < 0) {
_nidx += nframes;
}
} else { // _anim.repeatType == Controller.RT_CYCLE
if ((_nidx + _fdir) < 0 || (_nidx + _fdir) >= nframes) {