void _add_plane(const Vector2 &p_normal, real_t p_d) { Physics2DServer *ps = Physics2DServer::get_singleton(); Array arr; arr.push_back(p_normal); arr.push_back(p_d); RID plane = ps->line_shape_create(); ps->shape_set_data(plane, arr); RID plane_body = ps->body_create(); ps->body_set_mode(plane_body, Physics2DServer::BODY_MODE_STATIC); ps->body_set_space(plane_body, space); ps->body_add_shape(plane_body, plane); }
void _add_concave(const Vector<Vector2> &p_points, const Transform2D &p_xform = Transform2D()) { Physics2DServer *ps = Physics2DServer::get_singleton(); VisualServer *vs = VisualServer::get_singleton(); RID concave = ps->concave_polygon_shape_create(); ps->shape_set_data(concave, p_points); RID body = ps->body_create(); ps->body_set_mode(body, Physics2DServer::BODY_MODE_STATIC); ps->body_set_space(body, space); ps->body_add_shape(body, concave); ps->body_set_state(body, Physics2DServer::BODY_STATE_TRANSFORM, p_xform); RID sprite = vs->canvas_item_create(); vs->canvas_item_set_parent(sprite, canvas); vs->canvas_item_set_transform(sprite, p_xform); for (int i = 0; i < p_points.size(); i += 2) { vs->canvas_item_add_line(sprite, p_points[i], p_points[i + 1], Color(0, 0, 0), 2); } }