Hello Simon,
I know you are going to be answering this :P I don't know why you help so much but thankyou.
I don't get why when moving entities to simulation regions the entity_reference
was defined as a union. To me it seems scary because I will end up calling that StoreEntityReference
function with the index set inside the reference (instead of a pointer) and it will just treat that as a non null pointer. Then it will do something weird right?
So why not just define a struct for the reference with both the pointer and index inside it?
Here is the function I am talking about:
And here is how its used to convert a pointer to a low entity to an index
At this point, all indication of what is inside the union (i.e. a pointer or index) is lost. Is this not supposed to make me uncomfortable?
My understanding of unions is that regardless of whether the union contains the pointer or the index, I can access it as ref.Index
or ref.Ptr
and it will unsafe cast whatever data happens to be inside it.
There is also a sim_entity_hash
which is a struct of the same thing, so why not use this everywhere?