chipmunk 4.1.0-x86-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +38 -0
- data/ext/chipmunk/chipmunk.c +69 -0
- data/ext/chipmunk/chipmunk.h +91 -0
- data/ext/chipmunk/cpArbiter.c +263 -0
- data/ext/chipmunk/cpArbiter.h +85 -0
- data/ext/chipmunk/cpArray.c +114 -0
- data/ext/chipmunk/cpArray.h +45 -0
- data/ext/chipmunk/cpBB.c +46 -0
- data/ext/chipmunk/cpBB.h +53 -0
- data/ext/chipmunk/cpBody.c +180 -0
- data/ext/chipmunk/cpBody.h +132 -0
- data/ext/chipmunk/cpCollision.c +390 -0
- data/ext/chipmunk/cpCollision.h +23 -0
- data/ext/chipmunk/cpHashSet.c +219 -0
- data/ext/chipmunk/cpHashSet.h +79 -0
- data/ext/chipmunk/cpJoint.c +553 -0
- data/ext/chipmunk/cpJoint.h +122 -0
- data/ext/chipmunk/cpPolyShape.c +139 -0
- data/ext/chipmunk/cpPolyShape.h +92 -0
- data/ext/chipmunk/cpShape.c +244 -0
- data/ext/chipmunk/cpShape.h +141 -0
- data/ext/chipmunk/cpSpace.c +530 -0
- data/ext/chipmunk/cpSpace.h +120 -0
- data/ext/chipmunk/cpSpaceHash.c +455 -0
- data/ext/chipmunk/cpSpaceHash.h +100 -0
- data/ext/chipmunk/cpVect.c +63 -0
- data/ext/chipmunk/cpVect.h +106 -0
- data/ext/chipmunk/extconf.rb +4 -0
- data/ext/chipmunk/prime.h +68 -0
- data/ext/chipmunk/rb_chipmunk.c +109 -0
- data/ext/chipmunk/rb_chipmunk.h +77 -0
- data/ext/chipmunk/rb_cpBB.c +154 -0
- data/ext/chipmunk/rb_cpBody.c +239 -0
- data/ext/chipmunk/rb_cpJoint.c +136 -0
- data/ext/chipmunk/rb_cpShape.c +292 -0
- data/ext/chipmunk/rb_cpSpace.c +330 -0
- data/ext/chipmunk/rb_cpVect.c +250 -0
- data/lib/1.8/chipmunk.so +0 -0
- data/lib/1.9/chipmunk.so +0 -0
- data/lib/chipmunk.rb +15 -0
- metadata +92 -0
@@ -0,0 +1,250 @@
|
|
1
|
+
/* Copyright (c) 2007 Scott Lembcke
|
2
|
+
*
|
3
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
* of this software and associated documentation files (the "Software"), to deal
|
5
|
+
* in the Software without restriction, including without limitation the rights
|
6
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
* copies of the Software, and to permit persons to whom the Software is
|
8
|
+
* furnished to do so, subject to the following conditions:
|
9
|
+
*
|
10
|
+
* The above copyright notice and this permission notice shall be included in
|
11
|
+
* all copies or substantial portions of the Software.
|
12
|
+
*
|
13
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
* SOFTWARE.
|
20
|
+
*/
|
21
|
+
|
22
|
+
#include "chipmunk.h"
|
23
|
+
|
24
|
+
#include "ruby.h"
|
25
|
+
#include "rb_chipmunk.h"
|
26
|
+
|
27
|
+
VALUE c_cpVect;
|
28
|
+
|
29
|
+
static VALUE
|
30
|
+
rb_cpVectForAngle(VALUE self, VALUE angle)
|
31
|
+
{
|
32
|
+
return VNEW(cpvforangle(NUM2DBL(angle)));
|
33
|
+
}
|
34
|
+
|
35
|
+
static VALUE
|
36
|
+
rb_cpVectAlloc(VALUE klass)
|
37
|
+
{
|
38
|
+
cpVect *v = malloc(sizeof(cpVect));
|
39
|
+
return Data_Wrap_Struct(klass, NULL, free, v);
|
40
|
+
}
|
41
|
+
|
42
|
+
static VALUE
|
43
|
+
rb_cpVectInitialize(VALUE self, VALUE x, VALUE y)
|
44
|
+
{
|
45
|
+
cpVect *v = VGET(self);
|
46
|
+
v->x = NUM2DBL(x);
|
47
|
+
v->y = NUM2DBL(y);
|
48
|
+
|
49
|
+
return self;
|
50
|
+
}
|
51
|
+
|
52
|
+
static VALUE
|
53
|
+
rb_cpVectGetX(VALUE self)
|
54
|
+
{
|
55
|
+
return rb_float_new(VGET(self)->x);
|
56
|
+
}
|
57
|
+
|
58
|
+
static VALUE
|
59
|
+
rb_cpVectGetY(VALUE self)
|
60
|
+
{
|
61
|
+
return rb_float_new(VGET(self)->y);
|
62
|
+
}
|
63
|
+
|
64
|
+
static VALUE
|
65
|
+
rb_cpVectSetX(VALUE self, VALUE x)
|
66
|
+
{
|
67
|
+
VGET(self)->x = NUM2DBL(x);
|
68
|
+
return self;
|
69
|
+
}
|
70
|
+
|
71
|
+
static VALUE
|
72
|
+
rb_cpVectSetY(VALUE self, VALUE y)
|
73
|
+
{
|
74
|
+
VGET(self)->y = NUM2DBL(y);
|
75
|
+
return self;
|
76
|
+
}
|
77
|
+
|
78
|
+
static VALUE
|
79
|
+
rb_cpVectToString(VALUE self)
|
80
|
+
{
|
81
|
+
char str[256];
|
82
|
+
cpVect *v = VGET(self);
|
83
|
+
|
84
|
+
sprintf(str, "(% .3f, % .3f)", v->x, v->y);
|
85
|
+
|
86
|
+
return rb_str_new2(str);
|
87
|
+
}
|
88
|
+
|
89
|
+
static VALUE
|
90
|
+
rb_cpVectToArray(VALUE self)
|
91
|
+
{
|
92
|
+
cpVect *v = VGET(self);
|
93
|
+
return rb_ary_new3(2, rb_float_new(v->x), rb_float_new(v->y));
|
94
|
+
}
|
95
|
+
|
96
|
+
static VALUE
|
97
|
+
rb_cpVectToAngle(VALUE self)
|
98
|
+
{
|
99
|
+
return rb_float_new(cpvtoangle(*VGET(self)));
|
100
|
+
}
|
101
|
+
|
102
|
+
|
103
|
+
static VALUE
|
104
|
+
rb_cpVectNegate(VALUE self)
|
105
|
+
{
|
106
|
+
return VNEW(cpvneg(*VGET(self)));
|
107
|
+
}
|
108
|
+
|
109
|
+
static VALUE
|
110
|
+
rb_cpVectAdd(VALUE self, VALUE v)
|
111
|
+
{
|
112
|
+
return VNEW(cpvadd(*VGET(self), *VGET(v)));
|
113
|
+
}
|
114
|
+
|
115
|
+
static VALUE
|
116
|
+
rb_cpVectSub(VALUE self, VALUE v)
|
117
|
+
{
|
118
|
+
return VNEW(cpvsub(*VGET(self), *VGET(v)));
|
119
|
+
}
|
120
|
+
|
121
|
+
static VALUE
|
122
|
+
rb_cpVectSMult(VALUE self, VALUE s)
|
123
|
+
{
|
124
|
+
return VNEW(cpvmult(*VGET(self), NUM2DBL(s)));
|
125
|
+
}
|
126
|
+
|
127
|
+
static VALUE
|
128
|
+
rb_cpVectSDiv(VALUE self, VALUE s)
|
129
|
+
{
|
130
|
+
cpFloat factor = 1.0f/(float)NUM2DBL(s);
|
131
|
+
return VNEW(cpvmult(*VGET(self), factor));
|
132
|
+
}
|
133
|
+
|
134
|
+
static VALUE
|
135
|
+
rb_cpVectDot(VALUE self, VALUE v)
|
136
|
+
{
|
137
|
+
return rb_float_new(cpvdot(*VGET(self), *VGET(v)));
|
138
|
+
}
|
139
|
+
|
140
|
+
static VALUE
|
141
|
+
rb_cpVectCross(VALUE self, VALUE v)
|
142
|
+
{
|
143
|
+
return rb_float_new(cpvcross(*VGET(self), *VGET(v)));
|
144
|
+
}
|
145
|
+
|
146
|
+
static VALUE
|
147
|
+
rb_cpVectLength(VALUE self)
|
148
|
+
{
|
149
|
+
cpVect *v;
|
150
|
+
Data_Get_Struct(self, cpVect, v);
|
151
|
+
return rb_float_new(cpvlength(*v));
|
152
|
+
}
|
153
|
+
|
154
|
+
static VALUE
|
155
|
+
rb_cpVectLengthsq(VALUE self)
|
156
|
+
{
|
157
|
+
cpVect *v;
|
158
|
+
Data_Get_Struct(self, cpVect, v);
|
159
|
+
return rb_float_new(cpvlengthsq(*v));
|
160
|
+
}
|
161
|
+
|
162
|
+
static VALUE
|
163
|
+
rb_cpVectNorm(VALUE self)
|
164
|
+
{
|
165
|
+
return VNEW(cpvnormalize(*VGET(self)));
|
166
|
+
}
|
167
|
+
|
168
|
+
static VALUE
|
169
|
+
rb_cpVectNormBang(VALUE self)
|
170
|
+
{
|
171
|
+
cpVect *v = VGET(self);
|
172
|
+
*v = cpvnormalize(*v);
|
173
|
+
return self;
|
174
|
+
}
|
175
|
+
|
176
|
+
static VALUE
|
177
|
+
rb_cpVectPerp(VALUE self)
|
178
|
+
{
|
179
|
+
return VNEW(cpvperp(*VGET(self)));
|
180
|
+
}
|
181
|
+
|
182
|
+
static VALUE
|
183
|
+
rb_cpVectProject(VALUE self, VALUE v)
|
184
|
+
{
|
185
|
+
return VNEW(cpvproject(*VGET(self), *VGET(v)));
|
186
|
+
}
|
187
|
+
|
188
|
+
static VALUE
|
189
|
+
rb_cpVectRotate(VALUE self, VALUE v)
|
190
|
+
{
|
191
|
+
return VNEW(cpvrotate(*VGET(self), *VGET(v)));
|
192
|
+
}
|
193
|
+
|
194
|
+
static VALUE
|
195
|
+
rb_cpVectUnRotate(VALUE self, VALUE v)
|
196
|
+
{
|
197
|
+
return VNEW(cpvunrotate(*VGET(self), *VGET(v)));
|
198
|
+
}
|
199
|
+
|
200
|
+
static VALUE
|
201
|
+
rb_cpVectNear(VALUE self, VALUE v, VALUE d)
|
202
|
+
{
|
203
|
+
cpFloat dist = NUM2DBL(d);
|
204
|
+
cpVect delta = cpvsub(*VGET(self), *VGET(v));
|
205
|
+
return (cpvdot(delta, delta) <= dist*dist) ? Qtrue : Qfalse;
|
206
|
+
}
|
207
|
+
|
208
|
+
static VALUE
|
209
|
+
rb_vec2(VALUE self, VALUE x, VALUE y)
|
210
|
+
{
|
211
|
+
return VNEW(cpv(NUM2DBL(x), NUM2DBL(y)));
|
212
|
+
}
|
213
|
+
|
214
|
+
void
|
215
|
+
Init_cpVect(void)
|
216
|
+
{
|
217
|
+
c_cpVect = rb_define_class_under(m_Chipmunk, "Vec2", rb_cObject);
|
218
|
+
rb_define_singleton_method(c_cpBB, "for_angle", rb_cpVectForAngle, 1);
|
219
|
+
|
220
|
+
rb_define_alloc_func(c_cpVect, rb_cpVectAlloc);
|
221
|
+
rb_define_method(c_cpVect, "initialize", rb_cpVectInitialize, 2);
|
222
|
+
|
223
|
+
rb_define_method(c_cpVect, "x", rb_cpVectGetX, 0);
|
224
|
+
rb_define_method(c_cpVect, "y", rb_cpVectGetY, 0);
|
225
|
+
rb_define_method(c_cpVect, "x=", rb_cpVectSetX, 1);
|
226
|
+
rb_define_method(c_cpVect, "y=", rb_cpVectSetY, 1);
|
227
|
+
|
228
|
+
rb_define_method(c_cpVect, "to_s", rb_cpVectToString, 0);
|
229
|
+
rb_define_method(c_cpVect, "to_a", rb_cpVectToArray, 0);
|
230
|
+
rb_define_method(c_cpVect, "to_angle", rb_cpVectToAngle, 0);
|
231
|
+
|
232
|
+
rb_define_method(c_cpVect, "-@", rb_cpVectNegate, 0);
|
233
|
+
rb_define_method(c_cpVect, "+", rb_cpVectAdd, 1);
|
234
|
+
rb_define_method(c_cpVect, "-", rb_cpVectSub, 1);
|
235
|
+
rb_define_method(c_cpVect, "*", rb_cpVectSMult, 1);
|
236
|
+
rb_define_method(c_cpVect, "/", rb_cpVectSDiv, 1);
|
237
|
+
rb_define_method(c_cpVect, "dot", rb_cpVectDot, 1);
|
238
|
+
rb_define_method(c_cpVect, "cross", rb_cpVectCross, 1);
|
239
|
+
rb_define_method(c_cpVect, "length", rb_cpVectLength, 0);
|
240
|
+
rb_define_method(c_cpVect, "lengthsq", rb_cpVectLengthsq, 0);
|
241
|
+
rb_define_method(c_cpVect, "normalize", rb_cpVectNorm, 0);
|
242
|
+
rb_define_method(c_cpVect, "normalize!", rb_cpVectNormBang, 0);
|
243
|
+
rb_define_method(c_cpVect, "perp", rb_cpVectPerp, 0);
|
244
|
+
rb_define_method(c_cpVect, "project", rb_cpVectProject, 1);
|
245
|
+
rb_define_method(c_cpVect, "rotate", rb_cpVectRotate, 1);
|
246
|
+
rb_define_method(c_cpVect, "unrotate", rb_cpVectUnRotate, 1);
|
247
|
+
rb_define_method(c_cpVect, "near?", rb_cpVectNear, 2);
|
248
|
+
|
249
|
+
rb_define_global_function("vec2", rb_vec2, 2);
|
250
|
+
}
|
data/lib/1.8/chipmunk.so
ADDED
Binary file
|
data/lib/1.9/chipmunk.so
ADDED
Binary file
|
data/lib/chipmunk.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# this redirection script by John Mair (banisterfiend)
|
2
|
+
|
3
|
+
require 'rbconfig'
|
4
|
+
|
5
|
+
direc = File.dirname(__FILE__)
|
6
|
+
dlext = Config::CONFIG['DLEXT']
|
7
|
+
begin
|
8
|
+
if RUBY_VERSION && RUBY_VERSION =~ /1.9/
|
9
|
+
require "#{direc}/1.9/chipmunk.#{dlext}"
|
10
|
+
else
|
11
|
+
require "#{direc}/1.8/chipmunk.#{dlext}"
|
12
|
+
end
|
13
|
+
rescue LoadError => e
|
14
|
+
require "#{direc}/chipmunk.#{dlext}"
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chipmunk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 4.1.0
|
5
|
+
platform: x86-mswin32
|
6
|
+
authors:
|
7
|
+
- Scott Lembcke, Beoran, John Mair (banisterfiend)
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-01 00:00:00 +13:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: ruby bindings for the chipmunk physics engine
|
17
|
+
email: jrmair@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- Rakefile
|
26
|
+
- lib/chipmunk.rb
|
27
|
+
- ext/chipmunk/extconf.rb
|
28
|
+
- ext/chipmunk/prime.h
|
29
|
+
- ext/chipmunk/cpVect.h
|
30
|
+
- ext/chipmunk/cpJoint.h
|
31
|
+
- ext/chipmunk/cpBB.h
|
32
|
+
- ext/chipmunk/rb_chipmunk.h
|
33
|
+
- ext/chipmunk/cpBody.h
|
34
|
+
- ext/chipmunk/chipmunk.h
|
35
|
+
- ext/chipmunk/cpHashSet.h
|
36
|
+
- ext/chipmunk/cpShape.h
|
37
|
+
- ext/chipmunk/cpSpace.h
|
38
|
+
- ext/chipmunk/cpPolyShape.h
|
39
|
+
- ext/chipmunk/cpCollision.h
|
40
|
+
- ext/chipmunk/cpArray.h
|
41
|
+
- ext/chipmunk/cpSpaceHash.h
|
42
|
+
- ext/chipmunk/cpArbiter.h
|
43
|
+
- ext/chipmunk/cpBB.c
|
44
|
+
- ext/chipmunk/cpCollision.c
|
45
|
+
- ext/chipmunk/rb_cpBody.c
|
46
|
+
- ext/chipmunk/cpArbiter.c
|
47
|
+
- ext/chipmunk/cpJoint.c
|
48
|
+
- ext/chipmunk/chipmunk.c
|
49
|
+
- ext/chipmunk/cpHashSet.c
|
50
|
+
- ext/chipmunk/cpSpace.c
|
51
|
+
- ext/chipmunk/cpShape.c
|
52
|
+
- ext/chipmunk/cpBody.c
|
53
|
+
- ext/chipmunk/rb_cpBB.c
|
54
|
+
- ext/chipmunk/cpArray.c
|
55
|
+
- ext/chipmunk/rb_cpJoint.c
|
56
|
+
- ext/chipmunk/rb_cpVect.c
|
57
|
+
- ext/chipmunk/rb_cpSpace.c
|
58
|
+
- ext/chipmunk/cpSpaceHash.c
|
59
|
+
- ext/chipmunk/cpVect.c
|
60
|
+
- ext/chipmunk/rb_cpShape.c
|
61
|
+
- ext/chipmunk/rb_chipmunk.c
|
62
|
+
- ext/chipmunk/cpPolyShape.c
|
63
|
+
- lib/1.8/chipmunk.so
|
64
|
+
- lib/1.9/chipmunk.so
|
65
|
+
has_rdoc: false
|
66
|
+
homepage: http://code.google.com/p/chipmunk-physics/
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: "0"
|
77
|
+
version:
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: "0"
|
83
|
+
version:
|
84
|
+
requirements: []
|
85
|
+
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 1.2.0
|
88
|
+
signing_key:
|
89
|
+
specification_version: 2
|
90
|
+
summary: ruby bindings for the chipmunk physics engine
|
91
|
+
test_files: []
|
92
|
+
|