Add point inflation functions

This commit is contained in:
2023-03-20 01:33:05 +00:00
parent 6d69566857
commit a170d88ccc
5 changed files with 68 additions and 11 deletions

View File

@@ -100,6 +100,28 @@ void querylistbodies(cpBody *body, void *data)
}
}
int *phys2d_query_box_points(cpVect pos, cpVect wh, cpVect *points, int n)
{
cpShape *box = cpBoxShapeNew(NULL, wh.x, wh.y, 0.f);
cpTransform T = {0};
T.a = 1;
T.d = 1;
T.tx = pos.x;
T.ty = pos.y;
cpShapeUpdate(box, T);
cpBB bbox = cpShapeGetBB(box);
if (qhits) arrfree(qhits);
for (int i = 0; i < n; i++) {
if (cpBBContainsVect(bbox, points[i]))
arrpush(qhits, i);
}
return qhits;
}
int *phys2d_query_box(cpVect pos, cpVect wh)
{
cpShape *box = cpBoxShapeNew(NULL, wh.x, wh.y, 0.f);