chipmunk 5.3.4.0-x86-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ /* Copyright (c) 2007 Scott Lembcke
2
+ * Copyright (c) 2010-2011 John Mair
3
+ * Copyright (c) 2010-2011 Beoran (beoran@rubyforge.org)
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in
13
+ * all copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ * SOFTWARE.
22
+ */
data/README ADDED
@@ -0,0 +1,70 @@
1
+ Ruby Bindings to Chipmunk Physics Version 5.3.4
2
+
3
+ (C) Scott Lembcke, Beoran and John Mair (banisterfiend)
4
+
5
+ IMPORTANT NOTICE:
6
+ These are bindings for MRI Ruby 1.8.x and 1.9.x to Chipmunk version 5.3.4
7
+
8
+ (1) 1/10/09 Cross-Platform Gem built by John Mair (banisterfiend)
9
+ * Just go: gem install chipmunk
10
+
11
+ FORUM:
12
+ http://www.slembcke.net/forums
13
+
14
+ CONTACT:
15
+ slembcke@gmail.com (also on Google Talk) for Chipmunk.
16
+ beoran@rubyforge.org for these bindings to Ruby.
17
+
18
+ ABOUT CHIPMUNK:
19
+ Chipmunk is a simple, lightweight and fast 2D rigid body physics library
20
+ written in C by Slembcke. It's licensed under the unrestrictive, OSI approved
21
+ MIT license.
22
+
23
+ ABOUT THESE RUBY BINDINGS:
24
+ Although chipmunk comes with ruby bindings, they are not always up to date
25
+ with regards to the functionality of the C library, and historically, they
26
+ have been incompatible with recent versions of Ruby.
27
+
28
+ Therefore, these bindings are intended to as an enhanced version with more
29
+ features and better compatibility with recent versions of Ruby. They are also
30
+ intended to be an alternative to the chipmunk-ffi bindings when performance
31
+ is of the utmost importance, as it may be for games.
32
+
33
+ The intent is for these bindings to be mostly source code compatible with both
34
+ Slembcke's and ffi's bindings. Main exceptions are where I dislike either API.
35
+ In that case, I made an API that is pleasing to myself, and similar in naming
36
+ to the C API adjusted to ruby conventions. If you have any problems with these bindings, please contact the maintainer at beoran@rubyforge.org.
37
+
38
+ DOCUMENTATION:
39
+ http://beoran.github.com/chipmunk/
40
+
41
+ INCOMPATIBILITIES:
42
+ There are no bindings to SpaceHash since I fail to see the use of it, but
43
+ if someone is using them, I'll probably implement them.
44
+
45
+ CONTRACTING:
46
+ Howling Moon Software (Slembke's company) is available for contracting if you
47
+ want to make the physics in your game really stand out. Feel free to contact
48
+ them through their webpage: http://howlingmoonsoftware.com/contracting.php
49
+
50
+ TODO:
51
+ * More functionality.
52
+ * Specs for the new functionality I've wrapped and will wrap.
53
+ * Better documentation, perhaps based on C API documentation.
54
+
55
+
56
+ INFO FOR MAINTAINERS:
57
+
58
+ (1) 1/10/09 Cross-Platform Gem built by John Mair (banisterfiend)
59
+ * Just go: gem install chipmunk
60
+
61
+ (2) Patched for 1.9.1 by Beoran (beoran@rubyforge.org)
62
+
63
+ (3) How to build the gems? (maintainers only)
64
+ * Install rake-compiler (http://github.com/luislavena/rake-compiler)
65
+ * Install 1.9.1 and 1.8.6 mingw ruby versions (instructions above)
66
+ * Type: rake cross native gem RUBY_CC_VERSION=1.8.6:1.9.1
67
+ * Upload new gems to rubyforge and gemcutter.
68
+
69
+
70
+
@@ -0,0 +1,86 @@
1
+ # Rakefile added by John Mair (banisterfiend)
2
+
3
+ require 'rake/gempackagetask'
4
+ require 'rake/clean'
5
+
6
+ begin
7
+ require 'rake/extensiontask'
8
+ rescue LoadError
9
+ puts "rake-compiler not found! Please install the rake-compiler gem!"
10
+ # `/bin/bash -l -c "gem1.9 install rake-compiler"`
11
+ # require 'rake/extensiontask'
12
+ # puts "...done!"
13
+ end
14
+
15
+ CHIPMUNK_VERSION = "5.3.4.0"
16
+
17
+ dlext = Config::CONFIG['DLEXT']
18
+
19
+ CLEAN.include("ext/**/*.#{dlext}", "ext/**/.log", "ext/**/.o", "ext/**/*~", "ext/**/*#*", "ext/**/.obj", "ext/**/.def", "ext/**/.pdb")
20
+ CLOBBER.include("**/*.#{dlext}", "**/*~", "**/*#*", "**/*.log", "**/*.o", "doc/**")
21
+
22
+
23
+ def apply_spec_defaults(s)
24
+ s.name = "chipmunk"
25
+ s.summary = "Enhanced ruby bindings for the chipmunk 5.3.4 game physics engine."
26
+ s.description = s.summary + " "
27
+ s.version = CHIPMUNK_VERSION
28
+ s.author = "Scott Lembcke, Beoran, John Mair (banisterfiend)"
29
+ s.email = 'beoran@rubyforge.org'
30
+ s.date = Time.now.strftime '%Y-%m-%d'
31
+ s.require_path = 'lib'
32
+ s.homepage = "https://github.com/beoran/chipmunk"
33
+ end
34
+
35
+
36
+ # common tasks
37
+ task :compile => :clean
38
+
39
+ # platform dependent tasks
40
+ if RUBY_PLATFORM =~ /darwin/
41
+
42
+ spec = Gem::Specification.new do |s|
43
+ apply_spec_defaults(s)
44
+ s.platform = Gem::Platform::CURRENT
45
+ s.files = ["Rakefile", "README", "LICENSE", "lib/chipmunk.rb", "lib/1.8/chipmunk.#{dlext}", "lib/1.9/chipmunk.#{dlext}"]
46
+ end
47
+
48
+ Rake::ExtensionTask.new('chipmunk') do |ext|
49
+ ext.ext_dir = "ext"
50
+ ext.lib_dir = "lib/#{RUBY_VERSION[0..2]}"
51
+ ext.config_script = 'extconf.rb'
52
+ ext.config_options << 'macosx'
53
+ end
54
+
55
+ task :compile_multi => :clean do
56
+ `/bin/bash -l -c "rvm 1.8.6,1.9.1 rake compile"`
57
+ end
58
+
59
+ task :gem => :compile_multi
60
+ Rake::GemPackageTask.new(spec) do |pkg|
61
+ pkg.need_zip = false
62
+ pkg.need_tar = false
63
+ end
64
+
65
+ else
66
+
67
+ spec = Gem::Specification.new do |s|
68
+ apply_spec_defaults(s)
69
+ s.platform = Gem::Platform::RUBY
70
+ s.extensions = FileList["ext/**/extconf.rb"]
71
+ s.files = ["Rakefile", "README", "LICENSE", "lib/chipmunk.rb"] +
72
+ FileList["ext/**/extconf.rb", "ext/**/*.h", "ext/**/*.c"].to_a
73
+ end
74
+
75
+ Rake::ExtensionTask.new('chipmunk', spec) do |ext|
76
+ ext.config_script = 'extconf.rb'
77
+ ext.cross_compile = true
78
+ ext.cross_platform = 'i586-mingw32'
79
+ # ext.cross_platform = 'i386-mswin32'
80
+ end
81
+
82
+ Rake::GemPackageTask.new(spec) do |pkg|
83
+ pkg.need_zip = false
84
+ pkg.need_tar = false
85
+ end
86
+ end
@@ -0,0 +1,42 @@
1
+ require 'mkmf'
2
+
3
+ RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
4
+
5
+ dir_config('chipmunk')
6
+
7
+ MINGW = '/usr/i586-mingw32msvc'
8
+ CHIPMUNK_HEADER = 'chipmunk.h'
9
+ CHIPMUNK_NAME = 'chipmunk'
10
+ CHIPMUNK_FUNCTION = 'cpMomentForPoly'
11
+ CHIPMUNK_INCLUDE = ['/usr/include',
12
+ File.join(MINGW, 'include'),
13
+ File.join(MINGW, 'include', 'chipmunk'),
14
+ '/usr/local/include',
15
+ '/usr/include/chipmunk',
16
+ '/usr/local/include/chipmunk'
17
+ ]
18
+ CHIPMUNK_LIBDIR = ['/usr/lib',
19
+ File.join(MINGW, 'lib'),
20
+ '/usr/local/lib']
21
+
22
+ unless find_header(CHIPMUNK_HEADER, *CHIPMUNK_INCLUDE)
23
+ raise "Could not find Chipmunk headers!"
24
+ end
25
+
26
+
27
+ unless find_library(CHIPMUNK_NAME, CHIPMUNK_FUNCTION, *CHIPMUNK_LIBDIR)
28
+ raise "Could not link to Chipmunk library!"
29
+ end
30
+
31
+ =begin
32
+ have_header('chipmunk.h', include_dirs)
33
+ =end
34
+
35
+ if ARGV[0] == "macosx"
36
+ $CFLAGS += ' -arch ppc -arch i386 -arch x86_64'
37
+ $LDFLAGS += ' -arch x86_64 -arch i386 -arch ppc'
38
+ end
39
+
40
+ $CFLAGS += ' -std=gnu99 -ffast-math'
41
+ create_makefile('chipmunk')
42
+
@@ -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 <stdlib.h>
23
+
24
+ #include "chipmunk.h"
25
+
26
+ #include "ruby.h"
27
+ #include "rb_chipmunk.h"
28
+
29
+ VALUE m_Chipmunk;
30
+
31
+ ID id_parent;
32
+
33
+ static VALUE
34
+ rb_get_cp_bias_coef(VALUE self) {
35
+ return rb_float_new(cp_bias_coef);
36
+ }
37
+
38
+ static VALUE
39
+ rb_set_cp_bias_coef(VALUE self, VALUE num) {
40
+ cp_bias_coef = NUM2DBL(num);
41
+ return num;
42
+ }
43
+
44
+ static VALUE
45
+ rb_get_cp_collision_slop(VALUE self) {
46
+ return rb_float_new(cp_collision_slop);
47
+ }
48
+
49
+ static VALUE
50
+ rb_set_cp_collision_slop(VALUE self, VALUE num) {
51
+ cp_collision_slop = NUM2DBL(num);
52
+ return num;
53
+ }
54
+
55
+ static VALUE
56
+ rb_set_cp_contact_persistence(VALUE self, VALUE num) {
57
+ cp_contact_persistence = NUM2DBL(num);
58
+ return num;
59
+ }
60
+
61
+ static VALUE
62
+ rb_get_cp_contact_persistence(VALUE self) {
63
+ return rb_float_new(cp_contact_persistence);
64
+ }
65
+
66
+
67
+ static VALUE
68
+ rb_cpMomentForCircle(VALUE self, VALUE m, VALUE r1, VALUE r2, VALUE offset)
69
+ {
70
+ cpFloat i = cpMomentForCircle(NUM2DBL(m), NUM2DBL(r1), NUM2DBL(r2), *VGET(offset));
71
+ return rb_float_new(i);
72
+ }
73
+
74
+ static VALUE
75
+ rb_cpMomentForSegment(VALUE self, VALUE m, VALUE v1, VALUE v2)
76
+ {
77
+ cpFloat i = cpMomentForSegment(NUM2DBL(m), *VGET(v1), *VGET(v2));
78
+ return rb_float_new(i);
79
+ }
80
+
81
+ static VALUE
82
+ rb_cpMomentForPoly(VALUE self, VALUE m, VALUE arr, VALUE offset)
83
+ {
84
+ Check_Type(arr, T_ARRAY);
85
+ int numVerts = RARRAY_LEN(arr);
86
+ VALUE *ary_ptr = RARRAY_PTR(arr);
87
+ cpVect verts[numVerts];
88
+
89
+ for(int i=0; i<numVerts; i++)
90
+ verts[i] = *VGET(ary_ptr[i]);
91
+
92
+ cpFloat inertia = cpMomentForPoly(NUM2DBL(m), numVerts, verts, *VGET(offset));
93
+ return rb_float_new(inertia);
94
+ }
95
+
96
+ static VALUE
97
+ rb_cpMomentForBox(VALUE self, VALUE m, VALUE w, VALUE h) {
98
+ cpFloat i = cpMomentForBox(NUM2DBL(m), NUM2DBL(w), NUM2DBL(h));
99
+ return rb_float_new(i);
100
+ }
101
+
102
+ static VALUE
103
+ rb_cpAreaForCircle(VALUE self, VALUE r1, VALUE r2)
104
+ {
105
+ cpFloat i = cpAreaForCircle(NUM2DBL(r1), NUM2DBL(r2));
106
+ return rb_float_new(i);
107
+ }
108
+
109
+ static VALUE
110
+ rb_cpAreaForSegment(VALUE self, VALUE v1, VALUE v2, VALUE r)
111
+ {
112
+ cpFloat i = cpAreaForSegment(*VGET(v1), *VGET(v2), NUM2DBL(r));
113
+ return rb_float_new(i);
114
+ }
115
+
116
+ static VALUE
117
+ rb_cpAreaForPoly(VALUE self, VALUE arr)
118
+ {
119
+ Check_Type(arr, T_ARRAY);
120
+ int numVerts = RARRAY_LEN(arr);
121
+ VALUE *ary_ptr = RARRAY_PTR(arr);
122
+ cpVect verts[numVerts];
123
+
124
+ for(int i=0; i<numVerts; i++)
125
+ verts[i] = *VGET(ary_ptr[i]);
126
+
127
+ cpFloat area = cpAreaForPoly(numVerts, verts);
128
+ return rb_float_new(area);
129
+ }
130
+
131
+ static VALUE
132
+ rb_cpAreaForBox(VALUE self, VALUE w, VALUE h) {
133
+ cpFloat i = NUM2DBL(w) * NUM2DBL(h);
134
+ return rb_float_new(i);
135
+ }
136
+
137
+
138
+ static VALUE rb_cpfclamp(VALUE self, VALUE f, VALUE min, VALUE max) {
139
+ cpFloat result = cpfclamp(NUM2DBL(f), NUM2DBL(min), NUM2DBL(max));
140
+ return rb_float_new(result);
141
+ }
142
+
143
+ static VALUE rb_cpflerp(VALUE self, VALUE f1, VALUE f2, VALUE t) {
144
+ cpFloat result = cpflerp(NUM2DBL(f1), NUM2DBL(f2), NUM2DBL(t));
145
+ return rb_float_new(result);
146
+ }
147
+
148
+ static VALUE rb_cpflerpconst(VALUE self, VALUE f1, VALUE f2, VALUE d) {
149
+ cpFloat result = cpflerpconst(NUM2DBL(f1), NUM2DBL(f2), NUM2DBL(d));
150
+ return rb_float_new(result);
151
+ }
152
+
153
+ static VALUE
154
+ rb_cpCentroidForPoly(VALUE self, VALUE arr)
155
+ {
156
+ Check_Type(arr, T_ARRAY);
157
+ int numVerts = RARRAY_LEN(arr);
158
+ VALUE *ary_ptr = RARRAY_PTR(arr);
159
+ cpVect verts[numVerts];
160
+
161
+ for(int i=0; i<numVerts; i++)
162
+ verts[i] = *VGET(ary_ptr[i]);
163
+
164
+ return VNEW(cpCentroidForPoly(numVerts, verts));
165
+ }
166
+
167
+ static VALUE
168
+ rb_cpRecenterPoly(VALUE self, VALUE arr)
169
+ {
170
+ Check_Type(arr, T_ARRAY);
171
+ int numVerts = RARRAY_LEN(arr);
172
+ VALUE *ary_ptr = RARRAY_PTR(arr);
173
+ cpVect verts[numVerts];
174
+
175
+ for(int i=0; i<numVerts; i++)
176
+ verts[i] = *VGET(ary_ptr[i]);
177
+
178
+ cpRecenterPoly(numVerts, verts);
179
+
180
+ for(int i=0; i<numVerts; i++)
181
+ ary_ptr[i] = VNEW(verts[i]);
182
+ return arr;
183
+ }
184
+
185
+
186
+
187
+
188
+ void
189
+ Init_chipmunk(void)
190
+ {
191
+ id_parent = rb_intern("parent");
192
+
193
+ cpInitChipmunk();
194
+
195
+
196
+
197
+ m_Chipmunk = rb_define_module("CP");
198
+ rb_define_module_function(m_Chipmunk, "bias_coef", rb_get_cp_bias_coef, 0);
199
+ rb_define_module_function(m_Chipmunk, "bias_coef=", rb_set_cp_bias_coef, 1);
200
+ rb_define_module_function(m_Chipmunk, "collision_slop", rb_get_cp_collision_slop, 0);
201
+ rb_define_module_function(m_Chipmunk, "collision_slop=", rb_set_cp_collision_slop, 1);
202
+ rb_define_module_function(m_Chipmunk, "contact_persistence", rb_get_cp_contact_persistence, 0);
203
+ rb_define_module_function(m_Chipmunk, "contact_persistence=", rb_set_cp_contact_persistence, 1);
204
+
205
+
206
+
207
+ rb_define_module_function(m_Chipmunk, "clamp", rb_cpfclamp, 3);
208
+ rb_define_module_function(m_Chipmunk, "flerp", rb_cpflerp, 3);
209
+ rb_define_module_function(m_Chipmunk, "flerpconst", rb_cpflerpconst, 3);
210
+
211
+ rb_define_module_function(m_Chipmunk, "moment_for_circle", rb_cpMomentForCircle, 4);
212
+ rb_define_module_function(m_Chipmunk, "moment_for_poly", rb_cpMomentForPoly, 3);
213
+ rb_define_module_function(m_Chipmunk, "moment_for_segment", rb_cpMomentForSegment, 3);
214
+ rb_define_module_function(m_Chipmunk, "moment_for_box", rb_cpMomentForBox, 3);
215
+
216
+ rb_define_module_function(m_Chipmunk, "circle_moment", rb_cpMomentForCircle, 4);
217
+ rb_define_module_function(m_Chipmunk, "poly_moment", rb_cpMomentForPoly, 3);
218
+ rb_define_module_function(m_Chipmunk, "segment_moment", rb_cpMomentForSegment, 3);
219
+ rb_define_module_function(m_Chipmunk, "box_moment", rb_cpMomentForBox, 3);
220
+
221
+
222
+ rb_define_module_function(m_Chipmunk, "area_for_circle", rb_cpAreaForCircle, 2);
223
+ rb_define_module_function(m_Chipmunk, "area_for_poly", rb_cpAreaForPoly, 1);
224
+ rb_define_module_function(m_Chipmunk, "centroid_for_poly",
225
+ rb_cpCentroidForPoly, 1);
226
+ rb_define_module_function(m_Chipmunk, "recenter_poly",
227
+ rb_cpRecenterPoly, 1);
228
+
229
+ rb_define_module_function(m_Chipmunk, "area_for_segment", rb_cpAreaForSegment, 3);
230
+ rb_define_module_function(m_Chipmunk, "area_for_box", rb_cpAreaForBox, 2);
231
+
232
+ rb_define_module_function(m_Chipmunk, "circle_area", rb_cpAreaForCircle, 2);
233
+ rb_define_module_function(m_Chipmunk, "poly_area", rb_cpAreaForPoly, 1);
234
+ rb_define_module_function(m_Chipmunk, "segment_area", rb_cpAreaForSegment, 3);
235
+ rb_define_module_function(m_Chipmunk, "box_area", rb_cpAreaForBox, 2);
236
+
237
+ rb_define_const(m_Chipmunk, "ALL_LAYERS", UINT2NUM((unsigned int)CP_ALL_LAYERS));
238
+ rb_define_const(m_Chipmunk, "NO_GROUP" , UINT2NUM(CP_NO_GROUP));
239
+
240
+ rb_eval_string("Float::INFINITY = 1.0/0.0 unless Float.const_defined? :INFINITY");
241
+ rb_eval_string("CP::INFINITY = 1.0/0.0 unless CP.const_defined? :INFINITY");
242
+
243
+ Init_cpVect();
244
+ Init_cpBB();
245
+ Init_cpBody();
246
+ Init_cpShape();
247
+ Init_cpConstraint();
248
+ Init_cpSpace();
249
+ Init_cpArbiter();
250
+ }