UInstancedStaticMeshComponent::RemoveInstance invalidates instance indexes
Calling UInstancedStaticMeshComponent::RemoveInstance(int32 InstanceIndex) invalidates all indexes > removed index.
This would have been ok (not good but acceptable) if the description at least suggested this might happen. However, neither the description of AddInstance nor RemoveInstance provides any insight in why things get totally fucked up after removing an instance.
/** Remove the instance specified. Returns True on success. */
PerInstanceSMData is a TArray; RemoveAt removes the index and shrinks the array
Invalidating the only way of tracking something you create is serious malpractice. I advise you to change that. If not, please update the description in the header file to properly portray that those are volatile.
From my understanding, when you remove the element at the specified index the array shrinks, so the element at "Index+1" moves to "Index", and everything else rearranges accordingly. In this case, after removing instance1, the element that was stored in the location of instance2 would now be in the instance1 location. In the call to UpdateInstanceTransform() do you see the original instance2 element update if you replace "instance2" with "instance1".
answered Oct 20 '15 at 06:16 PM
Can you please make it more clear in the documentation, that the instance_idx is an always continous index with no gaps and not a handle? That's what I assumed, but wasn't sure. Thank you.
answered Aug 17 '16 at 09:18 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here