/* * Chipmunk2d::Constraint#max_force * @return [Float] */ static mrb_value constraint_get_max_force(mrb_state *mrb, mrb_value self) { cpConstraint *constraint; cpFloat max_force; constraint = mrb_data_get_ptr(mrb, self, &mrb_cp_constraint_type); max_force = cpConstraintGetMaxForce(constraint); return mrb_float_value(mrb, max_force); }
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::getMaxForce() { return cpConstraintGetMaxForce(this->m_constraint); }