Serializing out and reading in hkArray types in classes built via regenerateXML.py

Serializing out and reading in hkArray types in classes built via regenerateXML.py

Hello,

I have a subclass that includes an hkArray member. I used regenerateXML.py to build a ...Class.cpp file for it, and successfully serialized it out to an XML file:

-0.749664 -2.569430 -4.160680 -5.999540 -7.431300 -7.218050 -3.828340 -2.335110 -1.993260 -1.564480

... etc.

The thing that confuses me is that when I read my subclass back into memory from disk, my "m_heightPosts" hkArray is empty; all the other members look to have been read in correctly. Should I be using the "simple array" serialization format mentioned in the docs (m_heightPosts + m_numHeightPosts member var declaration), or is there something simple I'm forgetting to do in the way I have it now?

I have the data in a void* buffer, and read it using the PackfileReader::loadEntireFileInPlace command. This has been working fine for me for existing Havok classes. This is my first attempt using a class of my own (derived off hkReferencedObject).

Thanks in advance!

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi rahul.gupta,

I think the problem here is that you need to call the hkArray fixup constructor instead of the hkArray default constructor. The default constructor for hkArray will set the size to 0 and the data to null.

Your class' fixup constructor will look something like this:

MyClass( hkFinishLoadedObjectFlag f ) :
hkReferencedObject(f), m_heightPosts(f) { }

This will allow the hkArray to be filled in by the serialization system.

Let me know if that works.

Thanks,
Sean

Developer Support Engineer
Havok
www.havok.com

Leave a Comment

Please sign in to add a comment. Not a member? Join today