================ idDeclAF::ParseBallAndSocketJoint ================ */
| 1013 | ================ |
| 1014 | */ |
| 1015 | bool idDeclAF::ParseBallAndSocketJoint( idLexer &src ) { |
| 1016 | idToken token; |
| 1017 | idDeclAF_Constraint *constraint = new idDeclAF_Constraint; |
| 1018 | |
| 1019 | constraint->SetDefault( this ); |
| 1020 | constraints.Alloc() = constraint; |
| 1021 | |
| 1022 | if ( !src.ExpectTokenType( TT_STRING, 0, &token ) || |
| 1023 | !src.ExpectTokenString( "{" ) ) { |
| 1024 | return false; |
| 1025 | } |
| 1026 | |
| 1027 | constraint->type = DECLAF_CONSTRAINT_BALLANDSOCKETJOINT; |
| 1028 | constraint->limit = idDeclAF_Constraint::LIMIT_NONE; |
| 1029 | constraint->name = token; |
| 1030 | constraint->friction = 0.5f; |
| 1031 | constraint->anchor.ToVec3().Zero(); |
| 1032 | constraint->shaft[0].ToVec3().Zero(); |
| 1033 | |
| 1034 | while( src.ReadToken( &token ) ) { |
| 1035 | |
| 1036 | if ( !token.Icmp( "body1" ) ) { |
| 1037 | src.ExpectTokenType( TT_STRING, 0, &token ); |
| 1038 | constraint->body1 = token; |
| 1039 | } else if ( !token.Icmp( "body2" ) ) { |
| 1040 | src.ExpectTokenType( TT_STRING, 0, &token ); |
| 1041 | constraint->body2 = token; |
| 1042 | } else if ( !token.Icmp( "anchor" ) ) { |
| 1043 | if ( !constraint->anchor.Parse( src ) ) { |
| 1044 | return false; |
| 1045 | } |
| 1046 | } else if ( !token.Icmp( "conelimit" ) ) { |
| 1047 | if ( !constraint->limitAxis.Parse( src ) || |
| 1048 | !src.ExpectTokenString( "," ) ) { |
| 1049 | return false; |
| 1050 | } |
| 1051 | constraint->limitAngles[0] = src.ParseFloat(); |
| 1052 | if ( !src.ExpectTokenString( "," ) || |
| 1053 | !constraint->shaft[0].Parse( src ) ) { |
| 1054 | return false; |
| 1055 | } |
| 1056 | constraint->limit = idDeclAF_Constraint::LIMIT_CONE; |
| 1057 | } else if ( !token.Icmp( "pyramidlimit" ) ) { |
| 1058 | if ( !constraint->limitAxis.Parse( src ) || |
| 1059 | !src.ExpectTokenString( "," ) ) { |
| 1060 | return false; |
| 1061 | } |
| 1062 | constraint->limitAngles[0] = src.ParseFloat(); |
| 1063 | if ( !src.ExpectTokenString( "," ) ) { |
| 1064 | return false; |
| 1065 | } |
| 1066 | constraint->limitAngles[1] = src.ParseFloat(); |
| 1067 | if ( !src.ExpectTokenString( "," ) ) { |
| 1068 | return false; |
| 1069 | } |
| 1070 | constraint->limitAngles[2] = src.ParseFloat(); |
| 1071 | if ( !src.ExpectTokenString( "," ) || |
| 1072 | !constraint->shaft[0].Parse( src ) ) { |
nothing calls this directly
no test coverage detected