Nuke fixes

This commit is contained in:
John Alanbrook 2023-03-13 14:27:32 +00:00
parent 3018a1a188
commit 35a00c96ee
5 changed files with 27 additions and 1 deletions

View file

@ -122,6 +122,15 @@ int *phys2d_query_box(cpVect pos, cpVect wh)
return qhits;
}
int *phys2d_query_shape(struct phys2d_shape *shape)
{
if (qhits) arrfree(qhits);
cpSpaceShapeQuery(space, shape->shape, querylist, NULL);
return qhits;
}
int cpshape_enabled(cpShape *c)
{
cpShapeFilter filter = cpShapeGetFilter(c);
@ -728,5 +737,4 @@ void phys2d_add_handler_type(int cmd, int go, struct callee c) {
//go->cbs->separate = cb;
break;
}
}

View file

@ -139,6 +139,7 @@ struct color float2color(float *fcolor);
void shape_gui(struct phys2d_shape *shape);
void phys2d_setup_handlers(int go);
int *phys2d_query_shape(struct phys2d_shape *shape);
void phys2d_reindex_body(cpBody *body);
cpVect world2go(struct gameobject *go, cpVect worldpos);

View file

@ -236,6 +236,14 @@ void draw_box(struct cpVect c, struct cpVect wh, struct color color)
draw_rect(c.x, c.y, wh.x, wh.y, col);
}
void draw_arrow(struct cpVect start, struct cpVect end, struct color color)
{
float col[3] = {(float)color.r/255, (float)color.g/255, (float)color.b/255};
draw_line(start.x, start.y, end.x, end.y, col);
draw_cppoint(end, 5, color);
}
void draw_grid(int width, int span)
{
shader_use(gridShader);

View file

@ -8,6 +8,7 @@ void debugdraw_init();
void draw_line(int x1, int y1, int x2, int y2, float *color);
void draw_edge(struct cpVect *points, int n, float *color, int thickness);
void draw_points(struct cpVect *points, int n, float size, float *color);
void draw_arrow(struct cpVect start, struct cpVect end, struct color);
void draw_circle(int x, int y, float radius, int pixels, float *color, int fill);
void draw_grid(int width, int span);
void draw_rect(int x, int y, int w, int h, float *color);

View file

@ -834,6 +834,14 @@ duk_ret_t duk_cmd(duk_context *duk) {
case 79:
duk_push_boolean(duk, phys_stepping());
return 1;
case 80:
ints2duk(phys2d_query_shape(duk_get_pointer(duk,1)));
return 1;
case 81:
draw_arrow(duk2vec2(duk,1), duk2vec2(duk,2), duk2color(duk,3));
return 0;
}
return 0;