MCPcopy Create free account
hub / github.com/SpartanJ/eepp / physicsUpdate

Method physicsUpdate

src/tests/test_all/test.cpp:2469–2531  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2467}
2468
2469void 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

Callers

nothing calls this directly

Calls 15

setPosMethod · 0.80
setVelMethod · 0.80
getFPSMethod · 0.80
isMouseLeftPressedMethod · 0.80
pointQueryFirstMethod · 0.80
world2LocalMethod · 0.80
setMaxForceMethod · 0.80
addConstraintMethod · 0.80
removeConstraintMethod · 0.80
getFingerIndexMethod · 0.80
isDownMethod · 0.80
asFloatMethod · 0.45

Tested by

no test coverage detected