chipmunk 5.2.2 → 5.3.4.0
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 +21 -19
- data/README +67 -60
- data/Rakefile +85 -50
- data/ext/chipmunk/extconf.rb +42 -35
- data/ext/chipmunk/rb_chipmunk.c +250 -125
- data/ext/chipmunk/rb_chipmunk.h +105 -96
- data/ext/chipmunk/rb_cpArbiter.c +253 -225
- data/ext/chipmunk/rb_cpBB.c +210 -174
- data/ext/chipmunk/rb_cpBody.c +504 -347
- data/ext/chipmunk/rb_cpConstraint.c +336 -346
- data/ext/chipmunk/rb_cpShape.c +433 -455
- data/ext/chipmunk/rb_cpSpace.c +711 -544
- data/ext/chipmunk/rb_cpVect.c +346 -321
- data/lib/chipmunk.rb +183 -30
- metadata +12 -66
- data/ext/chipmunk/chipmunk.c +0 -105
- data/ext/chipmunk/cpArbiter.c +0 -274
- data/ext/chipmunk/cpArray.c +0 -128
- data/ext/chipmunk/cpBB.c +0 -47
- data/ext/chipmunk/cpBody.c +0 -188
- data/ext/chipmunk/cpCollision.c +0 -391
- data/ext/chipmunk/cpConstraint.c +0 -54
- data/ext/chipmunk/cpDampedRotarySpring.c +0 -106
- data/ext/chipmunk/cpDampedSpring.c +0 -117
- data/ext/chipmunk/cpGearJoint.c +0 -114
- data/ext/chipmunk/cpGrooveJoint.c +0 -138
- data/ext/chipmunk/cpHashSet.c +0 -253
- data/ext/chipmunk/cpPinJoint.c +0 -117
- data/ext/chipmunk/cpPivotJoint.c +0 -114
- data/ext/chipmunk/cpPolyShape.c +0 -241
- data/ext/chipmunk/cpRatchetJoint.c +0 -128
- data/ext/chipmunk/cpRotaryLimitJoint.c +0 -122
- data/ext/chipmunk/cpShape.c +0 -400
- data/ext/chipmunk/cpSimpleMotor.c +0 -99
- data/ext/chipmunk/cpSlideJoint.c +0 -131
- data/ext/chipmunk/cpSpace.c +0 -899
- data/ext/chipmunk/cpSpaceHash.c +0 -541
- data/ext/chipmunk/cpVect.c +0 -71
- data/ext/chipmunk/include/chipmunk/chipmunk.h +0 -148
- data/ext/chipmunk/include/chipmunk/chipmunk_ffi.h +0 -42
- data/ext/chipmunk/include/chipmunk/chipmunk_types.h +0 -80
- data/ext/chipmunk/include/chipmunk/chipmunk_unsafe.h +0 -54
- data/ext/chipmunk/include/chipmunk/constraints/cpConstraint.h +0 -92
- data/ext/chipmunk/include/chipmunk/constraints/cpDampedRotarySpring.h +0 -46
- data/ext/chipmunk/include/chipmunk/constraints/cpDampedSpring.h +0 -53
- data/ext/chipmunk/include/chipmunk/constraints/cpGearJoint.h +0 -41
- data/ext/chipmunk/include/chipmunk/constraints/cpGrooveJoint.h +0 -44
- data/ext/chipmunk/include/chipmunk/constraints/cpPinJoint.h +0 -43
- data/ext/chipmunk/include/chipmunk/constraints/cpPivotJoint.h +0 -42
- data/ext/chipmunk/include/chipmunk/constraints/cpRatchetJoint.h +0 -40
- data/ext/chipmunk/include/chipmunk/constraints/cpRotaryLimitJoint.h +0 -39
- data/ext/chipmunk/include/chipmunk/constraints/cpSimpleMotor.h +0 -37
- data/ext/chipmunk/include/chipmunk/constraints/cpSlideJoint.h +0 -44
- data/ext/chipmunk/include/chipmunk/constraints/util.h +0 -116
- data/ext/chipmunk/include/chipmunk/cpArbiter.h +0 -136
- data/ext/chipmunk/include/chipmunk/cpArray.h +0 -46
- data/ext/chipmunk/include/chipmunk/cpBB.h +0 -74
- data/ext/chipmunk/include/chipmunk/cpBody.h +0 -160
- data/ext/chipmunk/include/chipmunk/cpCollision.h +0 -23
- data/ext/chipmunk/include/chipmunk/cpHashSet.h +0 -82
- data/ext/chipmunk/include/chipmunk/cpPolyShape.h +0 -103
- data/ext/chipmunk/include/chipmunk/cpShape.h +0 -174
- data/ext/chipmunk/include/chipmunk/cpSpace.h +0 -180
- data/ext/chipmunk/include/chipmunk/cpSpaceHash.h +0 -109
- data/ext/chipmunk/include/chipmunk/cpVect.h +0 -157
- data/ext/chipmunk/prime.h +0 -68
- data/lib/chipmunk/version.rb +0 -3
@@ -1,109 +0,0 @@
|
|
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
|
-
// The spatial hash is Chipmunk's default (and currently only) spatial index type.
|
23
|
-
// Based on a chained hash table.
|
24
|
-
|
25
|
-
// Used internally to track objects added to the hash
|
26
|
-
typedef struct cpHandle{
|
27
|
-
// Pointer to the object
|
28
|
-
void *obj;
|
29
|
-
// Retain count
|
30
|
-
int retain;
|
31
|
-
// Query stamp. Used to make sure two objects
|
32
|
-
// aren't identified twice in the same query.
|
33
|
-
int stamp;
|
34
|
-
} cpHandle;
|
35
|
-
|
36
|
-
// Linked list element for in the chains.
|
37
|
-
typedef struct cpSpaceHashBin{
|
38
|
-
cpHandle *handle;
|
39
|
-
struct cpSpaceHashBin *next;
|
40
|
-
} cpSpaceHashBin;
|
41
|
-
|
42
|
-
// BBox callback. Called whenever the hash needs a bounding box from an object.
|
43
|
-
typedef cpBB (*cpSpaceHashBBFunc)(void *obj);
|
44
|
-
|
45
|
-
typedef struct cpSpaceHash{
|
46
|
-
// Number of cells in the table.
|
47
|
-
int numcells;
|
48
|
-
// Dimentions of the cells.
|
49
|
-
cpFloat celldim;
|
50
|
-
|
51
|
-
// BBox callback.
|
52
|
-
cpSpaceHashBBFunc bbfunc;
|
53
|
-
|
54
|
-
// Hashset of the handles and the recycled ones.
|
55
|
-
cpHashSet *handleSet;
|
56
|
-
cpArray *pooledHandles;
|
57
|
-
|
58
|
-
// The table and the recycled bins.
|
59
|
-
cpSpaceHashBin **table, *pooledBins;
|
60
|
-
|
61
|
-
// list of buffers to free on destruction.
|
62
|
-
cpArray *allocatedBuffers;
|
63
|
-
|
64
|
-
// Incremented on each query. See cpHandle.stamp.
|
65
|
-
int stamp;
|
66
|
-
} cpSpaceHash;
|
67
|
-
|
68
|
-
//Basic allocation/destruction functions.
|
69
|
-
cpSpaceHash *cpSpaceHashAlloc(void);
|
70
|
-
cpSpaceHash *cpSpaceHashInit(cpSpaceHash *hash, cpFloat celldim, int cells, cpSpaceHashBBFunc bbfunc);
|
71
|
-
cpSpaceHash *cpSpaceHashNew(cpFloat celldim, int cells, cpSpaceHashBBFunc bbfunc);
|
72
|
-
|
73
|
-
void cpSpaceHashDestroy(cpSpaceHash *hash);
|
74
|
-
void cpSpaceHashFree(cpSpaceHash *hash);
|
75
|
-
|
76
|
-
// Resize the hashtable. (Does not rehash! You must call cpSpaceHashRehash() if needed.)
|
77
|
-
void cpSpaceHashResize(cpSpaceHash *hash, cpFloat celldim, int numcells);
|
78
|
-
|
79
|
-
// Add an object to the hash.
|
80
|
-
void cpSpaceHashInsert(cpSpaceHash *hash, void *obj, cpHashValue id, cpBB bb);
|
81
|
-
// Remove an object from the hash.
|
82
|
-
void cpSpaceHashRemove(cpSpaceHash *hash, void *obj, cpHashValue id);
|
83
|
-
|
84
|
-
// Iterator function
|
85
|
-
typedef void (*cpSpaceHashIterator)(void *obj, void *data);
|
86
|
-
// Iterate over the objects in the hash.
|
87
|
-
void cpSpaceHashEach(cpSpaceHash *hash, cpSpaceHashIterator func, void *data);
|
88
|
-
|
89
|
-
// Rehash the contents of the hash.
|
90
|
-
void cpSpaceHashRehash(cpSpaceHash *hash);
|
91
|
-
// Rehash only a specific object.
|
92
|
-
void cpSpaceHashRehashObject(cpSpaceHash *hash, void *obj, cpHashValue id);
|
93
|
-
|
94
|
-
// Query callback.
|
95
|
-
typedef void (*cpSpaceHashQueryFunc)(void *obj1, void *obj2, void *data);
|
96
|
-
// Point query the hash. A reference to the query point is passed as obj1 to the query callback.
|
97
|
-
void cpSpaceHashPointQuery(cpSpaceHash *hash, cpVect point, cpSpaceHashQueryFunc func, void *data);
|
98
|
-
// Query the hash for a given BBox.
|
99
|
-
void cpSpaceHashQuery(cpSpaceHash *hash, void *obj, cpBB bb, cpSpaceHashQueryFunc func, void *data);
|
100
|
-
// Run a query for the object, then insert it. (Optimized case)
|
101
|
-
void cpSpaceHashQueryInsert(cpSpaceHash *hash, void *obj, cpBB bb, cpSpaceHashQueryFunc func, void *data);
|
102
|
-
// Rehashes while querying for each object. (Optimized case)
|
103
|
-
void cpSpaceHashQueryRehash(cpSpaceHash *hash, cpSpaceHashQueryFunc func, void *data);
|
104
|
-
|
105
|
-
// Segment Query callback.
|
106
|
-
// Return value is uesd for early exits of the query.
|
107
|
-
// If while traversing the grid, the raytrace function detects that an entire grid cell is beyond the hit point, it will stop the trace.
|
108
|
-
typedef cpFloat (*cpSpaceHashSegmentQueryFunc)(void *obj1, void *obj2, void *data);
|
109
|
-
void cpSpaceHashSegmentQuery(cpSpaceHash *hash, void *obj, cpVect a, cpVect b, cpFloat t_exit, cpSpaceHashSegmentQueryFunc func, void *data);
|
@@ -1,157 +0,0 @@
|
|
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
|
-
static const cpVect cpvzero={0.0f,0.0f};
|
23
|
-
|
24
|
-
static inline cpVect
|
25
|
-
cpv(const cpFloat x, const cpFloat y)
|
26
|
-
{
|
27
|
-
cpVect v = {x, y};
|
28
|
-
return v;
|
29
|
-
}
|
30
|
-
|
31
|
-
// non-inlined functions
|
32
|
-
cpFloat cpvlength(const cpVect v);
|
33
|
-
cpVect cpvslerp(const cpVect v1, const cpVect v2, const cpFloat t);
|
34
|
-
cpVect cpvslerpconst(const cpVect v1, const cpVect v2, const cpFloat a);
|
35
|
-
cpVect cpvforangle(const cpFloat a); // convert radians to a normalized vector
|
36
|
-
cpFloat cpvtoangle(const cpVect v); // convert a vector to radians
|
37
|
-
char *cpvstr(const cpVect v); // get a string representation of a vector
|
38
|
-
|
39
|
-
static inline cpVect
|
40
|
-
cpvadd(const cpVect v1, const cpVect v2)
|
41
|
-
{
|
42
|
-
return cpv(v1.x + v2.x, v1.y + v2.y);
|
43
|
-
}
|
44
|
-
|
45
|
-
static inline cpVect
|
46
|
-
cpvneg(const cpVect v)
|
47
|
-
{
|
48
|
-
return cpv(-v.x, -v.y);
|
49
|
-
}
|
50
|
-
|
51
|
-
static inline cpVect
|
52
|
-
cpvsub(const cpVect v1, const cpVect v2)
|
53
|
-
{
|
54
|
-
return cpv(v1.x - v2.x, v1.y - v2.y);
|
55
|
-
}
|
56
|
-
|
57
|
-
static inline cpVect
|
58
|
-
cpvmult(const cpVect v, const cpFloat s)
|
59
|
-
{
|
60
|
-
return cpv(v.x*s, v.y*s);
|
61
|
-
}
|
62
|
-
|
63
|
-
static inline cpFloat
|
64
|
-
cpvdot(const cpVect v1, const cpVect v2)
|
65
|
-
{
|
66
|
-
return v1.x*v2.x + v1.y*v2.y;
|
67
|
-
}
|
68
|
-
|
69
|
-
static inline cpFloat
|
70
|
-
cpvcross(const cpVect v1, const cpVect v2)
|
71
|
-
{
|
72
|
-
return v1.x*v2.y - v1.y*v2.x;
|
73
|
-
}
|
74
|
-
|
75
|
-
static inline cpVect
|
76
|
-
cpvperp(const cpVect v)
|
77
|
-
{
|
78
|
-
return cpv(-v.y, v.x);
|
79
|
-
}
|
80
|
-
|
81
|
-
static inline cpVect
|
82
|
-
cpvrperp(const cpVect v)
|
83
|
-
{
|
84
|
-
return cpv(v.y, -v.x);
|
85
|
-
}
|
86
|
-
|
87
|
-
static inline cpVect
|
88
|
-
cpvproject(const cpVect v1, const cpVect v2)
|
89
|
-
{
|
90
|
-
return cpvmult(v2, cpvdot(v1, v2)/cpvdot(v2, v2));
|
91
|
-
}
|
92
|
-
|
93
|
-
static inline cpVect
|
94
|
-
cpvrotate(const cpVect v1, const cpVect v2)
|
95
|
-
{
|
96
|
-
return cpv(v1.x*v2.x - v1.y*v2.y, v1.x*v2.y + v1.y*v2.x);
|
97
|
-
}
|
98
|
-
|
99
|
-
static inline cpVect
|
100
|
-
cpvunrotate(const cpVect v1, const cpVect v2)
|
101
|
-
{
|
102
|
-
return cpv(v1.x*v2.x + v1.y*v2.y, v1.y*v2.x - v1.x*v2.y);
|
103
|
-
}
|
104
|
-
|
105
|
-
static inline cpFloat
|
106
|
-
cpvlengthsq(const cpVect v)
|
107
|
-
{
|
108
|
-
return cpvdot(v, v);
|
109
|
-
}
|
110
|
-
|
111
|
-
static inline cpVect
|
112
|
-
cpvlerp(const cpVect v1, const cpVect v2, const cpFloat t)
|
113
|
-
{
|
114
|
-
return cpvadd(cpvmult(v1, 1.0f - t), cpvmult(v2, t));
|
115
|
-
}
|
116
|
-
|
117
|
-
static inline cpVect
|
118
|
-
cpvnormalize(const cpVect v)
|
119
|
-
{
|
120
|
-
return cpvmult(v, 1.0f/cpvlength(v));
|
121
|
-
}
|
122
|
-
|
123
|
-
static inline cpVect
|
124
|
-
cpvnormalize_safe(const cpVect v)
|
125
|
-
{
|
126
|
-
return (v.x == 0.0f && v.y == 0.0f ? cpvzero : cpvnormalize(v));
|
127
|
-
}
|
128
|
-
|
129
|
-
static inline cpVect
|
130
|
-
cpvclamp(const cpVect v, const cpFloat len)
|
131
|
-
{
|
132
|
-
return (cpvdot(v,v) > len*len) ? cpvmult(cpvnormalize(v), len) : v;
|
133
|
-
}
|
134
|
-
|
135
|
-
static inline cpVect
|
136
|
-
cpvlerpconst(cpVect v1, cpVect v2, cpFloat d)
|
137
|
-
{
|
138
|
-
return cpvadd(v1, cpvclamp(cpvsub(v2, v1), d));
|
139
|
-
}
|
140
|
-
|
141
|
-
static inline cpFloat
|
142
|
-
cpvdist(const cpVect v1, const cpVect v2)
|
143
|
-
{
|
144
|
-
return cpvlength(cpvsub(v1, v2));
|
145
|
-
}
|
146
|
-
|
147
|
-
static inline cpFloat
|
148
|
-
cpvdistsq(const cpVect v1, const cpVect v2)
|
149
|
-
{
|
150
|
-
return cpvlengthsq(cpvsub(v1, v2));
|
151
|
-
}
|
152
|
-
|
153
|
-
static inline int
|
154
|
-
cpvnear(const cpVect v1, const cpVect v2, const cpFloat dist)
|
155
|
-
{
|
156
|
-
return cpvdistsq(v1, v2) < dist*dist;
|
157
|
-
}
|
data/ext/chipmunk/prime.h
DELETED
@@ -1,68 +0,0 @@
|
|
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
|
-
// Used for resizing hash tables.
|
23
|
-
// Values approximately double.
|
24
|
-
// http://planetmath.org/encyclopedia/GoodHashTablePrimes.html
|
25
|
-
static int primes[] = {
|
26
|
-
5,
|
27
|
-
13,
|
28
|
-
23,
|
29
|
-
47,
|
30
|
-
97,
|
31
|
-
193,
|
32
|
-
389,
|
33
|
-
769,
|
34
|
-
1543,
|
35
|
-
3079,
|
36
|
-
6151,
|
37
|
-
12289,
|
38
|
-
24593,
|
39
|
-
49157,
|
40
|
-
98317,
|
41
|
-
196613,
|
42
|
-
393241,
|
43
|
-
786433,
|
44
|
-
1572869,
|
45
|
-
3145739,
|
46
|
-
6291469,
|
47
|
-
12582917,
|
48
|
-
25165843,
|
49
|
-
50331653,
|
50
|
-
100663319,
|
51
|
-
201326611,
|
52
|
-
402653189,
|
53
|
-
805306457,
|
54
|
-
1610612741,
|
55
|
-
0,
|
56
|
-
};
|
57
|
-
|
58
|
-
static inline int
|
59
|
-
next_prime(int n)
|
60
|
-
{
|
61
|
-
int i = 0;
|
62
|
-
while(n > primes[i]){
|
63
|
-
i++;
|
64
|
-
cpAssert(primes[i], "Tried to resize a hash table to a size greater than 1610612741 O_o"); // realistically this should never happen
|
65
|
-
}
|
66
|
-
|
67
|
-
return primes[i];
|
68
|
-
}
|
data/lib/chipmunk/version.rb
DELETED