FWGS / xash3d

DEPRECATED in favor of https://github.com/FWGS/xash3d-fwgs. Only bugfixes are accepted.
https://xash.su
GNU General Public License v3.0
549 stars 107 forks source link

StudioMDL animation events don't fire if r_studio_lerping is 0 #404

Open noodlecollie opened 5 years ago

noodlecollie commented 5 years ago

I found in my own fork that the animation events for my weapon view model would be ignored unless I'd previously fired the weapon. I tracked this down to R_StudioEstimateFrame() stubbornly returning 0 when called from R_StudioClientEvents(), which would essentially act as though the animation was not playing.

I established that there were in theory only two things that should affect the return value of R_StudioEstimateFrame() in this way: one would be if the cl_entity_t's curstate.frame was 0, and the other was if m_fDoInterp was false. From experimentation it appears that curstate.frame is actually always 0, even in cases where events are fired as they should be (I'm not sure if this is expected behaviour or not?). However, if m_flDoInterp is true then the returned value is interpolated (I'm assuming) accurately.

It appears that m_fDoInterp remains true after the first time the weapon has been fired, so subsequent animation events are fired properly. However, to me this doesn't feel like intended behaviour. m_fDoInterp is set in R_DrawStudioModelInternal() according to the value of r_studio_lerping; in theory it is always set to true if that function is drawing the current view model, but I was able to reproduce my original bug where animation events did not fire if I set r_studio_lerping to 0. If you do this and attempt to fire the Glock, for example, the muzzle flash will show forever (since it's played on animation frame 0) and reloading will not produce any sound.

What's the best way to fix this? Should curstate.frame be updated properly?

a1batross commented 5 years ago

Hi.

Sorry for long answer, I was quite busy.

r_studio_lerping is just an extension and mostly left for debugging purposes. I recommend to not change this value.

Also, old engine may sometimes handle view model incorrectly(due to unfinished weapon predicting). You may try to backport some features and fixes from new engine.

noodlecollie commented 5 years ago

Which repo is the new engine?

nekonomicon commented 5 years ago

https://github.com/FWGS/xash3d-fwgs