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

Method parseInternal

Extras/Serialize/BulletFileLoader/bFile.cpp:195–305  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

193
194// ----------------------------------------------------- //
195void bFile::parseInternal(int verboseMode, char *memDna, int memDnaLength)
196{
197 if ((mFlags & FD_OK) == 0)
198 return;
199
200 if (mFlags & FD_FILEDNA_IS_MEMDNA)
201 {
202 setFileDNA(verboseMode, memDna, memDnaLength);
203 }
204
205 if (mFileDNA == 0)
206 {
207 char *blenderData = mFileBuffer;
208 bChunkInd dna;
209 dna.oldPtr = 0;
210
211 char *tempBuffer = blenderData;
212 for (int i = 0; i < mFileLen; i++)
213 {
214 // looking for the data's starting position
215 // and the start of SDNA decls
216
217 if (!mDataStart && strncmp(tempBuffer, "REND", 4) == 0)
218 mDataStart = i;
219
220 if (strncmp(tempBuffer, "DNA1", 4) == 0)
221 {
222 // read the DNA1 block and extract SDNA
223 if (getNextBlock(&dna, tempBuffer, mFlags) > 0)
224 {
225 if (strncmp((tempBuffer + ChunkUtils::getOffset(mFlags)), "SDNANAME", 8) == 0)
226 dna.oldPtr = (tempBuffer + ChunkUtils::getOffset(mFlags));
227 else
228 dna.oldPtr = 0;
229 }
230 else
231 dna.oldPtr = 0;
232 }
233 // Some Bullet files are missing the DNA1 block
234 // In Blender it's DNA1 + ChunkUtils::getOffset() + SDNA + NAME
235 // In Bullet tests its SDNA + NAME
236 else if (strncmp(tempBuffer, "SDNANAME", 8) == 0)
237 {
238 dna.oldPtr = blenderData + i;
239 dna.len = mFileLen - i;
240
241 // Also no REND block, so exit now.
242 if (mVersion == 276) break;
243 }
244
245 if (mDataStart && dna.oldPtr) break;
246 tempBuffer++;
247 }
248 if (!dna.oldPtr || !dna.len)
249 {
250 //printf("Failed to find DNA1+SDNA pair\n");
251 mFlags &= ~FD_OK;
252 return;

Callers

nothing calls this directly

Calls 6

initMethod · 0.45
getNumNamesMethod · 0.45
getNameMethod · 0.45
dumpTypeDefinitionsMethod · 0.45
lessThanMethod · 0.45
initCmpFlagsMethod · 0.45

Tested by

no test coverage detected