Module: CP::Shape
Defined Under Namespace
Classes: Circle, Poly, Segment
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
Class Method Details
.reset_id_counter ⇒ Object
183
184
185
186
187
|
# File 'ext/chipmunk/rb_cpShape.c', line 183
static VALUE
rb_cpShapeResetIdCounter(VALUE self) {
cpResetShapeIdCounter();
return Qnil;
}
|
Instance Method Details
#add_to_space(space) ⇒ Object
65
66
67
|
# File 'lib/chipmunk.rb', line 65
def add_to_space(space)
space.add_shape(self)
end
|
142
143
144
145
146
147
148
|
# File 'ext/chipmunk/rb_cpShape.c', line 142
static VALUE
rb_cpShapeCacheBB(VALUE self) {
cpShape *shape = SHAPE(self);
cpShapeCacheBB(shape);
return rb_cpShapeGetBB(self);
}
|
54
55
56
57
|
# File 'ext/chipmunk/rb_cpShape.c', line 54
static VALUE
rb_cpShapeGetBody(VALUE self) {
return rb_ivar_get(self, id_body);
}
|
#body=(body) ⇒ Object
71
72
73
74
75
76
77
|
# File 'ext/chipmunk/rb_cpShape.c', line 71
static VALUE
rb_cpShapeSetBody(VALUE self, VALUE body) {
SHAPE(self)->body = BODY(body);
rb_ivar_set(self, id_body, body);
return body;
}
|
142
143
144
145
146
147
148
|
# File 'ext/chipmunk/rb_cpShape.c', line 142
static VALUE
rb_cpShapeCacheBB(VALUE self) {
cpShape *shape = SHAPE(self);
cpShapeCacheBB(shape);
return rb_cpShapeGetBB(self);
}
|
#chipmunk_objects ⇒ Object
61
62
63
|
# File 'lib/chipmunk.rb', line 61
def chipmunk_objects
[self]
end
|
#collision_type ⇒ Object
79
80
81
82
|
# File 'ext/chipmunk/rb_cpShape.c', line 79
static VALUE
rb_cpShapeGetCollType(VALUE self) {
return rb_iv_get(self, "collType");
}
|
#collision_type=(val) ⇒ Object
84
85
86
87
88
89
90
91
|
# File 'ext/chipmunk/rb_cpShape.c', line 84
static VALUE
rb_cpShapeSetCollType(VALUE self, VALUE val) {
VALUE col_type = rb_obj_id(val);
rb_iv_set(self, "collType", val);
SHAPE(self)->collision_type = NUM2ULONG(col_type);
return val;
}
|
104
105
106
107
|
# File 'ext/chipmunk/rb_cpShape.c', line 104
static VALUE
rb_cpShapeGetSelf(VALUE self) {
return self;
}
|
150
151
152
153
|
# File 'ext/chipmunk/rb_cpShape.c', line 150
static VALUE
rb_cpShapeGetElasticity(VALUE self) {
return rb_float_new(SHAPE(self)->e);
}
|
160
161
162
163
164
|
# File 'ext/chipmunk/rb_cpShape.c', line 160
static VALUE
rb_cpShapeSetElasticity(VALUE self, VALUE val) {
SHAPE(self)->e = NUM2DBL(val);
return val;
}
|
110
111
112
113
|
# File 'ext/chipmunk/rb_cpShape.c', line 110
static VALUE
rb_cpShapeGetGroup(VALUE self) {
return rb_iv_get(self, "@group");
}
|
#group=(groupValue) ⇒ Object
115
116
117
118
119
120
121
|
# File 'ext/chipmunk/rb_cpShape.c', line 115
static VALUE
rb_cpShapeSetGroup(VALUE self, VALUE groupValue) {
rb_iv_set(self, "@group", groupValue);
SHAPE(self)->group = CP_OBJ2INT(groupValue);
return groupValue;
}
|
123
124
125
126
|
# File 'ext/chipmunk/rb_cpShape.c', line 123
static VALUE
rb_cpShapeGetLayers(VALUE self) {
return UINT2NUM(SHAPE(self)->layers);
}
|
#layers=(layers) ⇒ Object
128
129
130
131
132
133
|
# File 'ext/chipmunk/rb_cpShape.c', line 128
static VALUE
rb_cpShapeSetLayers(VALUE self, VALUE layers) {
SHAPE(self)->layers = NUM2ULONG(layers);
return layers;
}
|
#nearest_point_query(point) ⇒ Object
196
197
198
199
200
201
202
203
204
|
# File 'ext/chipmunk/rb_cpShape.c', line 196
static VALUE
rb_cpShapeNearestPointQuery(VALUE self, VALUE point) {
cpNearestPointQueryInfo info;
cpShapeNearestPointQuery(SHAPE(self), *VGET(point), &info);
if(info.shape) {
return rb_cpNearestPointQueryInfoNew((VALUE)info.shape->data, VNEW(info.p), rb_float_new(info.d));
}
return Qnil;
}
|
So we use this as the object setter
93
94
95
96
|
# File 'ext/chipmunk/rb_cpShape.c', line 93
static VALUE
rb_cpShapeGetData(VALUE self) {
return rb_iv_get(self, "data");
}
|
#object=(val) ⇒ Object
98
99
100
101
102
|
# File 'ext/chipmunk/rb_cpShape.c', line 98
static VALUE
rb_cpShapeSetData(VALUE self, VALUE val) {
rb_iv_set(self, "data", val);
return val;
}
|
#point_query(point) ⇒ Object
Test if a point lies within a shape.
190
191
192
193
194
|
# File 'ext/chipmunk/rb_cpShape.c', line 190
static VALUE
rb_cpShapePointQuery(VALUE self, VALUE point) {
cpBool res = cpShapePointQuery(SHAPE(self), *VGET(point));
return res ? Qtrue : Qfalse;
}
|
135
136
137
138
139
140
|
# File 'ext/chipmunk/rb_cpShape.c', line 135
static VALUE
rb_cpShapeGetBB(VALUE self) {
cpBB *bb = malloc(sizeof(cpBB));
*bb = SHAPE(self)->bb;
return Data_Wrap_Struct(c_cpBB, NULL, free, bb);
}
|
#remove_from_space(space) ⇒ Object
69
70
71
|
# File 'lib/chipmunk.rb', line 69
def remove_from_space(space)
space.remove_shape(self)
end
|
#segment_query(a, b) ⇒ Object
207
208
209
210
211
212
213
214
215
|
# File 'ext/chipmunk/rb_cpShape.c', line 207
static VALUE
rb_cpShapeSegmentQuery(VALUE self, VALUE a, VALUE b) {
cpSegmentQueryInfo info;
cpShapeSegmentQuery(SHAPE(self), *VGET(a), *VGET(b), &info);
if(info.shape) {
return rb_cpSegmentQueryInfoNew((VALUE)info.shape->data, rb_float_new(info.t), VNEW(info.n));
}
return Qnil;
}
|
#sensor=(sensor) ⇒ Object
64
65
66
67
68
69
|
# File 'ext/chipmunk/rb_cpShape.c', line 64
static VALUE
rb_cpShapeSetSensor(VALUE self, VALUE sensor) {
int sens = (NIL_P(sensor) || (!sensor)) ? 0 : 1;
SHAPE(self)->sensor = sens;
return sensor;
}
|
#sensor? ⇒ Boolean
59
60
61
62
|
# File 'ext/chipmunk/rb_cpShape.c', line 59
static VALUE
rb_cpShapeSensorP(VALUE self) {
return SHAPE(self)->sensor ? Qtrue : Qfalse;
}
|
#surface_v ⇒ Object
172
173
174
175
|
# File 'ext/chipmunk/rb_cpShape.c', line 172
static VALUE
rb_cpShapeGetSurfaceV(VALUE self) {
return VWRAP(self, &SHAPE(self)->surface_v);
}
|
#surface_v=(val) ⇒ Object
177
178
179
180
181
|
# File 'ext/chipmunk/rb_cpShape.c', line 177
static VALUE
rb_cpShapeSetSurfaceV(VALUE self, VALUE val) {
SHAPE(self)->surface_v = *VGET(val);
return val;
}
|
155
156
157
158
|
# File 'ext/chipmunk/rb_cpShape.c', line 155
static VALUE
rb_cpShapeGetFriction(VALUE self) {
return rb_float_new(SHAPE(self)->u);
}
|
166
167
168
169
170
|
# File 'ext/chipmunk/rb_cpShape.c', line 166
static VALUE
rb_cpShapeSetFriction(VALUE self, VALUE val) {
SHAPE(self)->u = NUM2DBL(val);
return val;
}
|