View Issue Details

IDProjectCategoryView StatusLast Update
0003800The Dark ModAnimationpublic20.01.2015 00:12
ReporterSteveL Assigned ToSteveL  
PrioritynormalSeveritynormalReproducibilityalways
Status resolvedResolutionfixed 
Product VersionTDM 2.02 
Target VersionTDM 2.03Fixed in VersionTDM 2.03 
Summary0003800: anim tasks (path anim, path cycle anim, play anim) snap in without blending
Descriptionpath_anim snaps to the first frame of the animation without any blending of current animations. The blend_in spawnarg isn't used until after the animation has started, so it has no effect.
Additional InformationPathAnimTask makes use of the script event playAnim but it works a bit differently from general script-fired animations. Scripted animation tasks do it this way:
• call the animState script event to start the animation
• animState sets a variable to store the desired blend frames for the next animation, and it puts the AI scripts in a "wait" state so that the scripts don't play idle anims over the requested anim
• it then passes control back to the AI scripts
• which then call playAnim
• which checks the variable set by animState to find out how many frames to blend over, and plays the animation
• Afterwards, it zeroes out the variable that says how many blend frames to use, ready for the next animState

PathAnimTask does things in a different order:
• It calls playAnim *first* before setting the blend frames variable, which will still be sitting at 0
• It then calls animState as usual so that idle anims do not override the requested anim
• animState sets the right number of blend frames, but too late to affect the path animation

We can't just muscle in and have PathAnimTask set the variable itself. That variable is private to the animState. And we can't simply switch the order of the first two events above: the wait state won't last unless the anim is already playing. Need to look for other options. One would be for animState to provide a method for setting the "blend frames" variable directly, but there might be more elegant ways to fix it.
TagsNo tags attached.

Relationships

related to 0004012 resolvedSteveL Sitting guard in Old Habits 2 can't get up 
related to 0003770 resolvedSteveL Make LOD work for AI 
related to 0003597 resolvedSteveL Firing AI animations through a script has problems 

Activities

SteveL

SteveL

16.08.2014 06:18

reporter   ~0006852

Last edited: 16.08.2014 06:27

[untested] PlayAnimationTask and PathCycleAnimTask have the same set-up and probably share the problem

SteveL

SteveL

16.08.2014 06:26

reporter   ~0006853

Best fix is to move the job of starting the animation from the c++ code to the ai AnimState scripts, ai_darkmod_base::Torso_CustomAnim and Legs_CustomAnim. The other AnimState scripts all start their own animations, which is why they can do the things above in the right order. Nothing else uses those script functions. These tasks can use the same setup.
SteveL

SteveL

29.08.2014 18:10

reporter   ~0006903

Last edited: 29.08.2014 18:32

These scripts (ai_darkmod_base::Torso_CustomAnim and Legs_CustomAnim) are used only by those 3 tasks in the Game c++ code. No scripts in the core mod or published maps use them.

To implement this fix, the scripts need to know what anim to play, but those tasks use different spawnargs and have their own record of what to play. So to minimise disruption to the existing setup I propose to get the tasks to set 2 keys on the Actor, specifying the required anim and whether to cycle, and the script events will read those keys. The other animState scripts interpret spawnargs to find out what to play too.

PlayAnimationTask is used by conversations, and the state subsystem. I'll use a conversation in the test map.

SteveL

SteveL

29.08.2014 23:32

reporter   ~0006906

Hmm blend_in not being used isn't the whole of the story. Something is actively kicking the animation out of kilter for the path anim tasks but not the play anim task.
SteveL

SteveL

30.08.2014 12:10

reporter   ~0006908

The second bug is that the legs channel is being sync'd to the torso by the two path tasks without any blending. That means that if the legs are playing a different anim from the torso when the task starts, the legs anim is being lost in a single frame.
SteveL

SteveL

30.08.2014 12:13

reporter   ~0006909

Last edited: 30.08.2014 12:15

