MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / readStruct

Method readStruct

Extras/Serialize/BulletFileLoader/bFile.cpp:619–731  ·  view source on GitHub ↗

----------------------------------------------------- //

Source from the content-addressed store, hash-verified

617
618// ----------------------------------------------------- //
619char *bFile::readStruct(char *head, bChunkInd &dataChunk)
620{
621 bool ignoreEndianFlag = false;
622
623 if (mFlags & FD_ENDIAN_SWAP)
624 swap(head, dataChunk, ignoreEndianFlag);
625
626 if (!mFileDNA->flagEqual(dataChunk.dna_nr))
627 {
628 // Ouch! need to rebuild the struct
629 short *oldStruct, *curStruct;
630 char *oldType, *newType;
631 int oldLen, curLen, reverseOld;
632
633 oldStruct = mFileDNA->getStruct(dataChunk.dna_nr);
634 oldType = mFileDNA->getType(oldStruct[0]);
635
636 oldLen = mFileDNA->getLength(oldStruct[0]);
637
638 if ((mFlags & FD_BROKEN_DNA) != 0)
639 {
640 if ((strcmp(oldType, "btQuantizedBvhNodeData") == 0) && oldLen == 20)
641 {
642 return 0;
643 }
644 if ((strcmp(oldType, "btShortIntIndexData") == 0))
645 {
646 int allocLen = 2;
647 char *dataAlloc = new char[(dataChunk.nr * allocLen) + sizeof(void*)];
648 memset(dataAlloc, 0, (dataChunk.nr * allocLen) + sizeof(void*));
649 short *dest = (short *)dataAlloc;
650 const short *src = (short *)head;
651 for (int i = 0; i < dataChunk.nr; i++)
652 {
653 dest[i] = src[i];
654 if (mFlags & FD_ENDIAN_SWAP)
655 {
656 SWITCH_SHORT(dest[i]);
657 }
658 }
659 addDataBlock(dataAlloc);
660 return dataAlloc;
661 }
662 }
663
664 ///don't try to convert Link block data, just memcpy it. Other data can be converted.
665 if (strcmp("Link", oldType) != 0)
666 {
667 reverseOld = mMemoryDNA->getReverseType(oldType);
668
669 if ((reverseOld != -1))
670 {
671 // make sure it's here
672 //assert(reverseOld!= -1 && "getReverseType() returned -1, struct required!");
673
674 //
675 curStruct = mMemoryDNA->getStruct(reverseOld);
676 newType = mMemoryDNA->getType(curStruct[0]);

Callers

nothing calls this directly

Calls 7

swapFunction · 0.50
flagEqualMethod · 0.45
getStructMethod · 0.45
getTypeMethod · 0.45
getLengthMethod · 0.45
getReverseTypeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected