/* * Chipmunk2d::Constraint#impulse * @return [Float] */ static mrb_value constraint_get_impulse(mrb_state *mrb, mrb_value self) { cpConstraint *constraint; cpFloat impulse; constraint = mrb_data_get_ptr(mrb, self, &mrb_cp_constraint_type); impulse = cpConstraintGetImpulse(constraint); return mrb_float_value(mrb, impulse); }
void Chains::BreakableJointPostSolve(cpConstraint *joint, cpSpace *space) { cpFloat dt = cpSpaceGetCurrentTimeStep(space); // Convert the impulse to a force by dividing it by the timestep. cpFloat force = cpConstraintGetImpulse(joint)/dt; cpFloat maxForce = cpConstraintGetMaxForce(joint); // If the force is almost as big as the joint's max force, break it. if(force > 0.9*maxForce){ cpSpaceAddPostStepCallback(space, (cpPostStepFunc)BreakablejointPostStepRemove, joint, NULL); } }
cpFloat CCJoint::getImpulse() { return cpConstraintGetImpulse(this->m_constraint); }