mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
fix backward animation playing
This commit is contained in:
parent
cc32ef9d8c
commit
dce135ab10
@ -72,7 +72,10 @@ get_frame_rate() const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int AnimControl::
|
||||
get_frame() const {
|
||||
return (int)(_frame + 0.0001);
|
||||
// We have to use floor() here instead of simply casting the number
|
||||
// to an integer, becase the frame number might have become
|
||||
// negative.
|
||||
return (int)floor(_frame + 0.0001);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -382,7 +382,12 @@ advance_time(double time) {
|
||||
do_actions_backward(orig_frame-1, new_frame);
|
||||
} else {
|
||||
if (do_actions_backward(orig_frame-1, 0)) {
|
||||
_frame = _frame - (int)(_frame / num_frames) * num_frames;
|
||||
// floor() is correct here, instead of simply an integer
|
||||
// cast, because we are using floating-point arithmetic
|
||||
// anyway (no need to convert to integer format and back
|
||||
// again), and because we need correct behavior when the
|
||||
// frame number is negative.
|
||||
_frame = _frame - floor(_frame / num_frames) * num_frames;
|
||||
new_frame = get_frame();
|
||||
do_actions_backward(get_num_frames(), new_frame);
|
||||
}
|
||||
@ -394,7 +399,12 @@ advance_time(double time) {
|
||||
do_actions_forward(orig_frame+1, new_frame);
|
||||
} else {
|
||||
if (do_actions_forward(orig_frame+1, get_num_frames()-1)) {
|
||||
_frame = _frame - (int)(_frame / num_frames) * num_frames;
|
||||
// floor() is correct here, instead of simply an integer
|
||||
// cast, because we are using floating-point arithmetic
|
||||
// anyway (no need to convert to integer format and back
|
||||
// again), and because we need correct behavior when the
|
||||
// frame number is negative.
|
||||
_frame = _frame - floor(_frame / num_frames) * num_frames;
|
||||
new_frame = get_frame();
|
||||
do_actions_forward(0, new_frame);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user