| 2467 | } |
| 2468 | |
| 2469 | void EETest::physicsUpdate() { |
| 2470 | #ifndef EE_PLATFORM_TOUCH |
| 2471 | const Vector2f mousePos( KM->getMousePos().asFloat() ); |
| 2472 | mMousePoint = cVectNew( mousePos.x, mousePos.y ); |
| 2473 | cVect newPoint = tovect( cpvlerp( tocpv( mMousePoint_last ), tocpv( mMousePoint ), 0.25 ) ); |
| 2474 | mMouseBody->setPos( newPoint ); |
| 2475 | mMouseBody->setVel( ( newPoint - mMousePoint_last ) * (cpFloat)mWindow->getFPS() ); |
| 2476 | mMousePoint_last = newPoint; |
| 2477 | |
| 2478 | if ( KM->isMouseLeftPressed() ) { |
| 2479 | if ( NULL == mMouseJoint ) { |
| 2480 | cVect point = cVectNew( mousePos.x, mousePos.y ); |
| 2481 | |
| 2482 | Shape* shape = mSpace->pointQueryFirst( point, GRABABLE_MASK_BIT, CP_NO_GROUP ); |
| 2483 | |
| 2484 | if ( NULL != shape ) { |
| 2485 | mMouseJoint = eeNew( PivotJoint, ( mMouseBody, shape->getBody(), cVectZero, |
| 2486 | shape->getBody()->world2Local( point ) ) ); |
| 2487 | |
| 2488 | mMouseJoint->setMaxForce( 50000.0f ); |
| 2489 | mSpace->addConstraint( mMouseJoint ); |
| 2490 | } |
| 2491 | } |
| 2492 | } else if ( NULL != mMouseJoint ) { |
| 2493 | mSpace->removeConstraint( mMouseJoint ); |
| 2494 | eeSAFE_DELETE( mMouseJoint ); |
| 2495 | } |
| 2496 | #else |
| 2497 | for ( Uint32 i = 0; i < EE_MAX_FINGERS; i++ ) { |
| 2498 | InputFinger* Finger = KM->getFingerIndex( i ); |
| 2499 | mMousePoint[i] = cVectNew( Finger->x, Finger->y ); |
| 2500 | cVect newPoint = |
| 2501 | tovect( cpvlerp( tocpv( mMousePoint_last[i] ), tocpv( mMousePoint[i] ), 0.25 ) ); |
| 2502 | mMouseBody[i]->setPos( newPoint ); |
| 2503 | mMouseBody[i]->setVel( ( newPoint - mMousePoint_last[i] ) * (cpFloat)mWindow->getFPS() ); |
| 2504 | mMousePoint_last[i] = newPoint; |
| 2505 | |
| 2506 | if ( Finger->isDown() ) { |
| 2507 | if ( NULL == mMouseJoint[i] ) { |
| 2508 | cVect point = cVectNew( Finger->x, Finger->y ); |
| 2509 | |
| 2510 | Shape* shape = mSpace->pointQueryFirst( point, GRABABLE_MASK_BIT, CP_NO_GROUP ); |
| 2511 | |
| 2512 | if ( NULL != shape ) { |
| 2513 | mMouseJoint[i] = |
| 2514 | eeNew( PivotJoint, ( mMouseBody[i], shape->getBody(), cVectZero, |
| 2515 | shape->getBody()->world2Local( point ) ) ); |
| 2516 | |
| 2517 | mMouseJoint[i]->setMaxForce( 50000.0f ); |
| 2518 | mSpace->addConstraint( mMouseJoint[i] ); |
| 2519 | } |
| 2520 | } |
| 2521 | } else if ( NULL != mMouseJoint[i] ) { |
| 2522 | mSpace->removeConstraint( mMouseJoint[i] ); |
| 2523 | eeSAFE_DELETE( mMouseJoint[i] ); |
| 2524 | } |
| 2525 | } |
| 2526 | #endif |
nothing calls this directly
no test coverage detected