unsigned cPhysicsJointScrewNewton::LimitCallback(const NewtonJoint* pScrew, NewtonHingeSliderUpdateDesc* pDesc) { cPhysicsJointScrewNewton* pScrewJoint = (cPhysicsJointScrewNewton*)NewtonJointGetUserData(pScrew); //pScrewJoint->OnPhysicsUpdate(); float fDistance = NewtonCorkscrewGetJointPosit (pScrew); //Log("Dist: %f\n",fDistance); if(pScrewJoint->mfMinDistance == 0 && pScrewJoint->mfMaxDistance == 0) return 0; //Avoid oscillation CheckLimitAutoSleep(pScrewJoint, pScrewJoint->mfMinDistance,pScrewJoint->mfMaxDistance,fDistance); if (fDistance < pScrewJoint->mfMinDistance) { pScrewJoint->OnMinLimit(); pDesc->m_accel = NewtonCorkscrewCalculateStopAccel (pScrew, pDesc, pScrewJoint->mfMinDistance); pDesc->m_minFriction =0; return 1; } else if (fDistance > pScrewJoint->mfMaxDistance) { pScrewJoint->OnMaxLimit(); pDesc->m_accel = NewtonCorkscrewCalculateStopAccel (pScrew, pDesc, pScrewJoint->mfMaxDistance); pDesc->m_maxFriction =0; return 1; } else { if(pScrewJoint->mpParentBody ==NULL || pScrewJoint->mpParentBody->GetMass()==0) { if( (pScrewJoint->mfStickyMaxDistance != 0 && fabs(fDistance - pScrewJoint->mfMaxDistance) < pScrewJoint->mfStickyMaxDistance) || (pScrewJoint->mfStickyMinDistance != 0 && fabs(fDistance - pScrewJoint->mfMinDistance) < pScrewJoint->mfStickyMinDistance) ) { pScrewJoint->mpChildBody->SetAngularVelocity(0); pScrewJoint->mpChildBody->SetLinearVelocity(0); } } pScrewJoint->OnNoLimit(); } return 0; }
float cPhysicsJointScrewNewton::GetDistance() { return NewtonCorkscrewGetJointPosit(mpNewtonJoint); }
dFloat Roket_PhysicsJointCorkscrew::getPosition() { return NewtonCorkscrewGetJointPosit(joint); }