-
Notifications
You must be signed in to change notification settings - Fork 347
How to delete or remove instances or objects made by the Object Instancer? #1969
-
Hello all!
I have many projects in which i use the Object Instancer to make instances. It uses a source object that interacts with physics and simulation.
After some thousands of frames i have too many instances and to improve the performance i'd like to delete the created instances (obviously with some logic like FIFO, First In First Out) but there is no Delete Instance or Delete Object or "Remove Instance" or similar nodes in Animation Nodes, is it true?
How can do this operation to increase the performances?
I already know that the new instances are put in this collection
image
Thank you all in advance!
Andrea.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 5 replies
-
If they are still linked to the Object Instancer node, then it is not safe to remove them dynamically, so I guess the safest way is to store whatever information you need, like their transformations, cull the ones you want to remove, then change the instancer count to match the new count after culling, set the information to the objects again.
Beta Was this translation helpful? Give feedback.
All reactions
-
Thank you for the answer, i was thinking to the same idea but the problem is "how" remove/delete the already instances made.
Animation Nodes doesn't have a node for this.
Again thanks!
Beta Was this translation helpful? Give feedback.
All reactions
-
@Kimerabubble If your Object Instancer node had a count of 100 and you later turned that down to 70, it will remove the 30 objects that are not needed. So you don't need to delete them yourself, the node will do it for you. That is what I meant by:
then change the instancer count to match the new count after culling,
Beta Was this translation helpful? Give feedback.
All reactions
-
Yes i know but the problem is that decreasing the number of instances it deletes the last born and not the first born so I should "transfer" or shift all the actual information about transformation between the instances before decreasing the number, not so easy...
For example
t0: Instance 1 borns
t1: Instance 1 have a collision and change translation, rotation and maybe many other data in simulation
+ Instance 2 borns
t2: Instance 1 continues its simulation in RigidBodyWorld...
Instance 2 have a collision and change translation, rotation and maybe many other data in simulation
+ Instance 3 borns
t3: here if i wanted to delete the Instance 1 (the first born) i couldn't decrease the count of instances from 3 to 2 because i would delete the Instance 3.
In order to guarantee the actual collision of the instances i shoud transfer all the data
from Instance 3 to Instance 2,
from Instance 2 to Instance 1 and than decrease the count of the Object Instancer...i'm not so sure how it is easy to do and how much it could impact the performance.
I hope to have explained it well.
Beta Was this translation helpful? Give feedback.
All reactions
-
@Kimerabubble I think this is the only way unfortunately, because the Object Instancer keeps track of those objects, and removing them manually is possible, but it will confuse the node.
I don't think transferring the data is a bad option, but it doesn't have to be like you described. You essentially need to store the entire data in an array and operate on that array independent of the objects themselves, then set the data to the object at the end. Check this method for data storage for instance:
https://blender.stackexchange.com/questions/106679/make-particles-slip-around-objects-in-animation-nodes
https://blender.stackexchange.com/questions/105090/how-to-store-particle-locations-in-a-list/105178
Beta Was this translation helpful? Give feedback.
All reactions
-
Understood and thank you for the links, extremely detailed! I didn't know the possibility to transfer the entire data like that.
I'm going to learn how to apply that on instances of my context.
I will post you the result!
Thank you again!
Beta Was this translation helpful? Give feedback.