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

Method swapStruct

Extras/Serialize/BulletFileLoader/bFile.cpp:1052–1098  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1050
1051// ----------------------------------------------------- //
1052void bFile::swapStruct(int dna_nr, char *data, bool ignoreEndianFlag)
1053{
1054 if (dna_nr == -1) return;
1055
1056 short *strc = mFileDNA->getStruct(dna_nr);
1057 //short *firstStrc = strc;
1058
1059 int elementLen = strc[1];
1060 strc += 2;
1061
1062 short first = mFileDNA->getStruct(0)[0];
1063
1064 char *buf = data;
1065 for (int i = 0; i < elementLen; i++, strc += 2)
1066 {
1067 char *type = mFileDNA->getType(strc[0]);
1068 char *name = mFileDNA->getName(strc[1]);
1069
1070 int size = mFileDNA->getElementSize(strc[0], strc[1]);
1071 if (strc[0] >= first && name[0] != '*')
1072 {
1073 int old_nr = mFileDNA->getReverseType(type);
1074 int arrayLen = mFileDNA->getArraySizeNew(strc[1]);
1075 if (arrayLen == 1)
1076 {
1077 swapStruct(old_nr, buf, ignoreEndianFlag);
1078 }
1079 else
1080 {
1081 char *tmpBuf = buf;
1082 for (int i = 0; i < arrayLen; i++)
1083 {
1084 swapStruct(old_nr, tmpBuf, ignoreEndianFlag);
1085 tmpBuf += size / arrayLen;
1086 }
1087 }
1088 }
1089 else
1090 {
1091 //int arrayLenOld = mFileDNA->getArraySize(name);
1092 int arrayLen = mFileDNA->getArraySizeNew(strc[1]);
1093 //assert(arrayLenOld == arrayLen);
1094 swapData(buf, strc[0], arrayLen, ignoreEndianFlag);
1095 }
1096 buf += size;
1097 }
1098}
1099
1100void bFile::resolvePointersMismatch()
1101{

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