When stopping animation, make sure to update the meshes if the model was
outside the view frustum on the last update. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@109 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -601,6 +601,10 @@ public class Model extends ModelNode
|
|||||||
if (_anim == null) {
|
if (_anim == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (_outside) {
|
||||||
|
// make sure the meshes are in the right places when we come back into view
|
||||||
|
updateMeshes();
|
||||||
|
}
|
||||||
_paused = false;
|
_paused = false;
|
||||||
_anim = null;
|
_anim = null;
|
||||||
_animObservers.apply(new AnimCancelledOp(_animName));
|
_animObservers.apply(new AnimCancelledOp(_animName));
|
||||||
@@ -982,37 +986,7 @@ public class Model extends ModelNode
|
|||||||
// update the target transforms and animation frame if not outside the
|
// update the target transforms and animation frame if not outside the
|
||||||
// view frustum
|
// view frustum
|
||||||
if (!_outside) {
|
if (!_outside) {
|
||||||
if (_animMode == AnimationMode.FLIPBOOK) {
|
updateMeshes();
|
||||||
int frameId = (_anim.animId << 16) | _fidx;
|
|
||||||
_anim.applyFrame(_fidx);
|
|
||||||
if (!_anim.stored[_fidx]) {
|
|
||||||
storeMeshFrame(frameId, false);
|
|
||||||
updateWorldData(0f);
|
|
||||||
_anim.stored[_fidx] = true;
|
|
||||||
}
|
|
||||||
setMeshFrame(frameId);
|
|
||||||
|
|
||||||
} else if (_animMode == AnimationMode.MORPH) {
|
|
||||||
int frameId1 = (_anim.animId << 16) | _fidx,
|
|
||||||
frameId2 = (_anim.animId << 16) | _nidx;
|
|
||||||
if (!_anim.stored[_fidx]) {
|
|
||||||
storeMeshFrame(frameId1, true);
|
|
||||||
_anim.applyFrame(_fidx);
|
|
||||||
updateWorldData(0f);
|
|
||||||
_anim.stored[_fidx] = true;
|
|
||||||
}
|
|
||||||
if (!_anim.stored[_nidx]) {
|
|
||||||
storeMeshFrame(frameId2, true);
|
|
||||||
_anim.applyFrame(_nidx);
|
|
||||||
updateWorldData(0f);
|
|
||||||
_anim.stored[_nidx] = true;
|
|
||||||
}
|
|
||||||
_anim.blendFrames(_fidx, _nidx, _elapsed);
|
|
||||||
blendMeshFrames(frameId1, frameId2, _elapsed);
|
|
||||||
|
|
||||||
} else { // _animMode == AnimationMode.SKIN
|
|
||||||
_anim.blendFrames(_fidx, _nidx, _elapsed);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the next index is the same as this one, we are finished
|
// if the next index is the same as this one, we are finished
|
||||||
@@ -1045,6 +1019,44 @@ public class Model extends ModelNode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the states of the model's meshes according to the animation state.
|
||||||
|
*/
|
||||||
|
protected void updateMeshes ()
|
||||||
|
{
|
||||||
|
if (_animMode == AnimationMode.FLIPBOOK) {
|
||||||
|
int frameId = (_anim.animId << 16) | _fidx;
|
||||||
|
_anim.applyFrame(_fidx);
|
||||||
|
if (!_anim.stored[_fidx]) {
|
||||||
|
storeMeshFrame(frameId, false);
|
||||||
|
updateWorldData(0f);
|
||||||
|
_anim.stored[_fidx] = true;
|
||||||
|
}
|
||||||
|
setMeshFrame(frameId);
|
||||||
|
|
||||||
|
} else if (_animMode == AnimationMode.MORPH) {
|
||||||
|
int frameId1 = (_anim.animId << 16) | _fidx,
|
||||||
|
frameId2 = (_anim.animId << 16) | _nidx;
|
||||||
|
if (!_anim.stored[_fidx]) {
|
||||||
|
storeMeshFrame(frameId1, true);
|
||||||
|
_anim.applyFrame(_fidx);
|
||||||
|
updateWorldData(0f);
|
||||||
|
_anim.stored[_fidx] = true;
|
||||||
|
}
|
||||||
|
if (!_anim.stored[_nidx]) {
|
||||||
|
storeMeshFrame(frameId2, true);
|
||||||
|
_anim.applyFrame(_nidx);
|
||||||
|
updateWorldData(0f);
|
||||||
|
_anim.stored[_nidx] = true;
|
||||||
|
}
|
||||||
|
_anim.blendFrames(_fidx, _nidx, _elapsed);
|
||||||
|
blendMeshFrames(frameId1, frameId2, _elapsed);
|
||||||
|
|
||||||
|
} else { // _animMode == AnimationMode.SKIN
|
||||||
|
_anim.blendFrames(_fidx, _nidx, _elapsed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** A reference to the prototype, or <code>null</code> if this is a
|
/** A reference to the prototype, or <code>null</code> if this is a
|
||||||
* prototype. */
|
* prototype. */
|
||||||
protected Model _prototype;
|
protected Model _prototype;
|
||||||
|
|||||||
Reference in New Issue
Block a user