Source Code Project Mantis - FSSCP
View Issue Details
0002542FSSCPmath-relatedpublic2011-11-14 05:352019-12-14 13:01
Assigned ToGoober5000 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0002542: model_anim_get_time_type doesn't return correct value for triggered animations
DescriptionAfter triggering an animation, calls to ship:getAnimationDoneTime("scripted", 0) consistently return a garbage value as long as the animation plays.

I've tracked it down to model/modelanim.cpp:model_anim_get_time_type line 655 (note that line 650 is probably similarly affected, but the code just never goes there in my testcase), where a_time is consistently getting the value -2147483648 as long as the animation is playing.

I don't know if there's a problem with the math on that line, or whether the necessary animation data is not getting set for triggered animations somewhere else.

Unfortunately I have no portable complete testcase to provide. Below is a test script which displays timing information for a triggered animation on the player's ship; if you fly a ship with a triggered animation, you should see getAnimationDoneTime() returning a bogus value while the animation plays and the correct value (current time + the animation length) otherwise.

I haven't ruled out the possibility that this affects other animations than triggered ones, since model_anim_get_time_type the function is called from other places as well.
Additional Information;Note that this requires r7990, which fixes getAnimationDoneTime
;into returning the time in seconds as it should.

;You might also notice that when the animation is not playing,
;the value returned by getAnimationDoneTime progressively shrinks
;as the mission proceeds. This seems to be an unrelated issue.

#Conditional Hooks


$On Frame: [

    if hv.Player ~= nil and hv.Player:isValid() then
        gr.setColor(255, 255, 255)
        gr.drawString("Animation time remaining: " .. tostring(hv.Player:getAnimationDoneTime("scripted", 0) - mn.getMissionTime()), 300, 500)
        gr.drawString(" getAnimationDoneTime: " .. tostring(hv.Player:getAnimationDoneTime("scripted", 0)))
        gr.drawString(" getMissionTime: " .. tostring(mn.getMissionTime()))


TagsNo tags attached.
Attached Files

2011-11-20 03:15   
The patch posted at partially fixes the issue. If that is verified as working as advertised and gets committed, this report should probably be closed, as the remaining issues are a bit different.
2019-12-14 02:13   
See PR 2195:
2019-12-14 13:01   
The PR has been merged.

Issue History
2011-11-14 05:35zookeeperNew Issue
2011-11-20 03:15zookeeperNote Added: 0012983
2012-02-09 02:02Goober5000Assigned To => Goober5000
2012-02-09 02:02Goober5000Statusnew => assigned
2019-12-14 02:13Goober5000Note Added: 0016943
2019-12-14 13:01Goober5000Statusassigned => resolved
2019-12-14 13:01Goober5000Resolutionopen => fixed
2019-12-14 13:01Goober5000Note Added: 0016944