Use List Initializations for Vectors.
This commit is contained in:
parent
5f7c1081a7
commit
6c3a0460a8
22 changed files with 326 additions and 308 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue