Class: CP::DampedRotarySpring
- Inherits:
-
Object
- Object
- CP::DampedRotarySpring
show all
- 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
#body_a, #body_b, #struct
Instance Method Summary
collapse
Methods included from Constraint
included, #set_data_pointer
Constructor Details
#initialize(a_body, b_body, rest_angle, stiffness, damping) ⇒ 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
@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
|