#Animation Curve Conundrum

1 messages · Page 1 of 1 (latest)

hexed tundra
#

Hi folks!

Im running into an issue of something that USED to work, but suddenly I dont understand why its not working anymore. Maybe you have some insight on this:

Im using this static to set up animation curves internally

    {
        if !animcurve_really_exists(__ac_curve) return self
        if !animcurve_channel_exists(__ac_curve,__ac_channel) return self
        stencil_profile    ??= animcurve_create()
        animcurve_channel_copy(__ac_curve,__ac_channel,stencil_profile,0)
        stencil_mode= _mode
        return self
    }

but my legit animation curve is being bumped off by animcurve_really_exists :

function animcurve_really_exists(curve)
{
    if !is_real(curve) && !is_struct(curve) return false
    if !animcurve_exists(curve) return false
    
    return true
}

(Basically it allows to check for a curve without a crash if the variable is the wrong type)

Problem is, its getting transformed into the wrong type, I think?

If I remove this line if !is_real(curve) && !is_struct(curve) return false then I get a crash for passing the wrong type into animcurve_exists ...

Any ideas?

hexed tundra
#

This might be a bug.. animcurve_get_channel will sometimes return empty members of the points array, causing a crash when I try to reassign to it.
@steady plume sorry for the summon but you are an expert on curves, have you found anything like this?

hexed tundra
#

oh so its a known bug?

#

do you just remove the empty entries on the array?

steady plume
#

It seems that the animation curve system is not exactly the structs and arrays that the GM normally interprets. So if I remember correctly, you have to use json_stringfy to visualize the data

hexed tundra
#

well thats annoying + undocumented 🙄 . What about the other error?

steady plume
#

I remember it being a nightmare messing with the internals of animation curves... if I had known, I would have made my own spline curve system (although I wanted the editor functionality...)

steady plume
#

We have typed references now, so it could be an issue?

hexed tundra
steady plume
hexed tundra
#

maybe when they changed it to typed reference they forgot to update this function?

steady plume
#

I have the impression that they probably checked for all the _exists functions, to modify them all, but I think it's unlikely that they forgot that, but anything can happen lol

hexed tundra
#

yeah animcurve_exists() works properly . So im not sure which part of the function was not working

function animcurve_really_exists(curve)
{
    if !is_handle(curve) return false
    if !animcurve_exists(curve) return false
    
    return true
}

This seems to work now though if anyone's interested.

#

I haven't figured out whats going on with the random points being empty, but that will ahve to wait until tomorrow

hexed tundra
steady plume
#

Basically, the best "safe" approach is to recreate the entire animation curve from scratch, with new values

#

I know, I know... 😅6785_pepe_cringe

hexed tundra
#

haha so cursed. Ok thanks!

#

I might have some animation curve functions to share for TurboGML when this is done

steady plume
#

Thanks for the generosity 😊

hexed tundra
#

More mysterious animation curve stuff.

If I step through the function in the debugger it works properly .

However when I just play it either corrupts it as shown in the picture (fills the channel with local variables) or it empties the channel completely.
Before I was using the same variable name ( _channel instead of _channel_01 and _channel_02 ) and it was recursively filling th channel with either arrays or structs containing _channel._channel._channel._channel._channel (...)

Not sure if this should be marked as a bug or not, will make a link to the bug channel

#

Some important context: this is happening after I try to change the points inside the curve.
Curve doesnt seem to be malformed.
(I am changing the curve type as part of the debugging from bezier to catmull as I thought maybe the bezier curve was the culprit)

#

The error code ```############################################################################################
ERROR in
action number 1
of Step Event0
for object Test_Me:

animcurvechannel_evaluate() - first parameter is not valid animation curve channel
at gml_Script_anon_pulse_local_emitter_gml_GlobalScript_Pulse_15017_pulse_local_emitter_gml_GlobalScript_Pulse (line 624) - eval_a = clamp(animcurve_channel_evaluate(_channel_01,dir_stencil),0,1);
############################################################################################
gml_Script_anon_pulse_local_emitter_gml_GlobalScript_Pulse_15017_pulse_local_emitter_gml_GlobalScript_Pulse (line 624)
gml_Script_anon_pulse_local_emitter_gml_GlobalScript_Pulse_28600_pulse_local_emitter_gml_GlobalScript_Pulse (line 1059) - _stencil = __calculate_stencil(_ray,_stencil)
gml_Script_anon_pulse_local_emitter_gml_GlobalScript_Pulse_31395_pulse_local_emitter_gml_GlobalScript_Pulse (line 1175) - __check_stencil_collision(collisions,x,y)
gml_Object_Test_Me_Step_0 (line 1) - sys.pulse(100,x,y,false) // avg ~600

#

method that changes the channel:

function animcurve_channel_regen(curve, channel, new_points) 
{
    var _source,_dest,_index,_name;
    _source = animcurve_get_channel(curve, channel)
    _index    = animcurve_get_channel_index(curve, _source.name)
    
    _dest = animcurve_channel_new();
    
    _dest.name =        _source.name;
    _dest.type =        _source.type;
    _dest.iterations =    _source.iterations;
    _dest.points=        new_points;
    
    var _new_channels = curve.channels
    _new_channels[_index]=_dest
    
    curve.channels=_new_channels
    
    return
}```

could it be that it is storing a reference to a local variable that later gets destroyed?