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

Method init

Extras/Serialize/BulletFileLoader/bDNA.cpp:345–500  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

343
344// ----------------------------------------------------- //
345void bDNA::init(char *data, int len, bool swap)
346{
347 int *intPtr = 0;
348 short *shtPtr = 0;
349 char *cp = 0;
350 int dataLen = 0;
351 //long nr=0;
352 intPtr = (int *)data;
353
354 /*
355 SDNA (4 bytes) (magic number)
356 NAME (4 bytes)
357 <nr> (4 bytes) amount of names (int)
358 <string>
359 <string>
360 */
361
362 if (strncmp(data, "SDNA", 4) == 0)
363 {
364 // skip ++ NAME
365 intPtr++;
366 intPtr++;
367 }
368
369 // Parse names
370 if (swap)
371 {
372 *intPtr = ChunkUtils::swapInt(*intPtr);
373 }
374 dataLen = *intPtr;
375 intPtr++;
376
377 cp = (char *)intPtr;
378 int i;
379 for (i = 0; i < dataLen; i++)
380 {
381 bNameInfo info;
382 info.m_name = cp;
383 info.m_isPointer = (info.m_name[0] == '*') || (info.m_name[1] == '*');
384 name_is_array(info.m_name, &info.m_dim0, &info.m_dim1);
385 m_Names.push_back(info);
386 while (*cp) cp++;
387 cp++;
388 }
389
390 cp = btAlignPointer(cp, 4);
391
392 /*
393 TYPE (4 bytes)
394 <nr> amount of types (int)
395 <string>
396 <string>
397 */
398
399 intPtr = (int *)cp;
400 assert(strncmp(cp, "TYPE", 4) == 0);
401 intPtr++;
402

Callers 4

btBulletFileMethod · 0.45
setFileDNAMethod · 0.45
parseInternalMethod · 0.45
mainFunction · 0.45

Calls 7

btAlignPointerFunction · 0.85
btHashStringClass · 0.85
name_is_arrayFunction · 0.70
push_backMethod · 0.45
sizeMethod · 0.45
atMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected