Module: CP::Shape
- Included in:
- Circle, Poly, Segment
- Defined in:
- lib/chipmunk-ffi/shape.rb,
lib/chipmunk-ffi/unsafe.rb
Defined Under Namespace
Classes: Circle, Poly, Segment, SegmentQueryInfo
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#struct ⇒ Object
Returns the value of attribute struct.
67
68
69
|
# File 'lib/chipmunk-ffi/shape.rb', line 67
def struct
@struct
end
|
Class Method Details
.reset_id_counter ⇒ Object
160
161
162
|
# File 'lib/chipmunk-ffi/shape.rb', line 160
def self.reset_id_counter
CP.cpResetShapeIdCounter
end
|
Instance Method Details
#bb ⇒ Object
100
101
102
103
104
105
106
|
# File 'lib/chipmunk-ffi/shape.rb', line 100
def bb
our_bb = @struct.bb
size = BBStruct.size
bb_ptr = FFI::MemoryPointer.new size
bb_ptr.send(:put_bytes, 0, our_bb.to_bytes, 0, size)
BB.new(BBStruct.new(bb_ptr))
end
|
#body ⇒ Object
69
70
71
|
# File 'lib/chipmunk-ffi/shape.rb', line 69
def body
@body
end
|
#body=(new_body) ⇒ Object
72
73
74
75
|
# File 'lib/chipmunk-ffi/shape.rb', line 72
def body=(new_body)
@struct.body = new_body.struct.pointer
@body = new_body
end
|
#cache_bb ⇒ Object
108
109
110
111
|
# File 'lib/chipmunk-ffi/shape.rb', line 108
def cache_bb
CP.cpShapeCacheBB(@struct.bb)
bb
end
|
#collision_type ⇒ Object
77
78
79
|
# File 'lib/chipmunk-ffi/shape.rb', line 77
def collision_type
@collType
end
|
#collision_type=(col_type) ⇒ Object
80
81
82
83
|
# File 'lib/chipmunk-ffi/shape.rb', line 80
def collision_type=(col_type)
@collType = col_type
@struct.collision_type = col_type.object_id
end
|
#data ⇒ Object
126
127
128
|
# File 'lib/chipmunk-ffi/shape.rb', line 126
def data
@struct.data
end
|
#data=(new_data) ⇒ Object
129
130
131
|
# File 'lib/chipmunk-ffi/shape.rb', line 129
def data=(new_data)
@struct.data = new_data
end
|
#e ⇒ Object
112
113
114
|
# File 'lib/chipmunk-ffi/shape.rb', line 112
def e
@struct.e
end
|
#e=(new_e) ⇒ Object
115
116
117
|
# File 'lib/chipmunk-ffi/shape.rb', line 115
def e=(new_e)
@struct.e = new_e
end
|
#group ⇒ Object
85
86
87
|
# File 'lib/chipmunk-ffi/shape.rb', line 85
def group
@group
end
|
#group=(group_obj) ⇒ Object
88
89
90
91
|
# File 'lib/chipmunk-ffi/shape.rb', line 88
def group=(group_obj)
@group = group_obj
@struct.group = group_obj.object_id
end
|
#layers ⇒ Object
93
94
95
|
# File 'lib/chipmunk-ffi/shape.rb', line 93
def layers
@struct.layers
end
|
#layers=(l) ⇒ Object
96
97
98
|
# File 'lib/chipmunk-ffi/shape.rb', line 96
def layers=(l)
@struct.layers = l
end
|
#point_query(point) ⇒ Object
147
148
149
150
|
# File 'lib/chipmunk-ffi/shape.rb', line 147
def point_query(point)
bool_int = CP.cpShapePointQuery(@struct.pointer, point.struct)
bool_int == 0 ? false : true
end
|
#segment_query(a, b) ⇒ Object
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
# File 'lib/chipmunk-ffi/shape.rb', line 164
def segment_query(a,b)
ptr = FFI::MemoryPointer.new(SegmentQueryInfoStruct.size)
info = SegmentQueryInfoStruct.new ptr
bool_int = CP.cpShapeSegmentQuery(@struct.pointer, a.struct.pointer, b.struct.pointer, ptr)
hit = bool_int == 0 ? false : true
if hit
n = Vec2.new(info.n)
SegmentQueryInfo.new hit, info.t, n, info, ptr
else
SegmentQueryInfo.new hit
end
end
|
#sensor=(new_sensor) ⇒ Object
143
144
145
|
# File 'lib/chipmunk-ffi/shape.rb', line 143
def sensor=(new_sensor)
@struct.sensor = new_sensor ? 1 : 0
end
|
#sensor? ⇒ Boolean
140
141
142
|
# File 'lib/chipmunk-ffi/shape.rb', line 140
def sensor?
@struct.sensor == 0 ? false : true
end
|
#set_data_pointer ⇒ Object
152
153
154
155
156
157
158
|
# File 'lib/chipmunk-ffi/shape.rb', line 152
def set_data_pointer
mem = FFI::MemoryPointer.new(:long)
mem.put_long 0, object_id
@shape_pointer = mem
@struct.data = mem
end
|
#surface_v ⇒ Object
133
134
135
|
# File 'lib/chipmunk-ffi/shape.rb', line 133
def surface_v
Vec2.new @struct.surface_v
end
|
#surface_v=(new_sv) ⇒ Object
136
137
138
|
# File 'lib/chipmunk-ffi/shape.rb', line 136
def surface_v=(new_sv)
@struct.surface_v.pointer.put_bytes 0, new_sv.struct.to_bytes, 0,Vect.size
end
|
#u ⇒ Object
119
120
121
|
# File 'lib/chipmunk-ffi/shape.rb', line 119
def u
@struct.u
end
|
#u=(new_u) ⇒ Object
122
123
124
|
# File 'lib/chipmunk-ffi/shape.rb', line 122
def u=(new_u)
@struct.u = new_u
end
|