Changeset 501
- Timestamp:
- 02/12/08 16:10:15 (11 months ago)
- Files:
-
- branches/morph-targets/libx42/anim-morph.c (modified) (3 diffs)
- branches/morph-targets/libx42/anim.c (modified) (1 diff)
- branches/morph-targets/libx42/include/x42.h (modified) (2 diffs)
- branches/morph-targets/libx42/include/x42data.h (modified) (1 diff)
- branches/morph-targets/libx42/load.c (modified) (33 diffs)
- branches/morph-targets/libx42/local.h (modified) (2 diffs)
- branches/morph-targets/libx42/write.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/morph-targets/libx42/anim-morph.c
r500 r501 29 29 30 30 register float wt = morph->weight; 31 const x42morphTarget_t * morphTarget = x42->mor hpTargets + morph->targetIndex;31 const x42morphTarget_t * morphTarget = x42->morphTargets + morph->targetIndex; 32 32 33 33 const x42index_t * RESTRICT idxs = x42->morphIndices + morphTarget->firstDelta; … … 52 52 53 53 register float wt = morph->weight; 54 const x42morphTarget_t * morphTarget = x42->mor hpTargets + morph->targetIndex;54 const x42morphTarget_t * morphTarget = x42->morphTargets + morph->targetIndex; 55 55 56 56 const x42index_t * RESTRICT idxs = x42->morphIndices + morphTarget->firstDelta; … … 74 74 75 75 register float wt = morph->weight; 76 const x42morphTarget_t * morphTarget = x42->mor hpTargets + morph->targetIndex;76 const x42morphTarget_t * morphTarget = x42->morphTargets + morph->targetIndex; 77 77 78 78 const x42index_t * RESTRICT idxs = x42->morphIndices + morphTarget->firstDelta; branches/morph-targets/libx42/anim.c
r500 r501 118 118 { 119 119 demand_rf( morphs[i].targetIndex < x42->header.numMorphTargets, X42_ERR_BADPARAMS, "invalid morph target index" ); 120 demand_rf( x42->mor hpTargets[morphs[i].targetIndex].targetGroup == groupNum, X42_ERR_BADPARAMS, "morph target does not match group" );120 demand_rf( x42->morphTargets[morphs[i].targetIndex].targetGroup == groupNum, X42_ERR_BADPARAMS, "morph target does not match group" ); 121 121 } 122 122 branches/morph-targets/libx42/include/x42.h
r500 r501 73 73 u32 numVerts; 74 74 u32 numIndices; 75 u32 numMorphDeltas; 75 76 76 77 aabb_t boundingBox; … … 149 150 Morph target data. 150 151 */ 151 x42morphTarget_t *mor hpTargets;152 x42morphTarget_t *morphTargets; 152 153 x42index_t *morphIndices; 153 154 vec4_t *morphPos; branches/morph-targets/libx42/include/x42data.h
r498 r501 158 158 u32 numVerts; //may be zero iff numGroups is zero 159 159 u32 numIndices; //may be zero 160 161 u32 numMorphDeltas; //may be zero iff numMorphTargets is zero 160 162 161 163 aabb_t boundingBox; branches/morph-targets/libx42/load.c
r499 r501 44 44 { 45 45 case X42_VER_V5: 46 break; 46 case X42_VER_V6: 47 break; 47 48 48 49 default: … … 377 378 ret->numLods = in.numLods; 378 379 ret->numGroups = in.numGroups; 380 ret->numMorphTargets = 0; 379 381 380 382 ret->numVerts = in.numVerts; 381 383 ret->numIndices = in.numIndices; 384 ret->numMorphDeltas = 0; 382 385 383 386 ret->boundingSphere = in.boundingSphere; … … 386 389 break; 387 390 391 case X42_VER_V6: 392 { 393 x42Header_v6_t in; 394 checked_read( &in, sizeof( in ) ); 395 396 ret->modelFlags = in.modelFlags; 397 398 ret->baseFrame = in.baseFrame; 399 ret->numFrames = in.numFrames; 400 401 ret->nameBlobLen = in.nameBlobLen; 402 403 ret->numBones = in.numBones; 404 ret->numAnimGroups = in.numAnimGroups; 405 406 ret->numPosValues = in.numPosValues; 407 ret->numScaleValues = in.numScaleValues; 408 ret->numRotValues = in.numRotValues; 409 410 ret->keyStreamLength = in.keyStreamLength; 411 ret->numAnims = in.numAnims; 412 413 ret->numTags = in.numTags; 414 ret->numInfluences = in.numInfluences; 415 416 ret->numLods = in.numLods; 417 ret->numGroups = in.numGroups; 418 ret->numMorphTargets = in.numMorphTargets; 419 420 ret->numVerts = in.numVerts; 421 ret->numIndices = in.numIndices; 422 ret->numMorphDeltas = in.numMorphDeltas; 423 424 ret->boundingSphere = in.boundingSphere; 425 ret->boundingBox = in.boundingBox; 426 } 427 break; 428 388 429 NO_DEFAULT; 389 430 } … … 413 454 ret->numLods = swap_u16( ret->numLods ); 414 455 ret->numGroups = swap_u16( ret->numGroups ); 456 ret->numMorphTargets = swap_u16( ret->numMorphTargets ); 415 457 416 458 ret->numVerts = swap_u32( ret->numVerts ); 417 459 ret->numIndices = swap_u32( ret->numIndices ); 460 ret->numMorphDeltas = swap_u32( ret->numMorphDeltas ); 418 461 419 462 ret->boundingBox.mins[0] = swap_f32( ret->boundingBox.mins[0] ); … … 498 541 ret += sizeof( float[4] ); 499 542 500 ret = align( ret, sizeof( void* ) ) + sizeof( x42keyStreamEntry_t ) * h->keyStreamLength; 501 ret = align( ret, sizeof( void* ) ) + sizeof( x42animation_t ) * h->numAnims; 502 503 ret = align( ret, sizeof( float ) ) + sizeof( vec3_t ) * h->numPosValues; 504 ret = align( ret, sizeof( float ) ) + sizeof( vec3_t ) * h->numScaleValues; 505 ret = align( ret, sizeof( float ) ) + sizeof( quat_t ) * h->numRotValues; 506 507 ret = align( ret, sizeof( void* ) ) + sizeof( x42animGroup_t ) * h->numAnimGroups; 508 ret = align( ret, sizeof( void* ) ) + sizeof( x42bone_t ) * h->numBones; 509 ret = align( ret, sizeof( void* ) ) + sizeof( u8 ) * h->numBones; 510 511 ret = align( ret, sizeof( void* ) ) + sizeof( x42influence_t ) * h->numInfluences; 512 ret = align( ret, sizeof( void* ) ) + sizeof( x42tag_t ) * h->numTags; 513 514 ret = align( ret, sizeof( void* ) ) + sizeof( x42lodRange_t ) * h->numLods; 515 ret = align( ret, sizeof( void* ) ) + sizeof( x42group_t ) * h->numGroups; 516 517 ret = align( ret, sizeof( float[4] ) ) + sizeof( x42vertAnim_t ) * h->numVerts; 543 ret = align( ret, sizeof( void* ) ) + sizeof( x42keyStreamEntry_t ) * h->keyStreamLength; 544 ret = align( ret, sizeof( void* ) ) + sizeof( x42animation_t ) * h->numAnims; 545 546 ret = align( ret, sizeof( float ) ) + sizeof( vec3_t ) * h->numPosValues; 547 ret = align( ret, sizeof( float ) ) + sizeof( vec3_t ) * h->numScaleValues; 548 ret = align( ret, sizeof( float ) ) + sizeof( quat_t ) * h->numRotValues; 549 550 ret = align( ret, sizeof( void* ) ) + sizeof( x42animGroup_t ) * h->numAnimGroups; 551 ret = align( ret, sizeof( void* ) ) + sizeof( x42bone_t ) * h->numBones; 552 ret = align( ret, sizeof( void* ) ) + sizeof( u8 ) * h->numBones; 553 554 ret = align( ret, sizeof( void* ) ) + sizeof( x42influence_t ) * h->numInfluences; 555 ret = align( ret, sizeof( void* ) ) + sizeof( x42tag_t ) * h->numTags; 556 557 ret = align( ret, sizeof( void* ) ) + sizeof( x42lodRange_t ) * h->numLods; 558 ret = align( ret, sizeof( void* ) ) + sizeof( x42group_t ) * h->numGroups; 559 ret = align( ret, sizeof( void* ) ) + sizeof( x42morphTarget_t ) * h->numMorphTargets; 560 561 ret = align( ret, sizeof( float[4] ) ) + sizeof( x42vertAnim_t ) * h->numVerts; 518 562 if( persist_flags & X42_PERSIST_NORMALS ) 519 ret = align( ret, sizeof( float[4] ) ) + sizeof( x42vertNormal_t ) * h->numVerts;563 ret = align( ret, sizeof( float[4] ) ) + sizeof( x42vertNormal_t ) * h->numVerts; 520 564 if( persist_flags & X42_PERSIST_TANGENT_BASIS ) 521 ret = align( ret, sizeof( float[4] ) ) + sizeof( x42vertTangent_t ) * h->numVerts;565 ret = align( ret, sizeof( float[4] ) ) + sizeof( x42vertTangent_t ) * h->numVerts; 522 566 if( persist_flags & X42_PERSIST_TEXTURE_COORDINATES ) 523 ret = align( ret, sizeof( float ) ) + sizeof( vec2_t ) * h->numVerts;567 ret = align( ret, sizeof( float ) ) + sizeof( vec2_t ) * h->numVerts; 524 568 if( persist_flags & X42_PERSIST_COLORS ) 525 ret = align( ret, sizeof( rgba_t ) ) + sizeof( rgba_t ) * h->numVerts; 526 527 ret = align( ret, sizeof( x42index_t ) ) + sizeof( x42index_t ) * h->numIndices; 528 569 ret = align( ret, sizeof( rgba_t ) ) + sizeof( rgba_t ) * h->numVerts; 570 571 ret = align( ret, sizeof( x42index_t ) ) + sizeof( x42index_t ) * h->numIndices; 572 573 ret = align( ret, sizeof( x42index_t ) ) + sizeof( x42index_t ) * h->numMorphDeltas; 574 ret = align( ret, sizeof( float[4] ) ) + sizeof( vec4_t ) * h->numMorphDeltas; 575 if( persist_flags & X42_PERSIST_NORMALS ) 576 ret = align( ret, sizeof( float[4] ) ) + sizeof( x42morphNormal_t ) * h->numMorphDeltas; 577 if( persist_flags & X42_PERSIST_TANGENT_BASIS ) 578 ret = align( ret, sizeof( float[4] ) ) + sizeof( x42morphTangent_t ) * h->numMorphDeltas; 579 529 580 ret += sizeof( char ) * h->nameBlobLen; 530 581 … … 581 632 ret->lods = (x42lodRange_t*) advance_out( sizeof( void* ), sizeof( x42lodRange_t ) * h->numLods ); 582 633 ret->groups = (x42group_t*) advance_out( sizeof( void* ), sizeof( x42group_t ) * h->numGroups ); 583 634 ret->morphTargets = (x42morphTarget_t*) advance_out( sizeof( void* ), sizeof( x42morphTarget_t ) * h->numMorphTargets ); 635 584 636 ret->vertPos = (x42vertAnim_t*) advance_out( sizeof( float[4] ),sizeof( x42vertAnim_t ) * h->numVerts ); 585 637 … … 605 657 606 658 ret->indices = (x42index_t*) advance_out( sizeof( x42index_t ), sizeof( x42index_t ) * h->numIndices ); 659 660 ret->morphIndices = (x42index_t*) advance_out( sizeof( x42index_t ), sizeof( x42index_t ) * h->numMorphDeltas ); 661 ret->morphPos = (vec4_t*) advance_out( sizeof( float[4] ), sizeof( vec4_t ) * h->numMorphDeltas ); 662 663 if( persist_flags & X42_PERSIST_NORMALS ) 664 ret->morphNorm = (x42morphNormal_t*) advance_out( sizeof( float[4] ), sizeof( x42morphNormal_t ) * h->numMorphDeltas ); 665 else 666 ret->morphNorm = NULL; 667 668 if( persist_flags & X42_PERSIST_TANGENT_BASIS ) 669 ret->morphTan = (x42morphTangent_t*) advance_out( sizeof( float[4] ), sizeof( x42morphTangent_t ) * h->numMorphDeltas ); 670 else 671 ret->morphTan = NULL; 607 672 608 673 ret->strings = (char*) advance_out( sizeof( char ), sizeof( char ) * h->nameBlobLen ); … … 662 727 memcpy( ret->lods, src->lods, sizeof( x42lodRange_t ) * h->numLods ); 663 728 memcpy( ret->groups, src->groups, sizeof( x42group_t ) * h->numGroups ); 729 memcpy( ret->morphTargets, src->morphTargets, sizeof( x42morphTarget_t ) * h->numMorphTargets ); 664 730 665 731 memcpy( ret->vertPos, src->vertPos, sizeof( x42vertAnim_t ) * h->numVerts ); … … 679 745 memcpy( ret->indices, src->indices, sizeof( x42index_t ) * h->numIndices ); 680 746 681 memcpy( CONST_CAST( char, ret->strings ), src->strings, sizeof( char ) * h->nameBlobLen ); 747 memcpy( ret->morphIndices, src->morphIndices, sizeof( x42index_t ) * h->numMorphDeltas ); 748 memcpy( ret->morphPos, src->morphPos, sizeof( vec4_t ) * h->numMorphDeltas ); 749 750 if( src->morphNorm ) 751 memcpy( ret->morphNorm, src->morphNorm, sizeof( x42morphNormal_t ) * h->numMorphDeltas ); 752 753 if( src->morphTan ) 754 memcpy( ret->morphTan, src->morphTan, sizeof( x42morphTangent_t ) * h->numMorphDeltas ); 755 756 memcpy( CONST_CAST( char, ret->strings ), src->strings, sizeof( char ) * h->nameBlobLen ); 682 757 683 758 return ret; … … 690 765 691 766 bool stat; 692 x42PackHeader_v 5_t pack;767 x42PackHeader_v6_t pack; 693 768 694 769 /* … … 699 774 700 775 #define checked_read( buf, type, count ) \ 701 if( !const_cond_false ) \776 if( const_cond_true ) \ 702 777 { \ 703 778 size_t cb = sizeof( type ) * count; \ … … 711 786 712 787 #define checked_align( a ) \ 713 if( !const_cond_false ) \788 if( const_cond_true ) \ 714 789 { \ 715 790 stat = align_stream( file_stream, &inPos, a ); \ … … 720 795 721 796 #define checked_read_a( buf, type, count, a ) \ 722 if( !const_cond_false ) \797 if( const_cond_true ) \ 723 798 { \ 724 799 checked_align( a ); \ … … 729 804 730 805 #define checked_read_packed_floats( buf, pack, comps, count, stride ) \ 731 if( !const_cond_false ) \806 if( const_cond_true ) \ 732 807 { \ 733 808 checked_align( 2 ); \ … … 740 815 741 816 #define checked_read_packed_floats_s16n( buf, comps, count, stride ) \ 742 if( !const_cond_false ) \817 if( const_cond_true ) \ 743 818 { \ 744 819 checked_align( 2 ); \ … … 751 826 752 827 #define checked_read_packed_floats_s8n( buf, comps, count, stride ) \ 753 if( !const_cond_false ) \828 if( const_cond_true ) \ 754 829 { \ 755 830 checked_align( 1 ); \ … … 762 837 763 838 #define checked_skip( size, a ) \ 764 if( !const_cond_false ) \839 if( const_cond_true ) \ 765 840 { \ 766 841 size_t cb = (size); \ … … 779 854 */ 780 855 781 checked_read( &pack, x42PackHeader_v5_t, 1 ); 856 if( h->ident.version < X42_VER_V6 ) 857 { 858 memset( &pack, 0, sizeof( pack ) ); 859 checked_read( (x42PackHeader_v5_t*)&pack, x42PackHeader_v5_t, 1 ); //x42PackHeader_v6_t's first fields are identical to those of x42PackHeader_v5_t 860 } 861 else 862 { 863 checked_read( &pack, x42PackHeader_v6_t, 1 ); 864 } 782 865 783 866 checked_read_a( ret->bones, x42Bone_v5_t, h->numBones, 8 ); … … 821 904 checked_read_a( ret->lods, x42LodRange_v5_t, h->numLods, 8 ); 822 905 checked_read_a( ret->groups, x42Group_v5_t, h->numGroups, 8 ); 906 907 if( h->ident.version >= X42_VER_V6 ) 908 checked_read_a( ret->morphTargets, x42MorphTarget_v6_t, h->numMorphTargets, 8 ); 823 909 824 910 checked_read_packed_floats( &ret->vertPos[0].pos, pack.vertPosPack, 3, h->numVerts, sizeof( x42vertAnim_t ) ); … … 912 998 checked_read_a( ret->indices, x42Index_t, h->numIndices, 4 ); 913 999 1000 if( h->ident.version >= X42_VER_V6 ) 1001 { 1002 checked_read_a( ret->morphIndices, x42Index_t, h->numMorphDeltas, 4 ); 1003 checked_read_packed_floats( ret->morphPos, pack.morphPosPack, 3, h->numMorphDeltas, sizeof( vec4_t ) ); 1004 1005 if( ret->morphNorm ) 1006 { 1007 checked_read_packed_floats_s8n( &ret->morphNorm[0].norm, 3, h->numMorphDeltas, sizeof( x42morphNormal_t ) ); 1008 } 1009 else if( h->modelFlags & X42_MF_HAS_NORMALS ) 1010 checked_skip( sizeof( s8[3] ) * h->numMorphDeltas, 0 ); 1011 1012 if( ret->morphTan ) 1013 { 1014 checked_read_packed_floats_s8n( &ret->morphTan[0].tan, 7, h->numMorphDeltas, sizeof( x42morphTangent_t ) ); 1015 } 1016 else if( h->modelFlags & X42_MF_HAS_TANGENT_BASIS ) 1017 checked_skip( sizeof( s8[7] ) * h->numMorphDeltas, 0 ); 1018 } 1019 914 1020 checked_read( (char*)ret->strings, u8, h->nameBlobLen ); 915 1021 … … 956 1062 } 957 1063 1064 static void swap_x42PackHeader_v6_t( x42PackHeader_v6_t *pack ) 1065 { 1066 pack->animPosPack[0][0] = swap_f32( pack->animPosPack[0][0] ); 1067 pack->animPosPack[0][1] = swap_f32( pack->animPosPack[0][1] ); 1068 pack->animPosPack[1][0] = swap_f32( pack->animPosPack[1][0] ); 1069 pack->animPosPack[1][1] = swap_f32( pack->animPosPack[1][1] ); 1070 pack->animPosPack[2][0] = swap_f32( pack->animPosPack[2][0] ); 1071 pack->animPosPack[2][1] = swap_f32( pack->animPosPack[2][1] ); 1072 1073 pack->animScalePack[0] = swap_f32( pack->animScalePack[0] ); 1074 pack->animScalePack[1] = swap_f32( pack->animScalePack[1] ); 1075 1076 pack->vertPosPack[0][0] = swap_f32( pack->vertPosPack[0][0] ); 1077 pack->vertPosPack[0][1] = swap_f32( pack->vertPosPack[0][1] ); 1078 pack->vertPosPack[1][0] = swap_f32( pack->vertPosPack[1][0] ); 1079 pack->vertPosPack[1][1] = swap_f32( pack->vertPosPack[1][1] ); 1080 pack->vertPosPack[2][0] = swap_f32( pack->vertPosPack[2][0] ); 1081 pack->vertPosPack[2][1] = swap_f32( pack->vertPosPack[2][1] ); 1082 1083 pack->vertTcPack[0][0] = swap_f32( pack->vertTcPack[0][0] ); 1084 pack->vertTcPack[0][1] = swap_f32( pack->vertTcPack[0][1] ); 1085 pack->vertTcPack[1][0] = swap_f32( pack->vertTcPack[1][0] ); 1086 pack->vertTcPack[1][1] = swap_f32( pack->vertTcPack[1][1] ); 1087 1088 pack->morphPosPack[0][0] = swap_f32( pack->morphPosPack[0][0] ); 1089 pack->morphPosPack[0][1] = swap_f32( pack->morphPosPack[0][1] ); 1090 pack->morphPosPack[1][0] = swap_f32( pack->morphPosPack[1][0] ); 1091 pack->morphPosPack[1][1] = swap_f32( pack->morphPosPack[1][1] ); 1092 pack->morphPosPack[2][0] = swap_f32( pack->morphPosPack[2][0] ); 1093 pack->morphPosPack[2][1] = swap_f32( pack->morphPosPack[2][1] ); 1094 } 1095 958 1096 static void swap_x42KeyStreamEntry_v5_t( x42KeyStreamEntry_v5_t *ks ) 959 1097 { … … 1049 1187 } 1050 1188 1189 static void swap_x42MorphTarget_v6_t( x42MorphTarget_v6_t *morph ) 1190 { 1191 morph->targetName = swap_u16( morph->targetName ); 1192 morph->targetGroup = swap_u16( morph->targetGroup ); 1193 morph->firstDelta = swap_u32( morph->firstDelta ); 1194 morph->numDeltas = swap_u32( morph->numDeltas ); 1195 } 1196 1051 1197 static bool load_swapped( x42data_t *ret, const x42header_t *h, 1052 1198 x42inStream_t *file_stream, size_t inPos ) … … 1055 1201 1056 1202 bool stat; 1057 x42PackHeader_v 5_t pack;1203 x42PackHeader_v6_t pack; 1058 1204 1059 1205 /* … … 1064 1210 1065 1211 #define checked_read( buf, type, count ) \ 1066 if( !const_cond_false ) \1212 if( const_cond_true ) \ 1067 1213 { \ 1068 1214 uint _i; \ … … 1080 1226 1081 1227 #define checked_align( a ) \ 1082 if( !const_cond_false ) \1228 if( const_cond_true ) \ 1083 1229 { \ 1084 1230 stat = align_stream( file_stream, &inPos, a ); \ … … 1089 1235 1090 1236 #define checked_read_a( buf, type, count, a ) \ 1091 if( !const_cond_false ) \1237 if( const_cond_true ) \ 1092 1238 { \ 1093 1239 checked_align( a ); \ … … 1098 1244 1099 1245 #define checked_read_packed_floats( buf, pack, comps, count, stride ) \ 1100 if( !const_cond_false ) \1246 if( const_cond_true ) \ 1101 1247 { \ 1102 1248 checked_align( 2 ); \ … … 1109 1255 1110 1256 #define checked_read_packed_floats_s16n( buf, comps, count, stride ) \ 1111 if( !const_cond_false ) \1257 if( const_cond_true ) \ 1112 1258 { \ 1113 1259 checked_align( 2 ); \ … … 1120 1266 1121 1267 #define checked_read_packed_floats_s8n( buf, comps, count, stride ) \ 1122 if( !const_cond_false ) \1268 if( const_cond_true ) \ 1123 1269 { \ 1124 1270 checked_align( 1 ); \ … … 1131 1277 1132 1278 #define checked_skip( size, a ) \ 1133 if( !const_cond_false ) \1279 if( const_cond_true ) \ 1134 1280 { \ 1135 1281 size_t cb = (size); \ … … 1148 1294 */ 1149 1295 1150 checked_read( &pack, x42PackHeader_v5_t, 1 ); 1296 if( h->ident.version < X42_VER_V6 ) 1297 { 1298 memset( &pack, 0, sizeof( pack ) ); 1299 checked_read( (x42PackHeader_v5_t*)&pack, x42PackHeader_v5_t, 1 ); //x42PackHeader_v6_t's first fields are identical to those of x42PackHeader_v5_t 1300 } 1301 else 1302 { 1303 checked_read( &pack, x42PackHeader_v6_t, 1 ); 1304 } 1151 1305 1152 1306 checked_read_a( ret->bones, x42Bone_v5_t, h->numBones, 8 ); … … 1190 1344 checked_read_a( ret->lods, x42LodRange_v5_t, h->numLods, 8 ); 1191 1345 checked_read_a( ret->groups, x42Group_v5_t, h->numGroups, 8 ); 1346 1347 if( h->ident.version >= X42_VER_V6 ) 1348 checked_read_a( ret->morphTargets, x42MorphTarget_v6_t, h->numMorphTargets, 8 ); 1192 1349 1193 1350 checked_read_packed_floats( &ret->vertPos[0].pos, pack.vertPosPack, 3, h->numVerts, sizeof( x42vertAnim_t ) ); … … 1281 1438 checked_read_a( ret->indices, x42Index_t, h->numIndices, 4 ); 1282 1439 1440 if( h->ident.version >= X42_VER_V6 ) 1441 { 1442 checked_read_a( ret->morphIndices, x42Index_t, h->numMorphDeltas, 4 ); 1443 checked_read_packed_floats( ret->morphPos, pack.morphPosPack, 3, h->numMorphDeltas, sizeof( vec4_t ) ); 1444 1445 if( ret->morphNorm ) 1446 { 1447 checked_read_packed_floats_s8n( &ret->morphNorm[0].norm, 3, h->numMorphDeltas, sizeof( x42morphNormal_t ) ); 1448 } 1449 else if( h->modelFlags & X42_MF_HAS_NORMALS ) 1450 checked_skip( sizeof( s8[3] ) * h->numMorphDeltas, 0 ); 1451 1452 if( ret->morphTan ) 1453 { 1454 checked_read_packed_floats_s8n( &ret->morphTan[0].tan, 7, h->numMorphDeltas, sizeof( x42morphTangent_t ) ); 1455 } 1456 else if( h->modelFlags & X42_MF_HAS_TANGENT_BASIS ) 1457 checked_skip( sizeof( s8[7] ) * h->numMorphDeltas, 0 ); 1458 } 1459 1283 1460 checked_read( (char*)ret->strings, u8, h->nameBlobLen ); 1284 1461 branches/morph-targets/libx42/local.h
r500 r501 121 121 size_t elemSize, uint numElems, x42opts_t *opts ); 122 122 123 #define fail_r( code, msg ) if( const_cond_true ) { LIBX42_ERROR_EVENT( code, msg ); return; } else return 124 #define fail_rn( code, msg ) if( const_cond_true ) { LIBX42_ERROR_EVENT( code, msg ); return NULL; } return NULL 125 #define fail_rz( code, msg ) if( const_cond_true ) { LIBX42_ERROR_EVENT( code, msg ); return 0; } else return 0 126 #define fail_rf( code, msg ) if( const_cond_true ) { LIBX42_ERROR_EVENT( code, msg ); return false; } else return false 127 #define fail_rv( code, msg, v ) if( const_cond_true ) { LIBX42_ERROR_EVENT( code, msg ); return (v); } else return (v) 128 #define fail_go( code, mst, label ) if( const_cond_true ) { LIBX42_ERROR_EVENT( code, msg ); goto label; } else goto label 123 /* error handling macro goodness */ 124 #define fail_r( code, msg ) if( const_cond_true ) { LIBX42_ERROR_EVENT( code, msg ); return; } else return 125 #define fail_rn( code, msg ) if( const_cond_true ) { LIBX42_ERROR_EVENT( code, msg ); return NULL; } return NULL 126 #define fail_rz( code, msg ) if( const_cond_true ) { LIBX42_ERROR_EVENT( code, msg ); return 0; } else return 0 127 #define fail_rf( code, msg ) if( const_cond_true ) { LIBX42_ERROR_EVENT( code, msg ); return false; } else return false 128 #define fail_rv( code, msg, v ) if( const_cond_true ) { LIBX42_ERROR_EVENT( code, msg ); return (v); } else return (v) 129 #define fail_go( code, mst, label ) if( const_cond_true ) { LIBX42_ERROR_EVENT( code, msg ); goto label; } else goto label 129 130 130 #define demand_r( cond, code, msg ) if( !(cond) ) { LIBX42_ERROR_EVENT( code, msg ); return; }else (void)0131 #define demand_rn( cond, code, msg ) if( !(cond) ) { LIBX42_ERROR_EVENT( code, msg ); return NULL; }else (void)0132 #define demand_rz( cond, code, msg ) if( !(cond) ) { LIBX42_ERROR_EVENT( code, msg ); return 0; }else (void)0133 #define demand_rf( cond, code, msg ) if( !(cond) ) { LIBX42_ERROR_EVENT( code, msg ); return false; }else (void)0134 #define demand_rv( cond, code, msg, v ) if( !(cond) ) { LIBX42_ERROR_EVENT( code, msg ); return (v); }else (void)0135 #define demand_go( cond, code, msg, label ) if( !(cond) ) { LIBX42_ERROR_EVENT( code, msg ); goto label; }else (void)0131 #define demand_r( cond, code, msg ) if( !(cond) ) { LIBX42_ERROR_EVENT( code, msg ); return; } else (void)0 132 #define demand_rn( cond, code, msg ) if( !(cond) ) { LIBX42_ERROR_EVENT( code, msg ); return NULL; } else (void)0 133 #define demand_rz( cond, code, msg ) if( !(cond) ) { LIBX42_ERROR_EVENT( code, msg ); return 0; } else (void)0 134 #define demand_rf( cond, code, msg ) if( !(cond) ) { LIBX42_ERROR_EVENT( code, msg ); return false; } else (void)0 135 #define demand_rv( cond, code, msg, v ) if( !(cond) ) { LIBX42_ERROR_EVENT( code, msg ); return (v); } else (void)0 136 #define demand_go( cond, code, msg, label ) if( !(cond) ) { LIBX42_ERROR_EVENT( code, msg ); goto label; } else (void)0 136 137 137 138 #ifdef DEBUG … … 142 143 #endif 143 144 144 #define assert( cond, code, msg ) if( !(cond) ) { LIBX42_ERROR_EVENT( code, msg ); debugger_break(); }else (void)0145 #define assert( cond, code, msg ) if( !(cond) ) { LIBX42_ERROR_EVENT( code, msg ); debugger_break(); } else (void)0 145 146 #else 146 #define assert( cond, code, msg ) if( !const_cond_false ) { (void)sizeof( cond ); }else (void)0147 #define assert( cond, code, msg ) if( const_cond_true ) { (void)sizeof( cond ); } else (void)0 147 148 #endif 148 149 branches/morph-targets/libx42/write.c
r471 r501 436 436 437 437 #define checked_write( buf, size ) \ 438 if( !const_cond_false ) \438 if( const_cond_true ) \ 439 439 { \ 440 440 size_t cb = (size); \ … … 448 448 449 449 #define checked_align( a ) \ 450 if( !const_cond_false ) \450 if( const_cond_true ) \ 451 451 { \ 452 452 stat = align_stream( file_stream, &outPos, a ); \ … … 457 457 458 458 #define checked_write_a( buf, size, a ) \ 459 if( !const_cond_false ) \459 if( const_cond_true ) \ 460
