Sorry for the rather terse title.
I’ve been playing around with the serialization/deserialization code. It’s really awesome that it can resolve pointers to structures (so long as the struct being pointed to is serializable of course), but I find one of the details of how it does this confusing.
On the serialization side, you get an id for an object in memory by passing its pointer into the serializer’s getUniqueId function, which returns an void* that’s actually hiding an int, which is weird, but that’s a separate discussion.*
And whatever object is being pointed to, whenever it serializes itself, it stores that same id in the chunk in which it’s serialized.
So far so good. All chunks have ids, and some chunks contain data members containing the id of chunks that they need once deserialization happens.
Now we get to deserialization, and these chunk ids, which are really ints, get updated to be pointers to where the chunk is being stored in memory. ???
Of course, the data members inside the chunks get updated from their int nature to be pointers (I guess that’s done through the resolvePointers function?), and then at the application level there’s the business of storing these things in maps with the key being the pointer to the chunk and the value being the pointer to the newly constructed object in memory.
So my question is, why this complex business of updating these ids? Why not just leave them as ints?
And while we’re here, thanks Erwin for this comment. It saved me at least several hours of debugging, and much suffering!
*Now that I think about it, it's probably saved as a void* because it later gets updated to a pointer, but now we're back to my original question!
Physics APIs, Physics file formats, Maya, Max, XSI, Cinema 4D, Lightwave, Blender, thinkingParticles™ and other simulation tools, exporters and importers
1 post • Page 1 of 1