annotate trunk/chipmunkd/cpSpaceQuery.d @ 29:80058cee1a77

updated to chipmunk 5.3.4
author Extrawurst
date Thu, 16 Dec 2010 00:33:06 +0100
parents 4ceef5833c8c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
1
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
2 // written in the D programming language
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
3
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
4 module chipmunkd.cpSpaceQuery;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
5
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
6 import chipmunkd.chipmunk;
15
df4ebc8add66 rename/refactoring
Extrawurst
parents: 4
diff changeset
7 import chipmunkd.chipmunk_types;
4
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
8
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
9 struct pointQueryContext {
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
10 cpLayers layers;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
11 cpGroup group;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
12 cpSpacePointQueryFunc func;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
13 void *data;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
14 }
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
15
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
16 static void
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
17 pointQueryHelper(cpVect *point, cpShape *shape, pointQueryContext *context)
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
18 {
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
19 if(
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
20 !(shape.group && context.group == shape.group) && (context.layers&shape.layers) &&
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
21 cpShapePointQuery(shape, *point)
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
22 ){
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
23 context.func(shape, context.data);
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
24 }
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
25 }
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
26
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
27 void
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
28 cpSpacePointQuery(cpSpace *space, cpVect point, cpLayers layers, cpGroup group, cpSpacePointQueryFunc func, void *data)
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
29 {
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
30 pointQueryContext context = {layers, group, func, data};
23
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
31
29
80058cee1a77 updated to chipmunk 5.3.4
Extrawurst
parents: 23
diff changeset
32 cpSpaceLock(space);{
23
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
33 cpSpaceHashPointQuery(space.activeShapes, point, cast(cpSpaceHashQueryFunc)&pointQueryHelper, &context);
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
34 cpSpaceHashPointQuery(space.staticShapes, point, cast(cpSpaceHashQueryFunc)&pointQueryHelper, &context);
29
80058cee1a77 updated to chipmunk 5.3.4
Extrawurst
parents: 23
diff changeset
35 } cpSpaceUnlock(space);
4
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
36 }
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
37
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
38 static void
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
39 rememberLastPointQuery(cpShape *shape, cpShape **outShape)
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
40 {
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
41 if(!shape.sensor) *outShape = shape;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
42 }
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
43
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
44 cpShape *
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
45 cpSpacePointQueryFirst(cpSpace *space, cpVect point, cpLayers layers, cpGroup group)
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
46 {
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
47 cpShape *shape = null;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
48 cpSpacePointQuery(space, point, layers, group, cast(cpSpacePointQueryFunc)&rememberLastPointQuery, &shape);
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
49
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
50 return shape;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
51 }
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
52
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
53 //#pragma mark Segment Query Functions
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
54
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
55 struct segQueryContext {
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
56 cpVect start, end;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
57 cpLayers layers;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
58 cpGroup group;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
59 cpSpaceSegmentQueryFunc func;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
60 }
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
61
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
62 static cpFloat
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
63 segQueryFunc(segQueryContext *context, cpShape *shape, void *data)
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
64 {
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
65 cpSegmentQueryInfo info;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
66
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
67 if(
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
68 !(shape.group && context.group == shape.group) && (context.layers&shape.layers) &&
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
69 cpShapeSegmentQuery(shape, context.start, context.end, &info)
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
70 ){
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
71 context.func(shape, info.t, info.n, data);
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
72 }
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
73
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
74 return 1.0f;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
75 }
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
76
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
77 void
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
78 cpSpaceSegmentQuery(cpSpace *space, cpVect start, cpVect end, cpLayers layers, cpGroup group, cpSpaceSegmentQueryFunc func, void *data)
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
79 {
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
80 segQueryContext context = {
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
81 start, end,
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
82 layers, group,
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
83 func,
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
84 };
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
85
29
80058cee1a77 updated to chipmunk 5.3.4
Extrawurst
parents: 23
diff changeset
86 cpSpaceLock(space);{
23
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
87 cpSpaceHashSegmentQuery(space.staticShapes, &context, start, end, 1.0f, cast(cpSpaceHashSegmentQueryFunc)&segQueryFunc, data);
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
88 cpSpaceHashSegmentQuery(space.activeShapes, &context, start, end, 1.0f, cast(cpSpaceHashSegmentQueryFunc)&segQueryFunc, data);
29
80058cee1a77 updated to chipmunk 5.3.4
Extrawurst
parents: 23
diff changeset
89 } cpSpaceUnlock(space);
4
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
90 }
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
91
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
92 struct segQueryFirstContext {
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
93 cpVect start, end;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
94 cpLayers layers;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
95 cpGroup group;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
96 }
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
97
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
98 static cpFloat
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
99 segQueryFirst(segQueryFirstContext *context, cpShape *shape, cpSegmentQueryInfo *_out)
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
100 {
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
101 cpSegmentQueryInfo info;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
102
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
103 if(
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
104 !(shape.group && context.group == shape.group) &&
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
105 (context.layers&shape.layers) &&
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
106 !shape.sensor &&
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
107 cpShapeSegmentQuery(shape, context.start, context.end, &info) &&
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
108 info.t < _out.t
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
109 ){
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
110 *_out = info;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
111 }
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
112
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
113 return _out.t;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
114 }
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
115
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
116 cpShape *
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
117 cpSpaceSegmentQueryFirst(cpSpace *space, cpVect start, cpVect end, cpLayers layers, cpGroup group, cpSegmentQueryInfo *_out)
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
118 {
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
119 cpSegmentQueryInfo info = {null, 1.0f, cpvzero};
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
120 if(_out){
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
121 (*_out) = info;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
122 } else {
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
123 _out = &info;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
124 }
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
125
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
126 segQueryFirstContext context = {
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
127 start, end,
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
128 layers, group
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
129 };
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
130
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
131 cpSpaceHashSegmentQuery(space.staticShapes, &context, start, end, 1.0f, cast(cpSpaceHashSegmentQueryFunc)&segQueryFirst, _out);
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
132 cpSpaceHashSegmentQuery(space.activeShapes, &context, start, end, _out.t, cast(cpSpaceHashSegmentQueryFunc)&segQueryFirst, _out);
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
133
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
134 return _out.shape;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
135 }
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
136
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
137 //#pragma mark BB Query functions
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
138
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
139 struct bbQueryContext {
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
140 cpLayers layers;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
141 cpGroup group;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
142 cpSpaceBBQueryFunc func;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
143 void *data;
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
144 }
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
145
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
146 static void
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
147 bbQueryHelper(cpBB *bb, cpShape *shape, bbQueryContext *context)
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
148 {
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
149 if(
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
150 !(shape.group && context.group == shape.group) && (context.layers&shape.layers) &&
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
151 cpBBintersects(*bb, shape.bb)
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
152 ){
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
153 context.func(shape, context.data);
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
154 }
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
155 }
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
156
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
157 void
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
158 cpSpaceBBQuery(cpSpace *space, cpBB bb, cpLayers layers, cpGroup group, cpSpaceBBQueryFunc func, void *data)
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
159 {
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
160 bbQueryContext context = {layers, group, func, data};
23
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
161
29
80058cee1a77 updated to chipmunk 5.3.4
Extrawurst
parents: 23
diff changeset
162 cpSpaceLock(space);{
4
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
163 cpSpaceHashQuery(space.activeShapes, &bb, bb, cast(cpSpaceHashQueryFunc)&bbQueryHelper, &context);
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
164 cpSpaceHashQuery(space.staticShapes, &bb, bb, cast(cpSpaceHashQueryFunc)&bbQueryHelper, &context);
29
80058cee1a77 updated to chipmunk 5.3.4
Extrawurst
parents: 23
diff changeset
165 } cpSpaceUnlock(space);
4
7ebbd4d05553 initial commit
Extrawurst
parents:
diff changeset
166 }
23
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
167
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
168 //#pragma mark Shape Query Functions
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
169
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
170 struct shapeQueryContext {
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
171 cpSpaceShapeQueryFunc func;
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
172 void *data;
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
173 cpBool anyCollision;
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
174 }
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
175
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
176 // Callback from the spatial hash.
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
177 static void
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
178 shapeQueryHelper(cpShape *a, cpShape *b, shapeQueryContext *context)
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
179 {
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
180 // Reject any of the simple cases
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
181 if(
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
182 (a.group && a.group == b.group) ||
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
183 !(a.layers & b.layers) ||
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
184 a.sensor || b.sensor
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
185 ) return;
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
186
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
187 cpContact contacts[CP_MAX_CONTACTS_PER_ARBITER];
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
188 int numContacts = 0;
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
189
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
190 // Shape 'a' should have the lower shape type. (required by cpCollideShapes() )
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
191 if(a.klass.type <= b.klass.type){
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
192 numContacts = cpCollideShapes(a, b, contacts.ptr);
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
193 } else {
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
194 numContacts = cpCollideShapes(b, a, contacts.ptr);
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
195 for(int i=0; i<numContacts; i++) contacts[i].n = cpvneg(contacts[i].n);
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
196 }
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
197
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
198 if(numContacts){
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
199 context.anyCollision = cpTrue;
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
200
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
201 if(context.func){
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
202 cpContactPointSet set; set.count = numContacts;
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
203 for(int i=0; i<set.count; i++){
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
204 set.points[i].point = contacts[i].p;
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
205 set.points[i].normal = contacts[i].p;
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
206 set.points[i].dist = contacts[i].dist;
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
207 }
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
208
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
209 context.func(b, &set, context.data);
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
210 }
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
211 }
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
212 }
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
213
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
214 cpBool
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
215 cpSpaceShapeQuery(cpSpace *space, cpShape *shape, cpSpaceShapeQueryFunc func, void *data)
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
216 {
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
217 cpBB bb = cpShapeCacheBB(shape);
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
218 shapeQueryContext context = {func, data, cpFalse};
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
219
29
80058cee1a77 updated to chipmunk 5.3.4
Extrawurst
parents: 23
diff changeset
220 cpSpaceLock(space);{
23
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
221 cpSpaceHashQuery(space.activeShapes, shape, bb, cast(cpSpaceHashQueryFunc)&shapeQueryHelper, &context);
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
222 cpSpaceHashQuery(space.staticShapes, shape, bb, cast(cpSpaceHashQueryFunc)&shapeQueryHelper, &context);
29
80058cee1a77 updated to chipmunk 5.3.4
Extrawurst
parents: 23
diff changeset
223 } cpSpaceUnlock(space);
23
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
224
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
225 return context.anyCollision;
4ceef5833c8c updated to chipmunk 5.3.3
Extrawurst
parents: 15
diff changeset
226 }