HISM index problem

What exactly does the return value of “Add Instance” function mean?
I think it’s index of instance, and it auto-increment, but some time, like after removing instance many times, the return value may go low like 0 or 23, which the instance I already removed, why? Did I misunderstand the meaning of the return value?

I think it’s index of instance, and it auto-increment, but some time, like after removing instance many times, the return value may go low like 0 or 23, which the instance I already removed, why?

HISM indexes must live in a continuous ordered unique list. If you make a hundred, they’ll be ordered from 0-99. If you remove the 25th, another instance with a higher index will take its place and lose its own index! From an older thread of mine:

Note what happens to indexes when a random instance is removed, some other instances have their indexes reassigned. This used to be a massive issue up until 4.26 - were you to add LODs to the mix, the indexes would jumble up really quickly…


Another example from yet another thread regarding this:

Initially the spheres are ordered, their shade indicates their indexes. HISM components support per instance culling - off screen instances get removed from the index list (great for performance since we can render only some of them!). But if they’re not on the list, the HISM component needs to reorder indexes to fill in the gaps.

When they disappear on the right hand side, these are the high indexes - nothing needs rejiggling. 0-100 became 0-70 let’s say. It’s still neat.

Low indexes disappear when culling kicks on the left hand side. Now we have an index list of 30-100. The HISM will have none of that and will fill the initial indexes with something from the back. As you can see, this is quite chaotic.

The above was done using per instance custom data.

I want make a crowd with HISM, and make every one of them have HP, can be damaged and destroy.
I made a map/dict with int key(instance index) and float value(HP), but as you said, the index of HISM is not “stable”, the index of HISM won’t point to the same instance, btw, I got the index from hit result->hit item . how can I fix it, or HISM can still works for me ?

The HISM culling shenanigans improved dramatically.

Removing indexes still works the same, though. You can use a Dictionary for storing values but you’ll be unable to remove instances without indexes shifting about - making the data that resides in the Dictionary stale, useless.


One solution is to not remove instances, hide or move them out the way instead:

Here’s a small thing that hopefully demonstrates it better:

Wow, Thanks, But culling will change instance position too, like pic 2 in your last answer, so, if I move a instance too 0,0,10000000, it will go back because cull, I didn’t try it yet, that’s just my theory, should I turn off culling?

I tried, It’s works well, You saved my day, Thank you!

1 Like

Yup, there was a lot of work done on HISM between 4.25 - 4.27. Indexing is manageable.