Error serializing

Nacho
Posts: 31
Joined: Tue Mar 04, 2008 1:41 pm

Error serializing

Post by Nacho »

Hi,

I use serialize utility for save my btBvhTriangleMeshShape. Generally, it works. But now I've found a problem:

Sometimes, when serializing btQuantizedBvh (btQuantizedBvh::serialize), the values in m_quantizedContiguousNodes.m_quantizedAabbMax[..] and m_quantizedContiguousNodes.m_quantizedAabbMin[..] make that in memory appear the sequence of bytes: 53 44 4e 41 that matches 'SDNA'. This is the 'magic' number to detect the DNA data.

When I load the file, in bFile::parseInternal it finds the erroneous 'SDNA' sequence (not followed by 'NAME' sequence as says in bDNA::init).

If I change in bFile::parseInternal the line

Code: Select all

if (!sdnaPos && strncmp(tempBuffer, "SDNA", 4)==0)
by

Code: Select all

if (!sdnaPos && strncmp(tempBuffer, "SDNANAME", 8)==0)
it works correctly.

Can it be the general solution for this issue?

Thanks,
Nacho.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Error serializing

Post by Erwin Coumans »

Can you attach the .bullet file to this topic?

We need to look into this, it shouldn't happen. The search for the SDNA tag should only visit the header data for each chunk, not the contents.

We'll look into fixing this,
Erwin
Nacho
Posts: 31
Joined: Tue Mar 04, 2008 1:41 pm

Re: Error serializing

Post by Nacho »

Hi Erwin,

I'm sorry but the file size is about 7'7 Mb (compressed) and the size of attachment is limited to 2 Mb. Can I send you by other way?


Thanks,
Nacho.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Error serializing

Post by Erwin Coumans »

I changed the check for "SDNANAME" for now in latest trunk:
http://code.google.com/p/bullet/source/detail?r=2125

We could make the search more failsafe (by only seaching in particular chunks/locations), but for now this should do,
Thanks for the feedback!
Erwin
Nacho
Posts: 31
Joined: Tue Mar 04, 2008 1:41 pm

Re: Error serializing

Post by Nacho »

I see that in bFile::parseInternal, the search for 'SDNA' is in all file, not only the header of chunk:

Code: Select all

char *blenderData = mFileBuffer;
int sdnaPos=0;

char *tempBuffer = blenderData;
for (int i=0; i<mFileLen; i++)
{
	// looking for the data's starting position
	// and the start of SDNA decls

	if (!mDataStart && strncmp(tempBuffer, "REND", 4)==0)
		mDataStart = i;
	if (!sdnaPos && strncmp(tempBuffer, "SDNA", 4)==0)
		sdnaPos = i;
....
Nacho