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

Method getMatchingFileDNA

src/Bullet3Serialize/Bullet2FileLoader/b3File.cpp:908–988  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

906
907// ----------------------------------------------------- //
908void bFile::getMatchingFileDNA(short *dna_addr, const char *lookupName, const char *lookupType, char *strcData, char *data, bool fixupPointers)
909{
910 // find the matching memory dna data
911 // to the file being loaded. Fill the
912 // memory with the file data...
913
914 int len = dna_addr[1];
915 dna_addr += 2;
916
917 for (int i = 0; i < len; i++, dna_addr += 2)
918 {
919 const char *type = mFileDNA->getType(dna_addr[0]);
920 const char *name = mFileDNA->getName(dna_addr[1]);
921
922 int eleLen = mFileDNA->getElementSize(dna_addr[0], dna_addr[1]);
923
924 if ((mFlags & FD_BROKEN_DNA) != 0)
925 {
926 if ((strcmp(type, "short") == 0) && (strcmp(name, "int") == 0))
927 {
928 eleLen = 0;
929 }
930 }
931
932 if (strcmp(lookupName, name) == 0)
933 {
934 //int arrayLenold = mFileDNA->getArraySize((char*)name.c_str());
935 int arrayLen = mFileDNA->getArraySizeNew(dna_addr[1]);
936 //assert(arrayLenold == arrayLen);
937
938 if (name[0] == '*')
939 {
940 // cast pointers
941 int ptrFile = mFileDNA->getPointerSize();
942 int ptrMem = mMemoryDNA->getPointerSize();
943 safeSwapPtr(strcData, data);
944
945 if (fixupPointers)
946 {
947 if (arrayLen > 1)
948 {
949 //void **sarray = (void**)strcData;
950 //void **darray = (void**)data;
951
952 char *cpc, *cpo;
953 cpc = (char *)strcData;
954 cpo = (char *)data;
955
956 for (int a = 0; a < arrayLen; a++)
957 {
958 safeSwapPtr(cpc, cpo);
959 m_pointerFixupArray.push_back(cpc);
960 cpc += ptrMem;
961 cpo += ptrFile;
962 }
963 }
964 else
965 {

Callers

nothing calls this directly

Calls 7

getElementFunction · 0.70
getTypeMethod · 0.45
getNameMethod · 0.45
getElementSizeMethod · 0.45
getArraySizeNewMethod · 0.45
getPointerSizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected