Are dynamic fields as a struct member supported? #8665
Unanswered
edoardogiacomello
asked this question in
Q&A
Replies: 1 comment
-
For your point about looping, note that the array is allocated in chunks, in your case 32. So, it's going to loop over every eleement in each entire chunk. eg try the following to see it only loops over activet chunks:
oUtput:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
I'm trying to build a simulation in which I have a dynamic field of particles that belong to different objects. This is needed because in my simulation, new particles and object could spawn at runtime and I want to keep it flexible/efficient enough.
The particles are implemented as follow:
This seems to work, and I can access and add new elements by indexing. As a side note, a for loop iterates over all 1000 elements even if
parts
contains only a few active elements. I'm satisfied looping overrange(parts.length())
for now, but the docs state that for loops should automatically take care of everything (?).However, these particles belong to some objects that have different properties that are not directly related to the particles.
What I would like to accomplish is to have a dynamic list as a member of the each object struct containing the indices (or pointers?) to the particles belonging to that object. This would allow me to access an object from a particle, but also to access all the particles belonging to a given object:
is that possible?
Beta Was this translation helpful? Give feedback.
All reactions