A side-effect of this fix should be that scripts will finally be able to play anims without those anims getting interrupted by idle or patrolling anims, by setting the keys and calling AnimState(ANIMCHANNEL_TORSO, "Torso_CustomAnim", 12); etc.

Wants testing then wrapping in a more user-friendly script function.

SteveL

SteveL

30.08.2014 13:19

reporter   ~0006910

A problem with the fix: frame commands are now being called on both anim channels.
Sync'ing the anims channels is supposed to take care of that.
SteveL

SteveL

30.08.2014 15:27

reporter   ~0006911

The sync is happening before the animations are starting, because the AI scripts post PlayAnim as an event, and the c++ code is running the sync before the events get processed.

Putting the call to SyncAnimChannels on the event queue with zero ms delay doesn't work -- it still gets processed before the PlayAnim events.

Giving it 16ms (1 frame) delay works 80% of the time, but it can still fail. And it risks a double-call of a frame command for any anims that have a command in the first frame.
SteveL

SteveL

30.08.2014 18:05

reporter   ~0006912

Last edited: 31.08.2014 03:06

Moving the Sync call to the scripts doesn't help. Still getting duplicate frame commands, saying to destroy attachments spawned by an anim. Either script events can fire out of sequence, or something else is intervening to re-enable the frame commands on the legs channel. None of the script events seem to do a deferred hand-off.

UPDATE: the commands probably aren't out of sync. The second option was true: something else was fiddling with the setting:

SteveL

SteveL

31.08.2014 03:03

reporter   ~0006915

It was the new AI LOD transition causing the duplicate frame commands. Testing this issue has revealed a subtle bug in the animated LOD setup: the LOD code does a model swap and restores same-named anims at the right frame, if the md5 skeletons are compatible. But it needs to restore more than that: whether or not an animation is allowed to fire off frame commands, for example.

That parameter is private to idAnimBlend right now, so I've added an accessor FrameCommandsAllowed() so that the LOD code can see it and restore it.

I'll add a child issue to the AI LOD tracker to add a LOD copy method to idAnimBlend, so we can transfer the rest of the flags with LOD too. I suspect most are not used, but even if so they might be in future.
SteveL

SteveL

31.08.2014 04:15

reporter   ~0006916

Committed at rv6094 (code) rv13974 (script, binaries)

Issue History

Date Modified Username Field Change
27.07.2014 14:27 SteveL New Issue
27.07.2014 14:27 SteveL Status new => assigned
27.07.2014 14:27 SteveL Assigned To => SteveL
27.07.2014 14:28 SteveL Description Updated
16.08.2014 06:18 SteveL Note Added: 0006852
16.08.2014 06:26 SteveL Note Added: 0006853
16.08.2014 06:27 SteveL Note Edited: 0006852
29.08.2014 18:10 SteveL Note Added: 0006903
29.08.2014 18:32 SteveL Note Edited: 0006903
29.08.2014 23:32 SteveL Note Added: 0006906
30.08.2014 12:10 SteveL Note Added: 0006908
30.08.2014 12:13 SteveL Note Added: 0006909
30.08.2014 12:15 SteveL Note Edited: 0006909
30.08.2014 13:19 SteveL Note Added: 0006910
30.08.2014 15:27 SteveL Note Added: 0006911
30.08.2014 18:05 SteveL Note Added: 0006912
30.08.2014 18:06 SteveL Note Edited: 0006912
31.08.2014 03:03 SteveL Note Added: 0006915
31.08.2014 03:06 SteveL Note Edited: 0006912
31.08.2014 03:14 SteveL Relationship added related to 0003770
31.08.2014 04:11 SteveL Summary path_anim does not use blending => anim tasks (path anim, path cycle anim, play anim) snap in without blending
31.08.2014 04:15 SteveL Note Added: 0006916
31.08.2014 04:16 SteveL Status assigned => resolved
31.08.2014 04:16 SteveL Fixed in Version => TDM 2.03
31.08.2014 04:16 SteveL Resolution open => fixed
10.09.2014 19:19 SteveL Relationship added related to 0003597
20.01.2015 00:12 SteveL Relationship added related to 0004012