MCPcopy Create free account
hub / github.com/axmolengine/axmol / cpSpacePointQueryNearest

Function cpSpacePointQueryNearest

3rdparty/chipmunk/src/cpSpaceQuery.c:75–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75cpShape *
76cpSpacePointQueryNearest(cpSpace *space, cpVect point, cpFloat maxDistance, cpShapeFilter filter, cpPointQueryInfo *out)
77{
78 cpPointQueryInfo info = {NULL, cpvzero, maxDistance, cpvzero};
79 if(out){
80 (*out) = info;
81 } else {
82 out = &info;
83 }
84
85 struct PointQueryContext context = {
86 point, maxDistance,
87 filter,
88 NULL
89 };
90
91 cpBB bb = cpBBNewForCircle(point, cpfmax(maxDistance, 0.0f));
92 cpSpatialIndexQuery(space->dynamicShapes, &context, bb, (cpSpatialIndexQueryFunc)NearestPointQueryNearest, out);
93 cpSpatialIndexQuery(space->staticShapes, &context, bb, (cpSpatialIndexQueryFunc)NearestPointQueryNearest, out);
94
95 return (cpShape *)out->shape;
96}
97
98
99//MARK: Segment Query Functions

Callers 5

getShapeMethod · 0.85
onMouseDownMethod · 0.85
updateFunction · 0.85
updateFunction · 0.85
updateFunction · 0.85

Calls 3

cpBBNewForCircleFunction · 0.85
cpfmaxFunction · 0.85
cpSpatialIndexQueryFunction · 0.85

Tested by 1

onMouseDownMethod · 0.68