==================== idRenderModelMD5::LoadModel used for initial loads, reloadModel, and reloading the data of purged models Upon exit, the model will absolutely be valid, but possibly as a default model ==================== */
| 504 | ==================== |
| 505 | */ |
| 506 | void idRenderModelMD5::LoadModel() { |
| 507 | int version; |
| 508 | int i; |
| 509 | int num; |
| 510 | int parentNum; |
| 511 | idToken token; |
| 512 | idLexer parser( LEXFL_ALLOWPATHNAMES | LEXFL_NOSTRINGESCAPECHARS ); |
| 513 | idJointQuat *pose; |
| 514 | idMD5Joint *joint; |
| 515 | idJointMat *poseMat3; |
| 516 | |
| 517 | if ( !purged ) { |
| 518 | PurgeModel(); |
| 519 | } |
| 520 | purged = false; |
| 521 | |
| 522 | if ( !parser.LoadFile( name ) ) { |
| 523 | MakeDefaultModel(); |
| 524 | return; |
| 525 | } |
| 526 | |
| 527 | parser.ExpectTokenString( MD5_VERSION_STRING ); |
| 528 | version = parser.ParseInt(); |
| 529 | |
| 530 | if ( version != MD5_VERSION ) { |
| 531 | parser.Error( "Invalid version %d. Should be version %d\n", version, MD5_VERSION ); |
| 532 | } |
| 533 | |
| 534 | // |
| 535 | // skip commandline |
| 536 | // |
| 537 | parser.ExpectTokenString( "commandline" ); |
| 538 | parser.ReadToken( &token ); |
| 539 | |
| 540 | // parse num joints |
| 541 | parser.ExpectTokenString( "numJoints" ); |
| 542 | num = parser.ParseInt(); |
| 543 | joints.SetGranularity( 1 ); |
| 544 | joints.SetNum( num ); |
| 545 | defaultPose.SetGranularity( 1 ); |
| 546 | defaultPose.SetNum( num ); |
| 547 | poseMat3 = ( idJointMat * )_alloca16( num * sizeof( *poseMat3 ) ); |
| 548 | |
| 549 | // parse num meshes |
| 550 | parser.ExpectTokenString( "numMeshes" ); |
| 551 | num = parser.ParseInt(); |
| 552 | if ( num < 0 ) { |
| 553 | parser.Error( "Invalid size: %d", num ); |
| 554 | } |
| 555 | meshes.SetGranularity( 1 ); |
| 556 | meshes.SetNum( num ); |
| 557 | |
| 558 | // |
| 559 | // parse joints |
| 560 | // |
| 561 | parser.ExpectTokenString( "joints" ); |
| 562 | parser.ExpectTokenString( "{" ); |
| 563 | pose = defaultPose.Ptr(); |
nothing calls this directly
no test coverage detected