Animation: time offset slider #106520
|
@ -504,7 +504,7 @@ void time_offset_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float
|
|||
float delta_y;
|
||||
|
||||
/* If we operate directly on the fcurve there will be a feedback loop
|
||||
|
||||
* so we need to capture the "y" values on an array to then apply them on a second loop*/
|
||||
* so we need to capture the "y" values on an array to then apply them on a second loop. */
|
||||
float y_values[segment->length];
|
||||
this doesn't compile for me. C doesn't allow variable length arrays. you'd need to do this doesn't compile for me. C doesn't allow variable length arrays.
you'd need to do `MEM_callocN(sizeof(float) * segment->length, "Time Offset Samples");`
and at the end of the function `MEM_freeN(y_values);` so to not have a memory leak
AresDeveaux
commented
Why can I compile it? do I need to set something I haven't for When you say C doesn't allow variable length array, I'm not sure I follow. I thought by declaring an array with a fixed value, C could handle it. Isn't
Didn't know we could overshoot. Where is that set in the code, and how can I test it on the UI? In regard to the memory leak, should I be adding those types of lines to the other sliders too? Why can I compile it? do I need to set something I haven't for `make`?
When you say C doesn't allow variable length array, I'm not sure I follow. I thought by declaring an array with a fixed value, C could handle it. Isn't `segment->length` an unchanged value for that segment?
```
Also the slider currently allows an overshoot in the positive axis, but doesn't allow to go below 0.
When overshooting on positive x it doesn't loop infinitely as you'd expect
```
Didn't know we could overshoot. Where is that set in the code, and how can I test it on the UI?
In regard to the memory leak, should I be adding those types of lines to the other sliders too?
variable length arrays are a C99 feature, but I think Blender runs on a different standard. But honestly I can't find in the wiki where that is. A lot of the slider features are controller by the slider itself. You can see the shortcuts in the Status Bar variable length arrays are a C99 feature, but I think Blender runs on a different standard. But honestly I can't find in the wiki where that is.
A lot of the slider features are controller by the slider itself. You can see the shortcuts in the Status Bar
`ED_slider_allow_overshoot_set` allows you to change the behaviour
AresDeveaux
commented
Interesting! I didn't see those before. I tried overshoot in Interesting! I didn't see those before.
I tried overshoot in `time offset slider` and as you say, to the right it works as expected, but to the left stops at 0. I then tried the `ease slider`, the `neighbor slider` and the `default slider`, and all of them stop at 0. I could try to find the problem, but it seems the issue is not in my function but in the slider itself and that might be beyond my understanding at this point.
|
||||
|
||||
for (int i = segment->start_index; i < segment->start_index + segment->length; i++) {
|
||||
|
|
you don't need this line