|
From: Charles L. <cn...@us...> - 2009-04-20 21:38:02
|
Update of /cvsroot/hgengine/Mercury/src In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv19703 Modified Files: BetabetaMari.h BetaBetaMari.cpp Log Message: fix up Index: BetabetaMari.h =================================================================== RCS file: /cvsroot/hgengine/Mercury/src/BetabetaMari.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** BetabetaMari.h 5 Sep 2007 01:10:20 -0000 1.10 --- BetabetaMari.h 20 Apr 2009 21:37:49 -0000 1.11 *************** *** 25,28 **** --- 25,30 ---- //Is this the first update? bool m_bFirstUpdate; + MercuryPoint pLastGood; + MQuaternion qLastGood; }; Index: BetaBetaMari.cpp =================================================================== RCS file: /cvsroot/hgengine/Mercury/src/BetaBetaMari.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** BetaBetaMari.cpp 5 Sep 2007 01:10:20 -0000 1.25 --- BetaBetaMari.cpp 20 Apr 2009 21:37:49 -0000 1.26 *************** *** 2,5 **** --- 2,6 ---- #include "MercuryMath.h" #include "MercuryTheme.h" + #include "MercuryLog.h" #define MC_INPUTMAPPED 1 //convention: MESSAGE CODE *************** *** 39,43 **** //Generate the new ball collision object ! m_pSph = dCreateSphere( m_oSpace, SQRT( fMariSize )+1 ); dGeomSetData( m_pSph, this ); dGeomSetBody( m_pSph, m_oBody ); --- 40,44 ---- //Generate the new ball collision object ! m_pSph = dCreateSphere( m_oSpace, pow( fMariSize, 0.56)*1.1+1 ); dGeomSetData( m_pSph, this ); dGeomSetBody( m_pSph, m_oBody ); *************** *** 47,51 **** { //Generate the ball itself, and attach it to the local space ! m_pSph = dCreateSphere( m_oSpace, SQRT( fMariSize ) + 1 ); dGeomSetBody( m_pSph, m_oBody ); dGeomSetData( m_pSph, this ); --- 48,52 ---- { //Generate the ball itself, and attach it to the local space ! m_pSph = dCreateSphere( m_oSpace, pow( fMariSize, 0.56 )+1 ); dGeomSetBody( m_pSph, m_oBody ); dGeomSetData( m_pSph, this ); *************** *** 57,60 **** --- 58,81 ---- } + const float * fPos = dBodyGetPosition( GetBody() ); + if( fPos[0] > -1500 && fPos[0] < 1500 && ( fPos[0]>0 || fPos[0]<0 )&& !( fPos[0]>0&&fPos[0]<=0) ) + { + pLastGood = MercuryPoint( fPos ); + qLastGood = MQuaternion( (float*) dBodyGetQuaternion( GetBody() ) ); + dBodySetFiniteRotationMode( GetBody(), false ); + } + else + { + pLastGood.z += 0.1; + dBodySetPosition( GetBody(), pLastGood.x, pLastGood.y, pLastGood.z ); + qLastGood.x += 0.1; qLastGood.y += 0.01; + qLastGood = qLastGood.normalize(); + dBodySetQuaternion( GetBody(), &qLastGood.w ); + dBodySetFiniteRotationMode( GetBody(), true ); + + dBodySetLinearVel( GetBody(), 0, 0, 0 ); + dBodySetAngularVel( GetBody(), 0, 0, 0 ); + } + //Continue update cycle MercuryODEObjectLoadable::Update( dTime ); *************** *** 67,71 **** MercuryODEObjectLoadable* pHit2 = (MercuryODEObjectLoadable*)data.PeekItem(5).GetValueV(); MercuryODEWorld* pWorld = (MercuryODEWorld*)data.PeekItem(4).GetValueV(); - fMariSize += data.PeekItem().GetValueF(); //Increase the size of our mari MercuryPoint DX(data.PeekItem(3).GetValueF(), --- 88,91 ---- *************** *** 73,84 **** data.PeekItem(1).GetValueF()); //Get the position of the contact DX = DX - GetPosition(); //And find the relative position - //Verify that we didn't get a bogus hit. - if( (SQRT( fMariSize )+1) * 1.1 < DX.Magnitude() ) - return; - // stick->Play(); //Begin dismantling the hit object --- 93,111 ---- data.PeekItem(1).GetValueF()); + + //Verify that we didn't get a bogus hit. //this doesn't seem to work + // if( (pow( fMariSize, 0.56 )+1) * 1.1 < DX.Magnitude() ) + // return; + + fMariSize += data.PeekItem().GetValueF(); //Increase the size of our mari + //Get the position of the contact DX = DX - GetPosition(); //And find the relative position // stick->Play(); + //Destroy it's body information + if (pHit2->GetBody()) + dBodyDestroy( pHit2->GetBody() ); + //Begin dismantling the hit object *************** *** 125,132 **** pHit2->m_bBodied = false; - //Destroy it's body information - if (pHit2->GetBody()) - dBodyDestroy( pHit2->GetBody() ); - //Clean out the old object pHit2->m_vAllGeoms.clear(); --- 152,155 ---- *************** *** 140,145 **** MercuryODEObjectLoadable * pHit2 = (MercuryODEObjectLoadable*)pHit; ! if ( !pHit2->m_bBodied ) //Make sure what we are colliding with has a body, otherwise act normally ! return true; if ( pHit == this ) //If we're colliding with part of ourself, ignore. return false; --- 163,168 ---- MercuryODEObjectLoadable * pHit2 = (MercuryODEObjectLoadable*)pHit; ! // if ( !pHit2->m_bBodied ) //Make sure what we are colliding with has a body, otherwise act normally ! // return true; if ( pHit == this ) //If we're colliding with part of ourself, ignore. return false; *************** *** 154,159 **** float fSizeHit = pHit->GetParameter( "Size" ).GetValueF(); //Make sure we're allowed to suck it up ! if ( fSizeHit == 0 || fSizeHit > SQRT( fMariSize ) / 2.9 ) return true; --- 177,184 ---- float fSizeHit = pHit->GetParameter( "Size" ).GetValueF(); + if( fSizeHit != 0 ) + LOG.Log( ssprintf( "minsize: %f", pow( fMariSize, 0.56 ) / 2.9 ) ); //Make sure we're allowed to suck it up ! if ( fSizeHit == 0 || fSizeHit > pow( fMariSize, 0.56 ) / 2.9 ) return true; |