示例#1
0
/*
 * 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);
}
示例#2
0
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);
	}
}
示例#3
0
cpFloat CCJoint::getImpulse()
{
	return cpConstraintGetImpulse(this->m_constraint);
}