thomasp85 / tweenr

Interpolate your data
Other
399 stars 42 forks source link

Error: cannot create std::vector larger than max_size() #59

Open yazun opened 2 years ago

yazun commented 2 years ago

It seems we hit a regression when trying to use the tween_component

image

Error: cannot create std::vector larger than max_size()
In addition: Warning message:
In numeric_element_interpolator(as.numeric(data), as.integer(group),  :
  NAs introduced by coercion to integer range

This is most likely line 24 (ease_seq) in numeric_element_interpolator fn:

21        for (i = 1; i < data.size(); ++i) {
22          if (current_group == group[i]) {
23            int nframes = frame[i] - frame[i-1];
24            std::vector<double> ease_points = ease_seq(ease[i-1], nframes);
25            for (size_t j = 0; j < ease_points.size(); ++j) {
26              tweendata.push_back(data[i - 1] + ease_points[j] * (data[i] - data[i - 1]));
27              tweengroup.push_back(current_group);
28              tweenframe.push_back(j + frame[i-1]);
29            }
30          } else {

Do you have any hints why this could happen? Thanks

yazun commented 2 years ago

I guess nframes at line 23 gets negative? When this could happen.

yazun commented 2 years ago
Thread 1 "R" hit Breakpoint 6, ease_seq (easer="linear", length=-7) at utils.h:77
77      static inline std::vector<double> ease_seq(std::string easer, int length) {
(gdb) n
80            new_allocator() _GLIBCXX_USE_NOEXCEPT { }
(gdb)
78        std::vector<double> res(length);
(gdb) p length
$2 = -7
thomasp85 commented 2 years ago

Hum... can you provide a reproducible example so I can investigate on my end?