Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

std::vector

Engaged ,
Aug 04, 2016 Aug 04, 2016

What are folks' opinions on using std::vector for dynamically creating large arrays in AE plugins?

I'm guessing it's as frowned upon as using new and delete, since that's what's probably happening under the hood anyway when you create/resize a vector.

TBH I've tried it in my latest plugin, creating some pretty large vectors, and there's not been any issue, but that's not yet production code.

TOPICS
SDK
723
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 04, 2016 Aug 04, 2016

Hi Christian,

I'm using vectors quite often and didn't have any problem.

But the headaches come if you want to share vectors between calls using SequenceData... You'll have to handle flattening unflattening process. Doable, but you loose the simplicity of vectors...

Cheers,

François

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 05, 2016 Aug 05, 2016

Hi François,

Good to know, thanks. I had a brief look at allocators afterwards, which might allow us to define a memory allocator using AE's memory suites, which vector can then use (by default a new vector will use std::allocator, which is implicit). I'll post anything that I come up with.

Vectors are rather useful, and nice to use. You're right about having to flatten and unflatten - with this sort of thing it always seems somewhat inefficient, since you need to have a large enough array in your sequence data to take whatever your vector might have stored within.

Cheers, Christian

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 05, 2016 Aug 05, 2016

In fact, if you want to flatten / unflatten, you don't need to have an array in your sequence data.

You should have a look at this thread:

Using std::vector in sequence_data

Toby litterally saved my life on this one!

Cheers,

François

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 05, 2016 Aug 05, 2016

Thankfully I'm using no sequence data in my current plugin but thanks for the link.

I was wondering how much of a potential performance hit flattening and unflattening sequence data on a frame-by-frame basis might introduce with the latest AE versions. With large arrays in vectors this must introduce some kind of slowdown, right?

Cheers, C

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 05, 2016 Aug 05, 2016

Well, if you're calling your data from the same call each time (render), I don't see any need for flattening unflattening.

Troubles come when you use the same data in different calls. You can have a look at this one:

Sequence_data different in PF_Cmd_RENDER and PF_Cmd_USER_CHANGED_PARAM

See? I've been bothering everyone with my vectors 😉

Cheers,

François

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 20, 2018 Aug 20, 2018
LATEST

Hi Christian, I wonder if you managed to create std::vector by using AE's memory functions ?

Thanks !

Gab

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines