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

Method parseInternal

src/Bullet3Serialize/Bullet2FileLoader/b3File.cpp:181–284  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

179
180// ----------------------------------------------------- //
181void bFile::parseInternal(int verboseMode, char *memDna, int memDnaLength)
182{
183 if ((mFlags & FD_OK) == 0)
184 return;
185
186 char *blenderData = mFileBuffer;
187 bChunkInd dna;
188 dna.oldPtr = 0;
189
190 char *tempBuffer = blenderData;
191 for (int i = 0; i < mFileLen; i++)
192 {
193 // looking for the data's starting position
194 // and the start of SDNA decls
195
196 if (!mDataStart && strncmp(tempBuffer, "REND", 4) == 0)
197 mDataStart = i;
198
199 if (strncmp(tempBuffer, "DNA1", 4) == 0)
200 {
201 // read the DNA1 block and extract SDNA
202 if (getNextBlock(&dna, tempBuffer, mFlags) > 0)
203 {
204 if (strncmp((tempBuffer + ChunkUtils::getOffset(mFlags)), "SDNANAME", 8) == 0)
205 dna.oldPtr = (tempBuffer + ChunkUtils::getOffset(mFlags));
206 else
207 dna.oldPtr = 0;
208 }
209 else
210 dna.oldPtr = 0;
211 }
212 // Some Bullet files are missing the DNA1 block
213 // In Blender it's DNA1 + ChunkUtils::getOffset() + SDNA + NAME
214 // In Bullet tests its SDNA + NAME
215 else if (strncmp(tempBuffer, "SDNANAME", 8) == 0)
216 {
217 dna.oldPtr = blenderData + i;
218 dna.len = mFileLen - i;
219
220 // Also no REND block, so exit now.
221 if (mVersion == 276) break;
222 }
223
224 if (mDataStart && dna.oldPtr) break;
225 tempBuffer++;
226 }
227 if (!dna.oldPtr || !dna.len)
228 {
229 //printf("Failed to find DNA1+SDNA pair\n");
230 mFlags &= ~FD_OK;
231 return;
232 }
233
234 mFileDNA = new bDNA();
235
236 ///mFileDNA->init will convert part of DNA file endianness to current CPU endianness if necessary
237 mFileDNA->init((char *)dna.oldPtr, dna.len, (mFlags & FD_ENDIAN_SWAP) != 0);
238

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