diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-01-12 10:04:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-12 10:04:45 +0100 |
commit | 189662e5bdd5347ed9f8c2a4711bddd7037c5362 (patch) | |
tree | c076f1d5132092185f6bc12e03d88d86a9a52200 /scene/resources | |
parent | e664d195cbaa5ebc7a9926a8afc432296ff08588 (diff) | |
parent | 6c3a0460a803b3dbe89a4172c49f38fc4b95a299 (diff) |
Merge pull request #56696 from AnilBK/use-init-lists
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/separation_ray_shape_2d.cpp | 16 | ||||
-rw-r--r-- | scene/resources/separation_ray_shape_3d.cpp | 7 | ||||
-rw-r--r-- | scene/resources/style_box.cpp | 23 | ||||
-rw-r--r-- | scene/resources/tile_set.cpp | 94 | ||||
-rw-r--r-- | scene/resources/world_boundary_shape_3d.cpp | 23 |
5 files changed, 85 insertions, 78 deletions
diff --git a/scene/resources/separation_ray_shape_2d.cpp b/scene/resources/separation_ray_shape_2d.cpp index 5ac8d0a475..0406c91b70 100644 --- a/scene/resources/separation_ray_shape_2d.cpp +++ b/scene/resources/separation_ray_shape_2d.cpp @@ -59,15 +59,13 @@ void SeparationRayShape2D::draw(const RID &p_to_rid, const Color &p_color) { xf.rotate(target_position.angle()); xf.translate(Vector2(no_line ? 0 : target_position.length() - arrow_size, 0)); - Vector<Vector2> pts; - pts.push_back(xf.xform(Vector2(arrow_size, 0))); - pts.push_back(xf.xform(Vector2(0, 0.5 * arrow_size))); - pts.push_back(xf.xform(Vector2(0, -0.5 * arrow_size))); - - Vector<Color> cols; - for (int i = 0; i < 3; i++) { - cols.push_back(p_color); - } + Vector<Vector2> pts = { + xf.xform(Vector2(arrow_size, 0)), + xf.xform(Vector2(0, 0.5 * arrow_size)), + xf.xform(Vector2(0, -0.5 * arrow_size)) + }; + + Vector<Color> cols = { p_color, p_color, p_color }; RS::get_singleton()->canvas_item_add_primitive(p_to_rid, pts, cols, Vector<Point2>(), RID()); } diff --git a/scene/resources/separation_ray_shape_3d.cpp b/scene/resources/separation_ray_shape_3d.cpp index a059d55bbe..5aa7616589 100644 --- a/scene/resources/separation_ray_shape_3d.cpp +++ b/scene/resources/separation_ray_shape_3d.cpp @@ -33,9 +33,10 @@ #include "servers/physics_server_3d.h" Vector<Vector3> SeparationRayShape3D::get_debug_mesh_lines() const { - Vector<Vector3> points; - points.push_back(Vector3()); - points.push_back(Vector3(0, 0, get_length())); + Vector<Vector3> points = { + Vector3(), + Vector3(0, 0, get_length()) + }; return points; } diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp index c39902739f..5afd424e03 100644 --- a/scene/resources/style_box.cpp +++ b/scene/resources/style_box.cpp @@ -521,21 +521,22 @@ inline void draw_ring(Vector<Vector2> &verts, Vector<int> &indices, Vector<Color set_inner_corner_radius(style_rect, ring_rect, corner_radius, ring_corner_radius); // Corner radius center points. - Vector<Point2> outer_points; - outer_points.push_back(ring_rect.position + Vector2(ring_corner_radius[0], ring_corner_radius[0])); //tl - outer_points.push_back(Point2(ring_rect.position.x + ring_rect.size.x - ring_corner_radius[1], ring_rect.position.y + ring_corner_radius[1])); //tr - outer_points.push_back(ring_rect.position + ring_rect.size - Vector2(ring_corner_radius[2], ring_corner_radius[2])); //br - outer_points.push_back(Point2(ring_rect.position.x + ring_corner_radius[3], ring_rect.position.y + ring_rect.size.y - ring_corner_radius[3])); //bl + Vector<Point2> outer_points = { + ring_rect.position + Vector2(ring_corner_radius[0], ring_corner_radius[0]), //tl + Point2(ring_rect.position.x + ring_rect.size.x - ring_corner_radius[1], ring_rect.position.y + ring_corner_radius[1]), //tr + ring_rect.position + ring_rect.size - Vector2(ring_corner_radius[2], ring_corner_radius[2]), //br + Point2(ring_rect.position.x + ring_corner_radius[3], ring_rect.position.y + ring_rect.size.y - ring_corner_radius[3]) //bl + }; real_t inner_corner_radius[4]; set_inner_corner_radius(style_rect, inner_rect, corner_radius, inner_corner_radius); - Vector<Point2> inner_points; - inner_points.push_back(inner_rect.position + Vector2(inner_corner_radius[0], inner_corner_radius[0])); //tl - inner_points.push_back(Point2(inner_rect.position.x + inner_rect.size.x - inner_corner_radius[1], inner_rect.position.y + inner_corner_radius[1])); //tr - inner_points.push_back(inner_rect.position + inner_rect.size - Vector2(inner_corner_radius[2], inner_corner_radius[2])); //br - inner_points.push_back(Point2(inner_rect.position.x + inner_corner_radius[3], inner_rect.position.y + inner_rect.size.y - inner_corner_radius[3])); //bl - + Vector<Point2> inner_points = { + inner_rect.position + Vector2(inner_corner_radius[0], inner_corner_radius[0]), //tl + Point2(inner_rect.position.x + inner_rect.size.x - inner_corner_radius[1], inner_rect.position.y + inner_corner_radius[1]), //tr + inner_rect.position + inner_rect.size - Vector2(inner_corner_radius[2], inner_corner_radius[2]), //br + Point2(inner_rect.position.x + inner_corner_radius[3], inner_rect.position.y + inner_rect.size.y - inner_corner_radius[3]) //bl + }; // Calculate the vertices. for (int corner_index = 0; corner_index < 4; corner_index++) { for (int detail = 0; detail <= adapted_corner_detail; detail++) { diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index 44a7af75b9..ddb9cc7440 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -1765,11 +1765,14 @@ Vector<Point2> TileSet::_get_square_corner_or_side_terrain_bit_polygon(Vector2i break; } bit_rect.position *= Vector2(p_size) / 6.0; - Vector<Vector2> polygon; - polygon.push_back(bit_rect.position); - polygon.push_back(Vector2(bit_rect.get_end().x, bit_rect.position.y)); - polygon.push_back(bit_rect.get_end()); - polygon.push_back(Vector2(bit_rect.position.x, bit_rect.get_end().y)); + + Vector<Vector2> polygon = { + bit_rect.position, + Vector2(bit_rect.get_end().x, bit_rect.position.y), + bit_rect.get_end(), + Vector2(bit_rect.position.x, bit_rect.get_end().y) + }; + return polygon; } @@ -1984,25 +1987,26 @@ Vector<Point2> TileSet::_get_isometric_side_terrain_bit_polygon(Vector2i p_size, } Vector<Point2> TileSet::_get_half_offset_corner_or_side_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit, float p_overlap, TileSet::TileOffsetAxis p_offset_axis) { - Vector<Vector2> point_list; - point_list.push_back(Vector2(3, (3.0 * (1.0 - p_overlap * 2.0)) / 2.0)); - point_list.push_back(Vector2(3, 3.0 * (1.0 - p_overlap * 2.0))); - point_list.push_back(Vector2(2, 3.0 * (1.0 - (p_overlap * 2.0) * 2.0 / 3.0))); - point_list.push_back(Vector2(1, 3.0 - p_overlap * 2.0)); - point_list.push_back(Vector2(0, 3)); - point_list.push_back(Vector2(-1, 3.0 - p_overlap * 2.0)); - point_list.push_back(Vector2(-2, 3.0 * (1.0 - (p_overlap * 2.0) * 2.0 / 3.0))); - point_list.push_back(Vector2(-3, 3.0 * (1.0 - p_overlap * 2.0))); - point_list.push_back(Vector2(-3, (3.0 * (1.0 - p_overlap * 2.0)) / 2.0)); - point_list.push_back(Vector2(-3, -(3.0 * (1.0 - p_overlap * 2.0)) / 2.0)); - point_list.push_back(Vector2(-3, -3.0 * (1.0 - p_overlap * 2.0))); - point_list.push_back(Vector2(-2, -3.0 * (1.0 - (p_overlap * 2.0) * 2.0 / 3.0))); - point_list.push_back(Vector2(-1, -(3.0 - p_overlap * 2.0))); - point_list.push_back(Vector2(0, -3)); - point_list.push_back(Vector2(1, -(3.0 - p_overlap * 2.0))); - point_list.push_back(Vector2(2, -3.0 * (1.0 - (p_overlap * 2.0) * 2.0 / 3.0))); - point_list.push_back(Vector2(3, -3.0 * (1.0 - p_overlap * 2.0))); - point_list.push_back(Vector2(3, -(3.0 * (1.0 - p_overlap * 2.0)) / 2.0)); + Vector<Vector2> point_list = { + Vector2(3, (3.0 * (1.0 - p_overlap * 2.0)) / 2.0), + Vector2(3, 3.0 * (1.0 - p_overlap * 2.0)), + Vector2(2, 3.0 * (1.0 - (p_overlap * 2.0) * 2.0 / 3.0)), + Vector2(1, 3.0 - p_overlap * 2.0), + Vector2(0, 3), + Vector2(-1, 3.0 - p_overlap * 2.0), + Vector2(-2, 3.0 * (1.0 - (p_overlap * 2.0) * 2.0 / 3.0)), + Vector2(-3, 3.0 * (1.0 - p_overlap * 2.0)), + Vector2(-3, (3.0 * (1.0 - p_overlap * 2.0)) / 2.0), + Vector2(-3, -(3.0 * (1.0 - p_overlap * 2.0)) / 2.0), + Vector2(-3, -3.0 * (1.0 - p_overlap * 2.0)), + Vector2(-2, -3.0 * (1.0 - (p_overlap * 2.0) * 2.0 / 3.0)), + Vector2(-1, -(3.0 - p_overlap * 2.0)), + Vector2(0, -3), + Vector2(1, -(3.0 - p_overlap * 2.0)), + Vector2(2, -3.0 * (1.0 - (p_overlap * 2.0) * 2.0 / 3.0)), + Vector2(3, -3.0 * (1.0 - p_overlap * 2.0)), + Vector2(3, -(3.0 * (1.0 - p_overlap * 2.0)) / 2.0) + }; Vector2 unit = Vector2(p_size) / 6.0; for (int i = 0; i < point_list.size(); i++) { @@ -2144,19 +2148,20 @@ Vector<Point2> TileSet::_get_half_offset_corner_or_side_terrain_bit_polygon(Vect } Vector<Point2> TileSet::_get_half_offset_corner_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit, float p_overlap, TileSet::TileOffsetAxis p_offset_axis) { - Vector<Vector2> point_list; - point_list.push_back(Vector2(3, 0)); - point_list.push_back(Vector2(3, 3.0 * (1.0 - p_overlap * 2.0))); - point_list.push_back(Vector2(1.5, (3.0 * (1.0 - p_overlap * 2.0) + 3.0) / 2.0)); - point_list.push_back(Vector2(0, 3)); - point_list.push_back(Vector2(-1.5, (3.0 * (1.0 - p_overlap * 2.0) + 3.0) / 2.0)); - point_list.push_back(Vector2(-3, 3.0 * (1.0 - p_overlap * 2.0))); - point_list.push_back(Vector2(-3, 0)); - point_list.push_back(Vector2(-3, -3.0 * (1.0 - p_overlap * 2.0))); - point_list.push_back(Vector2(-1.5, -(3.0 * (1.0 - p_overlap * 2.0) + 3.0) / 2.0)); - point_list.push_back(Vector2(0, -3)); - point_list.push_back(Vector2(1.5, -(3.0 * (1.0 - p_overlap * 2.0) + 3.0) / 2.0)); - point_list.push_back(Vector2(3, -3.0 * (1.0 - p_overlap * 2.0))); + Vector<Vector2> point_list = { + Vector2(3, 0), + Vector2(3, 3.0 * (1.0 - p_overlap * 2.0)), + Vector2(1.5, (3.0 * (1.0 - p_overlap * 2.0) + 3.0) / 2.0), + Vector2(0, 3), + Vector2(-1.5, (3.0 * (1.0 - p_overlap * 2.0) + 3.0) / 2.0), + Vector2(-3, 3.0 * (1.0 - p_overlap * 2.0)), + Vector2(-3, 0), + Vector2(-3, -3.0 * (1.0 - p_overlap * 2.0)), + Vector2(-1.5, -(3.0 * (1.0 - p_overlap * 2.0) + 3.0) / 2.0), + Vector2(0, -3), + Vector2(1.5, -(3.0 * (1.0 - p_overlap * 2.0) + 3.0) / 2.0), + Vector2(3, -3.0 * (1.0 - p_overlap * 2.0)) + }; Vector2 unit = Vector2(p_size) / 6.0; for (int i = 0; i < point_list.size(); i++) { @@ -2250,13 +2255,14 @@ Vector<Point2> TileSet::_get_half_offset_corner_terrain_bit_polygon(Vector2i p_s } Vector<Point2> TileSet::_get_half_offset_side_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit, float p_overlap, TileSet::TileOffsetAxis p_offset_axis) { - Vector<Vector2> point_list; - point_list.push_back(Vector2(3, 3.0 * (1.0 - p_overlap * 2.0))); - point_list.push_back(Vector2(0, 3)); - point_list.push_back(Vector2(-3, 3.0 * (1.0 - p_overlap * 2.0))); - point_list.push_back(Vector2(-3, -3.0 * (1.0 - p_overlap * 2.0))); - point_list.push_back(Vector2(0, -3)); - point_list.push_back(Vector2(3, -3.0 * (1.0 - p_overlap * 2.0))); + Vector<Vector2> point_list = { + Vector2(3, 3.0 * (1.0 - p_overlap * 2.0)), + Vector2(0, 3), + Vector2(-3, 3.0 * (1.0 - p_overlap * 2.0)), + Vector2(-3, -3.0 * (1.0 - p_overlap * 2.0)), + Vector2(0, -3), + Vector2(3, -3.0 * (1.0 - p_overlap * 2.0)) + }; Vector2 unit = Vector2(p_size) / 6.0; for (int i = 0; i < point_list.size(); i++) { diff --git a/scene/resources/world_boundary_shape_3d.cpp b/scene/resources/world_boundary_shape_3d.cpp index efa288511d..09d41e8291 100644 --- a/scene/resources/world_boundary_shape_3d.cpp +++ b/scene/resources/world_boundary_shape_3d.cpp @@ -34,7 +34,6 @@ Vector<Vector3> WorldBoundaryShape3D::get_debug_mesh_lines() const { Plane p = get_plane(); - Vector<Vector3> points; Vector3 n1 = p.get_any_perpendicular_normal(); Vector3 n2 = p.normal.cross(n1).normalized(); @@ -46,16 +45,18 @@ Vector<Vector3> WorldBoundaryShape3D::get_debug_mesh_lines() const { p.normal * p.d + n1 * -10.0 + n2 * 10.0, }; - points.push_back(pface[0]); - points.push_back(pface[1]); - points.push_back(pface[1]); - points.push_back(pface[2]); - points.push_back(pface[2]); - points.push_back(pface[3]); - points.push_back(pface[3]); - points.push_back(pface[0]); - points.push_back(p.normal * p.d); - points.push_back(p.normal * p.d + p.normal * 3); + Vector<Vector3> points = { + pface[0], + pface[1], + pface[1], + pface[2], + pface[2], + pface[3], + pface[3], + pface[0], + p.normal * p.d, + p.normal * p.d + p.normal * 3 + }; return points; } |