Endian swap

wabmcfarlane
Posts: 1
Joined: Mon Jun 11, 2012 10:30 am

Endian swap

Post by wabmcfarlane »

i am currently looking at a way of endian swapping .bullet files for an xbox360 project. currently files exported from Maya on my pc are saved as little endian and converted to big endian at load time. i was wondering if there is a export option to control the endian type that a file is exported as? or any other helpful endian swapping tool for .bullet files?

thanks in advance and i apologise if this question has already been answered.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Endian swap

Post by Erwin Coumans »

I haven't tried this yet, but it would be a useful feature.

One idea is to use the BulletFileLoader using the in-memory buffer, and forcing a endian swap, before you write the data to disk.
Can you let us know if you have a solution?
Thanks,
Erwin
podfish
Posts: 6
Joined: Wed Oct 10, 2012 12:38 am

Re: Endian swap

Post by podfish »

has no one done this yet? I think I'm going to have to do it; we export from the PC to various platforms, so it'd be a lot nicer to pre-swap.
I also notice that the 'extras' folder source-files aren't as careful as the 'src' folders regarding use of the btAllocators. There are several calls to operator new[], and I bet there are corresponding operator delete[]s I haven't found yet.
Two more things: the DNA seems wasteful when building for a console. It looks like it'll abort the read with ""Failed to find DNA1+SDNA pair\n"" if I strip the DNA sections out of the platform-specific game builds, unless I modify bFile.cpp.
And finally, if I want to leave the bullet file's image in memory, re-using the data (load-in-place) wherever possible, I'd have to add that functionality as well, right? For example, the shape-data objects that hold the triangle data have perfectly valid arrays that are duplicated when the shapes themselves are made. It'd be nice to save that data too.

It seems like I'm proposing some major changes to bFile/btBulletFile. It seems to me that these are common features, though, so I hope that I can avoid re-inventing any wheels!
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Endian swap

Post by Erwin Coumans »

I just had a look, and added a endianness swap to btBulletWorldImporter and bFile.

https://code.google.com/p/bullet/source/detail?r=2618

Can you test it and let us know if that works for you?
the DNA seems wasteful when building for a console.
Indeed. One option to reduce the DNA size a lot for small files that only contain few Bullet structures is to only save DNA structures that are actually used.
Right now, the full DNA is always attached.
And finally, if I want to leave the bullet file's image in memory, re-using the data (load-in-place) wherever possible, I'd have to add that functionality as well, right?
Indeed, it should be possibly to avoid further duplication of data and use the Bullet file data in-place. It needs some work.
If you have time to work on it please consider sharing it.

Thanks!
Erwin
podfish
Posts: 6
Joined: Wed Oct 10, 2012 12:38 am

Re: Endian swap

Post by podfish »

Erwin Coumans wrote:I just had a look, and added a endianness swap to btBulletWorldImporter and bFile.

https://code.google.com/p/bullet/source/detail?r=2618

Can you test it and let us know if that works for you?
I'm building with it now, and I'll hook it up to our toolchain. Thanks for the quick response!

Soon I'll see if replacing "new char[]" with btAlignedAlloc calls will force every allocation to go through my library's allocation code, and see if I can come up with a simple way to handle in-place loading. I think the key there will be to distinquish between delete()able pointers and ones that point to in-place data. I have some potentially cunning ideas.