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 /core | |
parent | e664d195cbaa5ebc7a9926a8afc432296ff08588 (diff) | |
parent | 6c3a0460a803b3dbe89a4172c49f38fc4b95a299 (diff) |
Merge pull request #56696 from AnilBK/use-init-lists
Diffstat (limited to 'core')
-rw-r--r-- | core/core_bind.cpp | 10 | ||||
-rw-r--r-- | core/math/a_star.cpp | 3 | ||||
-rw-r--r-- | core/math/geometry_3d.cpp | 29 |
3 files changed, 18 insertions, 24 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 1891ea7e3a..ef28f43f05 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -698,10 +698,7 @@ Variant Geometry2D::line_intersects_line(const Vector2 &p_from_a, const Vector2 Vector<Vector2> Geometry2D::get_closest_points_between_segments(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2) { Vector2 r1, r2; ::Geometry2D::get_closest_points_between_segments(p1, q1, p2, q2, r1, r2); - Vector<Vector2> r; - r.resize(2); - r.set(0, r1); - r.set(1, r2); + Vector<Vector2> r = { r1, r2 }; return r; } @@ -923,10 +920,7 @@ Vector<Plane> Geometry3D::build_capsule_planes(float p_radius, float p_height, i Vector<Vector3> Geometry3D::get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2) { Vector3 r1, r2; ::Geometry3D::get_closest_points_between_segments(p1, p2, q1, q2, r1, r2); - Vector<Vector3> r; - r.resize(2); - r.set(0, r1); - r.set(1, r2); + Vector<Vector3> r = { r1, r2 }; return r; } diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index ebe88fcf66..ce2435216b 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -699,8 +699,7 @@ Vector<Vector2> AStar2D::get_point_path(int p_from_id, int p_to_id) { ERR_FAIL_COND_V_MSG(!to_exists, Vector<Vector2>(), vformat("Can't get point path. Point with id: %d doesn't exist.", p_to_id)); if (a == b) { - Vector<Vector2> ret; - ret.push_back(Vector2(a->pos.x, a->pos.y)); + Vector<Vector2> ret = { Vector2(a->pos.x, a->pos.y) }; return ret; } diff --git a/core/math/geometry_3d.cpp b/core/math/geometry_3d.cpp index e1bce81b6b..98a2c27d93 100644 --- a/core/math/geometry_3d.cpp +++ b/core/math/geometry_3d.cpp @@ -644,14 +644,15 @@ Geometry3D::MeshData Geometry3D::build_convex_mesh(const Vector<Plane> &p_planes Vector3 right = p.normal.cross(ref).normalized(); Vector3 up = p.normal.cross(right).normalized(); - Vector<Vector3> vertices; - Vector3 center = p.center(); + // make a quad clockwise - vertices.push_back(center - up * subplane_size + right * subplane_size); - vertices.push_back(center - up * subplane_size - right * subplane_size); - vertices.push_back(center + up * subplane_size - right * subplane_size); - vertices.push_back(center + up * subplane_size + right * subplane_size); + Vector<Vector3> vertices = { + center - up * subplane_size + right * subplane_size, + center - up * subplane_size - right * subplane_size, + center + up * subplane_size - right * subplane_size, + center + up * subplane_size + right * subplane_size + }; for (int j = 0; j < p_planes.size(); j++) { if (j == i) { @@ -762,14 +763,14 @@ Geometry3D::MeshData Geometry3D::build_convex_mesh(const Vector<Plane> &p_planes } Vector<Plane> Geometry3D::build_box_planes(const Vector3 &p_extents) { - Vector<Plane> planes; - - planes.push_back(Plane(Vector3(1, 0, 0), p_extents.x)); - planes.push_back(Plane(Vector3(-1, 0, 0), p_extents.x)); - planes.push_back(Plane(Vector3(0, 1, 0), p_extents.y)); - planes.push_back(Plane(Vector3(0, -1, 0), p_extents.y)); - planes.push_back(Plane(Vector3(0, 0, 1), p_extents.z)); - planes.push_back(Plane(Vector3(0, 0, -1), p_extents.z)); + Vector<Plane> planes = { + Plane(Vector3(1, 0, 0), p_extents.x), + Plane(Vector3(-1, 0, 0), p_extents.x), + Plane(Vector3(0, 1, 0), p_extents.y), + Plane(Vector3(0, -1, 0), p_extents.y), + Plane(Vector3(0, 0, 1), p_extents.z), + Plane(Vector3(0, 0, -1), p_extents.z) + }; return planes; } |