================ idDeclAF::ParseSpring ================ */
| 1281 | ================ |
| 1282 | */ |
| 1283 | bool idDeclAF::ParseSpring( idLexer &src ) { |
| 1284 | idToken token; |
| 1285 | idDeclAF_Constraint *constraint = new idDeclAF_Constraint; |
| 1286 | |
| 1287 | constraint->SetDefault( this ); |
| 1288 | constraints.Alloc() = constraint; |
| 1289 | |
| 1290 | if ( !src.ExpectTokenType( TT_STRING, 0, &token ) || |
| 1291 | !src.ExpectTokenString( "{" ) ) { |
| 1292 | return false; |
| 1293 | } |
| 1294 | |
| 1295 | constraint->type = DECLAF_CONSTRAINT_SPRING; |
| 1296 | constraint->limit = idDeclAF_Constraint::LIMIT_NONE; |
| 1297 | constraint->name = token; |
| 1298 | constraint->friction = 0.5f; |
| 1299 | |
| 1300 | while( src.ReadToken( &token ) ) { |
| 1301 | |
| 1302 | if ( !token.Icmp( "body1" ) ) { |
| 1303 | src.ExpectTokenType( TT_STRING, 0, &token ); |
| 1304 | constraint->body1 = token; |
| 1305 | } else if ( !token.Icmp( "body2" ) ) { |
| 1306 | src.ExpectTokenType( TT_STRING, 0, &token ); |
| 1307 | constraint->body2 = token; |
| 1308 | } else if ( !token.Icmp( "anchor1" ) ) { |
| 1309 | if ( !constraint->anchor.Parse( src ) ) { |
| 1310 | return false; |
| 1311 | } |
| 1312 | } else if ( !token.Icmp( "anchor2" ) ) { |
| 1313 | if ( !constraint->anchor2.Parse( src ) ) { |
| 1314 | return false; |
| 1315 | } |
| 1316 | } else if ( !token.Icmp( "friction" ) ) { |
| 1317 | constraint->friction = src.ParseFloat(); |
| 1318 | } else if ( !token.Icmp( "stretch" ) ) { |
| 1319 | constraint->stretch = src.ParseFloat(); |
| 1320 | } else if ( !token.Icmp( "compress" ) ) { |
| 1321 | constraint->compress = src.ParseFloat(); |
| 1322 | } else if ( !token.Icmp( "damping" ) ) { |
| 1323 | constraint->damping = src.ParseFloat(); |
| 1324 | } else if ( !token.Icmp( "restLength" ) ) { |
| 1325 | constraint->restLength = src.ParseFloat(); |
| 1326 | } else if ( !token.Icmp( "minLength" ) ) { |
| 1327 | constraint->minLength = src.ParseFloat(); |
| 1328 | } else if ( !token.Icmp( "maxLength" ) ) { |
| 1329 | constraint->maxLength = src.ParseFloat(); |
| 1330 | } else if ( token == "}" ) { |
| 1331 | break; |
| 1332 | } else { |
| 1333 | src.Error( "unknown token %s in spring", token.c_str() ); |
| 1334 | return false; |
| 1335 | } |
| 1336 | } |
| 1337 | |
| 1338 | return true; |
| 1339 | } |
| 1340 |
nothing calls this directly
no test coverage detected