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

Method swapStruct

src/Bullet3Serialize/Bullet2FileLoader/b3File.cpp:1019–1065  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1017
1018// ----------------------------------------------------- //
1019void bFile::swapStruct(int dna_nr, char *data, bool ignoreEndianFlag)
1020{
1021 if (dna_nr == -1) return;
1022
1023 short *strc = mFileDNA->getStruct(dna_nr);
1024 //short *firstStrc = strc;
1025
1026 int elementLen = strc[1];
1027 strc += 2;
1028
1029 short first = mFileDNA->getStruct(0)[0];
1030
1031 char *buf = data;
1032 for (int i = 0; i < elementLen; i++, strc += 2)
1033 {
1034 char *type = mFileDNA->getType(strc[0]);
1035 char *name = mFileDNA->getName(strc[1]);
1036
1037 int size = mFileDNA->getElementSize(strc[0], strc[1]);
1038 if (strc[0] >= first && name[0] != '*')
1039 {
1040 int old_nr = mFileDNA->getReverseType(type);
1041 int arrayLen = mFileDNA->getArraySizeNew(strc[1]);
1042 if (arrayLen == 1)
1043 {
1044 swapStruct(old_nr, buf, ignoreEndianFlag);
1045 }
1046 else
1047 {
1048 char *tmpBuf = buf;
1049 for (int i = 0; i < arrayLen; i++)
1050 {
1051 swapStruct(old_nr, tmpBuf, ignoreEndianFlag);
1052 tmpBuf += size / arrayLen;
1053 }
1054 }
1055 }
1056 else
1057 {
1058 //int arrayLenOld = mFileDNA->getArraySize(name);
1059 int arrayLen = mFileDNA->getArraySizeNew(strc[1]);
1060 //assert(arrayLenOld == arrayLen);
1061 swapData(buf, strc[0], arrayLen, ignoreEndianFlag);
1062 }
1063 buf += size;
1064 }
1065}
1066
1067void bFile::resolvePointersMismatch()
1068{

Callers

nothing calls this directly

Calls 6

getStructMethod · 0.45
getTypeMethod · 0.45
getNameMethod · 0.45
getElementSizeMethod · 0.45
getReverseTypeMethod · 0.45
getArraySizeNewMethod · 0.45

Tested by

no test coverage detected