Class: CP::DampedRotarySpring
- Inherits:
-
Object
- Object
- CP::DampedRotarySpring
- Includes:
- Constraint
- Defined in:
- lib/chipmunk-ffi/constraints/damped_rotary_spring.rb
Constant Summary
Constants included from Constraint
Constraint::DampedRotarySpring, Constraint::DampedSpring, Constraint::GearJoint, Constraint::GrooveJoint, Constraint::PinJoint, Constraint::PivotJoint, Constraint::RatchetJoint, Constraint::RotaryLimitJoint, Constraint::SimpleMotor, Constraint::SlideJoint
Instance Attribute Summary
Attributes included from Constraint
Instance Method Summary collapse
-
#initialize(a_body, b_body, rest_angle, stiffness, damping) ⇒ DampedRotarySpring
constructor
A new instance of DampedRotarySpring.
- #spring_torque_func ⇒ Object
- #spring_torque_func=(l) ⇒ Object
Methods included from Constraint
Constructor Details
#initialize(a_body, b_body, rest_angle, stiffness, damping) ⇒ DampedRotarySpring
Returns a new instance of DampedRotarySpring.
21 22 23 24 25 26 27 |
# File 'lib/chipmunk-ffi/constraints/damped_rotary_spring.rb', line 21 def initialize(a_body, b_body,rest_angle, stiffness, damping) @body_a, @body_b = a_body, b_body @struct = DampedRotarySpringStruct.new(CP.cpDampedRotarySpringNew( a_body.struct.pointer,b_body.struct.pointer, rest_angle, stiffness, damping)) set_data_pointer set_initial_torque_proc end |
Instance Method Details
#spring_torque_func ⇒ Object
29 30 31 |
# File 'lib/chipmunk-ffi/constraints/damped_rotary_spring.rb', line 29 def spring_torque_func @user_level_torque_lambda end |
#spring_torque_func=(l) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/chipmunk-ffi/constraints/damped_rotary_spring.rb', line 33 def spring_torque_func=(l) @user_level_torque_lambda = l # We keep the lambda in an ivar to keep it from being GCed @spring_torque_lambda = Proc.new do |spring_ptr,angle| spring_struct = DampedRotarySpringStruct.new(spring_ptr) obj_id = spring_struct.constraint.data.get_long(0) spring = ObjectSpace._id2ref(obj_id) l.call(spring,angle) end @struct.spring_torque_func = @spring_torque_lambda end |