| 883 | } |
| 884 | |
| 885 | void bFile::safeSwapPtr(char *dst, const char *src) |
| 886 | { |
| 887 | int ptrFile = mFileDNA->getPointerSize(); |
| 888 | int ptrMem = mMemoryDNA->getPointerSize(); |
| 889 | |
| 890 | if (!src && !dst) |
| 891 | return; |
| 892 | |
| 893 | if (ptrFile == ptrMem) |
| 894 | { |
| 895 | memcpy(dst, src, ptrMem); |
| 896 | } |
| 897 | else if (ptrMem == 4 && ptrFile == 8) |
| 898 | { |
| 899 | btPointerUid *oldPtr = (btPointerUid *)src; |
| 900 | btPointerUid *newPtr = (btPointerUid *)dst; |
| 901 | |
| 902 | if (oldPtr->m_uniqueIds[0] == oldPtr->m_uniqueIds[1]) |
| 903 | { |
| 904 | //Bullet stores the 32bit unique ID in both upper and lower part of 64bit pointers |
| 905 | //so it can be used to distinguish between .blend and .bullet |
| 906 | newPtr->m_uniqueIds[0] = oldPtr->m_uniqueIds[0]; |
| 907 | } |
| 908 | else |
| 909 | { |
| 910 | //deal with pointers the Blender .blend style way, see |
| 911 | //readfile.c in the Blender source tree |
| 912 | long64 longValue = *((long64 *)src); |
| 913 | //endian swap for 64bit pointer otherwise truncation will fail due to trailing zeros |
| 914 | if (mFlags & FD_ENDIAN_SWAP) |
| 915 | SWITCH_LONGINT(longValue); |
| 916 | *((int *)dst) = (int)(longValue >> 3); |
| 917 | } |
| 918 | } |
| 919 | else if (ptrMem == 8 && ptrFile == 4) |
| 920 | { |
| 921 | btPointerUid *oldPtr = (btPointerUid *)src; |
| 922 | btPointerUid *newPtr = (btPointerUid *)dst; |
| 923 | if (oldPtr->m_uniqueIds[0] == oldPtr->m_uniqueIds[1]) |
| 924 | { |
| 925 | newPtr->m_uniqueIds[0] = oldPtr->m_uniqueIds[0]; |
| 926 | newPtr->m_uniqueIds[1] = 0; |
| 927 | } |
| 928 | else |
| 929 | { |
| 930 | *((long64 *)dst) = *((int *)src); |
| 931 | } |
| 932 | } |
| 933 | else |
| 934 | { |
| 935 | printf("%d %d\n", ptrFile, ptrMem); |
| 936 | assert(0 && "Invalid pointer len"); |
| 937 | } |
| 938 | } |
| 939 | |
| 940 | // ----------------------------------------------------- // |
| 941 | void bFile::getMatchingFileDNA(short *dna_addr, const char *lookupName, const char *lookupType, char *strcData, char *data, bool fixupPointers) |
nothing calls this directly
no test coverage detected