Use List Initializations for Vectors.

This commit is contained in:
Anilforextra 2022-01-11 21:12:39 +05:45
parent 5f7c1081a7
commit 6c3a0460a8
22 changed files with 326 additions and 308 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -145,20 +145,19 @@ void AnimationTrackEditColor::draw_key_link(int p_index, float p_pixels_sec, int
}
for (int i = 0; i < color_samples.size() - 1; i++) {
Vector<Vector2> points;
Vector<Color> colors;
Vector<Vector2> points = {
Vector2(Math::lerp(x_from, x_to, float(i) / (color_samples.size() - 1)), y_from),
Vector2(Math::lerp(x_from, x_to, float(i + 1) / (color_samples.size() - 1)), y_from),
Vector2(Math::lerp(x_from, x_to, float(i + 1) / (color_samples.size() - 1)), y_from + fh),
Vector2(Math::lerp(x_from, x_to, float(i) / (color_samples.size() - 1)), y_from + fh)
};
points.push_back(Vector2(Math::lerp(x_from, x_to, float(i) / (color_samples.size() - 1)), y_from));
colors.push_back(color_samples[i]);
points.push_back(Vector2(Math::lerp(x_from, x_to, float(i + 1) / (color_samples.size() - 1)), y_from));
colors.push_back(color_samples[i + 1]);
points.push_back(Vector2(Math::lerp(x_from, x_to, float(i + 1) / (color_samples.size() - 1)), y_from + fh));
colors.push_back(color_samples[i + 1]);
points.push_back(Vector2(Math::lerp(x_from, x_to, float(i) / (color_samples.size() - 1)), y_from + fh));
colors.push_back(color_samples[i]);
Vector<Color> colors = {
color_samples[i],
color_samples[i + 1],
color_samples[i + 1],
color_samples[i]
};
draw_primitive(points, colors, Vector<Vector2>());
}

View File

@ -488,10 +488,11 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
color.a *= 0.2;
}
Vector<Color> colors;
colors.push_back(color);
colors.push_back(color);
colors.push_back(color);
Vector<Color> colors = {
color,
color,
color
};
blend_space_draw->draw_primitive(points, colors, Vector<Vector2>());
}

View File

@ -3381,10 +3381,11 @@ void CanvasItemEditor::_draw_selection() {
Size2 move_factor = Size2(MOVE_HANDLE_DISTANCE, MOVE_HANDLE_DISTANCE);
viewport->draw_set_transform_matrix(simple_xform);
Vector<Point2> points;
points.push_back(Vector2(move_factor.x * EDSCALE, 5 * EDSCALE));
points.push_back(Vector2(move_factor.x * EDSCALE, -5 * EDSCALE));
points.push_back(Vector2((move_factor.x + 10) * EDSCALE, 0));
Vector<Point2> points = {
Vector2(move_factor.x * EDSCALE, 5 * EDSCALE),
Vector2(move_factor.x * EDSCALE, -5 * EDSCALE),
Vector2((move_factor.x + 10) * EDSCALE, 0)
};
viewport->draw_colored_polygon(points, get_theme_color(SNAME("axis_x_color"), SNAME("Editor")));
viewport->draw_line(Point2(), Point2(move_factor.x * EDSCALE, 0), get_theme_color(SNAME("axis_x_color"), SNAME("Editor")), Math::round(EDSCALE));
@ -5823,11 +5824,12 @@ void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String &
editor_data->get_undo_redo().add_do_property(child, "rect_size", texture_size);
} else if (node_class == "Polygon2D") {
Size2 texture_size = texture->get_size();
Vector<Vector2> list;
list.push_back(Vector2(0, 0));
list.push_back(Vector2(texture_size.width, 0));
list.push_back(Vector2(texture_size.width, texture_size.height));
list.push_back(Vector2(0, texture_size.height));
Vector<Vector2> list = {
Vector2(0, 0),
Vector2(texture_size.width, 0),
Vector2(texture_size.width, texture_size.height),
Vector2(0, texture_size.height)
};
editor_data->get_undo_redo().add_do_property(child, "polygon", list);
}

View File

@ -324,37 +324,34 @@ void EditorNode3DGizmo::add_unscaled_billboard(const Ref<Material> &p_material,
ERR_FAIL_COND(!spatial_node);
Instance ins;
Vector<Vector3> vs;
Vector<Vector2> uv;
Vector<Color> colors;
Vector<Vector3> vs = {
Vector3(-p_scale, p_scale, 0),
Vector3(p_scale, p_scale, 0),
Vector3(p_scale, -p_scale, 0),
Vector3(-p_scale, -p_scale, 0)
};
vs.push_back(Vector3(-p_scale, p_scale, 0));
vs.push_back(Vector3(p_scale, p_scale, 0));
vs.push_back(Vector3(p_scale, -p_scale, 0));
vs.push_back(Vector3(-p_scale, -p_scale, 0));
Vector<Vector2> uv = {
Vector2(0, 0),
Vector2(1, 0),
Vector2(1, 1),
Vector2(0, 1)
};
uv.push_back(Vector2(0, 0));
uv.push_back(Vector2(1, 0));
uv.push_back(Vector2(1, 1));
uv.push_back(Vector2(0, 1));
Vector<Color> colors = {
p_modulate,
p_modulate,
p_modulate,
p_modulate
};
colors.push_back(p_modulate);
colors.push_back(p_modulate);
colors.push_back(p_modulate);
colors.push_back(p_modulate);
Vector<int> indices = { 0, 1, 2, 0, 2, 3 };
Ref<ArrayMesh> mesh = memnew(ArrayMesh);
Array a;
a.resize(Mesh::ARRAY_MAX);
a[Mesh::ARRAY_VERTEX] = vs;
a[Mesh::ARRAY_TEX_UV] = uv;
Vector<int> indices;
indices.push_back(0);
indices.push_back(1);
indices.push_back(2);
indices.push_back(0);
indices.push_back(2);
indices.push_back(3);
a[Mesh::ARRAY_INDEX] = indices;
a[Mesh::ARRAY_COLOR] = colors;
mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, a);
@ -1477,9 +1474,10 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
p_gizmo->add_lines(points_primary, material_primary, false, color);
p_gizmo->add_lines(points_secondary, material_secondary, false, color);
Vector<Vector3> handles;
handles.push_back(Vector3(0, 0, -r));
handles.push_back(Vector3(w, 0, -d));
Vector<Vector3> handles = {
Vector3(0, 0, -r),
Vector3(w, 0, -d)
};
p_gizmo->add_handles(handles, get_material("handles"));
p_gizmo->add_unscaled_billboard(icon, 0.05, color);
@ -2210,10 +2208,10 @@ void SpringArm3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
p_gizmo->clear();
Vector<Vector3> lines;
lines.push_back(Vector3());
lines.push_back(Vector3(0, 0, 1.0) * spring_arm->get_length());
Vector<Vector3> lines = {
Vector3(),
Vector3(0, 0, 1.0) * spring_arm->get_length()
};
Ref<StandardMaterial3D> material = get_material("shape_material", p_gizmo);
@ -4296,9 +4294,10 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
p_gizmo->add_collision_segments(collision_segments);
Vector<Vector3> handles;
handles.push_back(Vector3(cs2->get_radius(), 0, 0));
handles.push_back(Vector3(0, cs2->get_height() * 0.5, 0));
Vector<Vector3> handles = {
Vector3(cs2->get_radius(), 0, 0),
Vector3(0, cs2->get_height() * 0.5, 0)
};
p_gizmo->add_handles(handles, handles_material);
}
@ -4352,16 +4351,16 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
p_gizmo->add_collision_segments(collision_segments);
Vector<Vector3> handles;
handles.push_back(Vector3(cs2->get_radius(), 0, 0));
handles.push_back(Vector3(0, cs2->get_height() * 0.5, 0));
Vector<Vector3> handles = {
Vector3(cs2->get_radius(), 0, 0),
Vector3(0, cs2->get_height() * 0.5, 0)
};
p_gizmo->add_handles(handles, handles_material);
}
if (Object::cast_to<WorldBoundaryShape3D>(*s)) {
Ref<WorldBoundaryShape3D> wbs = s;
const Plane &p = wbs->get_plane();
Vector<Vector3> points;
Vector3 n1 = p.get_any_perpendicular_normal();
Vector3 n2 = p.normal.cross(n1).normalized();
@ -4373,16 +4372,18 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
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
};
p_gizmo->add_lines(points, material);
p_gizmo->add_collision_segments(points);
@ -4419,9 +4420,10 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
if (Object::cast_to<SeparationRayShape3D>(*s)) {
Ref<SeparationRayShape3D> rs = s;
Vector<Vector3> points;
points.push_back(Vector3());
points.push_back(Vector3(0, 0, rs->get_length()));
Vector<Vector3> points = {
Vector3(),
Vector3(0, 0, rs->get_length())
};
p_gizmo->add_lines(points, material);
p_gizmo->add_collision_segments(points);
Vector<Vector3> handles;

View File

@ -5260,21 +5260,26 @@ Size2 VisualShaderNodePortPreview::get_minimum_size() const {
void VisualShaderNodePortPreview::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
Vector<Vector2> points;
Vector<Vector2> uvs;
Vector<Color> colors;
points.push_back(Vector2());
uvs.push_back(Vector2(0, 0));
colors.push_back(Color(1, 1, 1, 1));
points.push_back(Vector2(get_size().width, 0));
uvs.push_back(Vector2(1, 0));
colors.push_back(Color(1, 1, 1, 1));
points.push_back(get_size());
uvs.push_back(Vector2(1, 1));
colors.push_back(Color(1, 1, 1, 1));
points.push_back(Vector2(0, get_size().height));
uvs.push_back(Vector2(0, 1));
colors.push_back(Color(1, 1, 1, 1));
Vector<Vector2> points = {
Vector2(),
Vector2(get_size().width, 0),
get_size(),
Vector2(0, get_size().height)
};
Vector<Vector2> uvs = {
Vector2(0, 0),
Vector2(1, 0),
Vector2(1, 1),
Vector2(0, 1)
};
Vector<Color> colors = {
Color(1, 1, 1, 1),
Color(1, 1, 1, 1),
Color(1, 1, 1, 1),
Color(1, 1, 1, 1)
};
draw_primitive(points, colors, uvs);
}

View File

@ -164,15 +164,15 @@ void CollisionPolygon2D::_notification(int p_what) {
dcol.a = 1.0;
Vector2 line_to(0, 20);
draw_line(Vector2(), line_to, dcol, 3);
Vector<Vector2> pts;
real_t tsize = 8;
pts.push_back(line_to + (Vector2(0, tsize)));
pts.push_back(line_to + (Vector2(Math_SQRT12 * tsize, 0)));
pts.push_back(line_to + (Vector2(-Math_SQRT12 * tsize, 0)));
Vector<Color> cols;
for (int i = 0; i < 3; i++) {
cols.push_back(dcol);
}
Vector<Vector2> pts = {
line_to + Vector2(0, tsize),
line_to + Vector2(Math_SQRT12 * tsize, 0),
line_to + Vector2(-Math_SQRT12 * tsize, 0)
};
Vector<Color> cols{ dcol, dcol, dcol };
draw_primitive(pts, cols, Vector<Vector2>()); //small arrow
}

View File

@ -121,15 +121,15 @@ void CollisionShape2D::_notification(int p_what) {
}
Vector2 line_to(0, 20);
draw_line(Vector2(), line_to, draw_col, 2);
Vector<Vector2> pts;
real_t tsize = 8;
pts.push_back(line_to + (Vector2(0, tsize)));
pts.push_back(line_to + (Vector2(Math_SQRT12 * tsize, 0)));
pts.push_back(line_to + (Vector2(-Math_SQRT12 * tsize, 0)));
Vector<Color> cols;
for (int i = 0; i < 3; i++) {
cols.push_back(draw_col);
}
Vector<Vector2> pts{
line_to + Vector2(0, tsize),
line_to + Vector2(Math_SQRT12 * tsize, 0),
line_to + Vector2(-Math_SQRT12 * tsize, 0)
};
Vector<Color> cols{ draw_col, draw_col, draw_col };
draw_primitive(pts, cols, Vector<Vector2>());
}

View File

@ -152,11 +152,14 @@ void CPUParticles2D::_update_mesh_texture() {
} else {
tex_size = Size2(1, 1);
}
Vector<Vector2> vertices;
vertices.push_back(-tex_size * 0.5);
vertices.push_back(-tex_size * 0.5 + Vector2(tex_size.x, 0));
vertices.push_back(-tex_size * 0.5 + tex_size);
vertices.push_back(-tex_size * 0.5 + Vector2(0, tex_size.y));
Vector<Vector2> vertices = {
-tex_size * 0.5,
-tex_size * 0.5 + Vector2(tex_size.x, 0),
-tex_size * 0.5 + tex_size,
-tex_size * 0.5 + Vector2(0, tex_size.y)
};
Vector<Vector2> uvs;
AtlasTexture *atlas_texure = Object::cast_to<AtlasTexture>(*texture);
if (atlas_texure && atlas_texure->get_atlas().is_valid()) {
@ -172,18 +175,15 @@ void CPUParticles2D::_update_mesh_texture() {
uvs.push_back(Vector2(1, 1));
uvs.push_back(Vector2(0, 1));
}
Vector<Color> colors;
colors.push_back(Color(1, 1, 1, 1));
colors.push_back(Color(1, 1, 1, 1));
colors.push_back(Color(1, 1, 1, 1));
colors.push_back(Color(1, 1, 1, 1));
Vector<int> indices;
indices.push_back(0);
indices.push_back(1);
indices.push_back(2);
indices.push_back(2);
indices.push_back(3);
indices.push_back(0);
Vector<Color> colors = {
Color(1, 1, 1, 1),
Color(1, 1, 1, 1),
Color(1, 1, 1, 1),
Color(1, 1, 1, 1)
};
Vector<int> indices = { 0, 1, 2, 2, 3, 0 };
Array arr;
arr.resize(RS::ARRAY_MAX);

View File

@ -427,26 +427,23 @@ void GPUParticles2D::_notification(int p_what) {
} else {
RS::get_singleton()->mesh_clear(mesh);
Vector<Vector2> points;
points.resize(4);
points.write[0] = Vector2(-size.x / 2.0, -size.y / 2.0);
points.write[1] = Vector2(size.x / 2.0, -size.y / 2.0);
points.write[2] = Vector2(size.x / 2.0, size.y / 2.0);
points.write[3] = Vector2(-size.x / 2.0, size.y / 2.0);
Vector<Vector2> uvs;
uvs.resize(4);
uvs.write[0] = Vector2(0, 0);
uvs.write[1] = Vector2(1, 0);
uvs.write[2] = Vector2(1, 1);
uvs.write[3] = Vector2(0, 1);
Vector<int> indices;
indices.resize(6);
indices.write[0] = 0;
indices.write[1] = 1;
indices.write[2] = 2;
indices.write[3] = 0;
indices.write[4] = 2;
indices.write[5] = 3;
Vector<Vector2> points = {
Vector2(-size.x / 2.0, -size.y / 2.0),
Vector2(size.x / 2.0, -size.y / 2.0),
Vector2(size.x / 2.0, size.y / 2.0),
Vector2(-size.x / 2.0, size.y / 2.0)
};
Vector<Vector2> uvs = {
Vector2(0, 0),
Vector2(1, 0),
Vector2(1, 1),
Vector2(0, 1)
};
Vector<int> indices = { 0, 1, 2, 0, 2, 3 };
Array arr;
arr.resize(RS::ARRAY_MAX);
arr[RS::ARRAY_VERTEX] = points;

View File

@ -36,37 +36,41 @@ void Position2D::_draw_cross() {
const real_t extents = get_gizmo_extents();
// Add more points to create a "hard stop" in the color gradient.
PackedVector2Array points_x;
points_x.push_back(Point2(+extents, 0));
points_x.push_back(Point2());
points_x.push_back(Point2());
points_x.push_back(Point2(-extents, 0));
PackedVector2Array points_x = {
Point2(+extents, 0),
Point2(),
Point2(),
Point2(-extents, 0)
};
PackedVector2Array points_y;
points_y.push_back(Point2(0, +extents));
points_y.push_back(Point2());
points_y.push_back(Point2());
points_y.push_back(Point2(0, -extents));
PackedVector2Array points_y = {
Point2(0, +extents),
Point2(),
Point2(),
Point2(0, -extents)
};
// Use the axis color which is brighter for the positive axis.
// Use a darkened axis color for the negative axis.
// This makes it possible to see in which direction the Position3D node is rotated
// (which can be important depending on how it's used).
// Axis colors are taken from `axis_x_color` and `axis_y_color` (defined in `editor/editor_themes.cpp`).
PackedColorArray colors_x;
const Color color_x = Color(0.96, 0.20, 0.32);
colors_x.push_back(color_x);
colors_x.push_back(color_x);
colors_x.push_back(color_x.lerp(Color(0, 0, 0), 0.5));
colors_x.push_back(color_x.lerp(Color(0, 0, 0), 0.5));
PackedColorArray colors_x = {
color_x,
color_x,
color_x.lerp(Color(0, 0, 0), 0.5),
color_x.lerp(Color(0, 0, 0), 0.5)
};
draw_multiline_colors(points_x, colors_x);
PackedColorArray colors_y;
const Color color_y = Color(0.53, 0.84, 0.01);
colors_y.push_back(color_y);
colors_y.push_back(color_y);
colors_y.push_back(color_y.lerp(Color(0, 0, 0), 0.5));
colors_y.push_back(color_y.lerp(Color(0, 0, 0), 0.5));
PackedColorArray colors_y = {
color_y,
color_y,
color_y.lerp(Color(0, 0, 0), 0.5),
color_y.lerp(Color(0, 0, 0), 0.5)
};
draw_multiline_colors(points_y, colors_y);
}

View File

@ -244,15 +244,13 @@ void RayCast2D::_draw_debug_shape() {
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<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;
for (int i = 0; i < 3; i++) {
cols.push_back(draw_col);
}
Vector<Color> cols = { draw_col, draw_col, draw_col };
draw_primitive(pts, cols, Vector<Vector2>());
}

View File

@ -239,14 +239,16 @@ void ShapeCast2D::_notification(int p_what) {
xf.translate(Vector2(target_position.length(), 0));
draw_line(Vector2(), target_position, draw_col, 2);
Vector<Vector2> pts;
float tsize = 8;
pts.push_back(xf.xform(Vector2(tsize, 0)));
pts.push_back(xf.xform(Vector2(0, Math_SQRT12 * tsize)));
pts.push_back(xf.xform(Vector2(0, -Math_SQRT12 * tsize)));
Vector<Color> cols;
for (int i = 0; i < 3; i++)
cols.push_back(draw_col);
Vector<Vector2> pts = {
xf.xform(Vector2(tsize, 0)),
xf.xform(Vector2(0, Math_SQRT12 * tsize)),
xf.xform(Vector2(0, -Math_SQRT12 * tsize))
};
Vector<Color> cols = { draw_col, draw_col, draw_col };
draw_primitive(pts, cols, Vector<Vector2>());
}

View File

@ -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<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;
for (int i = 0; i < 3; i++) {
cols.push_back(p_color);
}
Vector<Color> cols = { p_color, p_color, p_color };
RS::get_singleton()->canvas_item_add_primitive(p_to_rid, pts, cols, Vector<Point2>(), RID());
}

View File

@ -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;
}

View File

@ -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++) {

View File

@ -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++) {

View File

@ -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;
}

View File

@ -1795,12 +1795,14 @@ void RenderForwardClustered::_render_material(const Transform3D &p_cam_transform
{
RenderListParameters render_list_params(render_list[RENDER_LIST_SECONDARY].elements.ptr(), render_list[RENDER_LIST_SECONDARY].element_info.ptr(), render_list[RENDER_LIST_SECONDARY].elements.size(), true, pass_mode, true, false, rp_uniform_set);
//regular forward for now
Vector<Color> clear;
clear.push_back(Color(0, 0, 0, 0));
clear.push_back(Color(0, 0, 0, 0));
clear.push_back(Color(0, 0, 0, 0));
clear.push_back(Color(0, 0, 0, 0));
clear.push_back(Color(0, 0, 0, 0));
Vector<Color> clear = {
Color(0, 0, 0, 0),
Color(0, 0, 0, 0),
Color(0, 0, 0, 0),
Color(0, 0, 0, 0),
Color(0, 0, 0, 0)
};
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(p_framebuffer, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, clear, 1.0, 0, p_region);
_render_list(draw_list, RD::get_singleton()->framebuffer_get_format(p_framebuffer), &render_list_params, 0, render_list_params.element_count);
RD::get_singleton()->draw_list_end();
@ -1839,12 +1841,13 @@ void RenderForwardClustered::_render_uv2(const PagedArray<GeometryInstance *> &p
{
RenderListParameters render_list_params(render_list[RENDER_LIST_SECONDARY].elements.ptr(), render_list[RENDER_LIST_SECONDARY].element_info.ptr(), render_list[RENDER_LIST_SECONDARY].elements.size(), true, pass_mode, true, false, rp_uniform_set, true);
//regular forward for now
Vector<Color> clear;
clear.push_back(Color(0, 0, 0, 0));
clear.push_back(Color(0, 0, 0, 0));
clear.push_back(Color(0, 0, 0, 0));
clear.push_back(Color(0, 0, 0, 0));
clear.push_back(Color(0, 0, 0, 0));
Vector<Color> clear = {
Color(0, 0, 0, 0),
Color(0, 0, 0, 0),
Color(0, 0, 0, 0),
Color(0, 0, 0, 0),
Color(0, 0, 0, 0)
};
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(p_framebuffer, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, clear, 1.0, 0, p_region);
const int uv_offset_count = 9;
@ -1901,11 +1904,12 @@ void RenderForwardClustered::_render_sdfgi(RID p_render_buffers, const Vector3i
Vector3 half_extents = p_bounds.size * 0.5;
Vector3 center = p_bounds.position + half_extents;
Vector<RID> sbs;
sbs.push_back(p_albedo_texture);
sbs.push_back(p_emission_texture);
sbs.push_back(p_emission_aniso_texture);
sbs.push_back(p_geom_facing_texture);
Vector<RID> sbs = {
p_albedo_texture,
p_emission_texture,
p_emission_aniso_texture,
p_geom_facing_texture
};
//print_line("re-render " + p_from + " - " + p_size + " bounds " + p_bounds);
for (int i = 0; i < 3; i++) {

View File

@ -1002,12 +1002,13 @@ void RenderForwardMobile::_render_material(const Transform3D &p_cam_transform, c
{
RenderListParameters render_list_params(render_list[RENDER_LIST_SECONDARY].elements.ptr(), render_list[RENDER_LIST_SECONDARY].element_info.ptr(), render_list[RENDER_LIST_SECONDARY].elements.size(), true, pass_mode, rp_uniform_set, 0);
//regular forward for now
Vector<Color> clear;
clear.push_back(Color(0, 0, 0, 0));
clear.push_back(Color(0, 0, 0, 0));
clear.push_back(Color(0, 0, 0, 0));
clear.push_back(Color(0, 0, 0, 0));
clear.push_back(Color(0, 0, 0, 0));
Vector<Color> clear = {
Color(0, 0, 0, 0),
Color(0, 0, 0, 0),
Color(0, 0, 0, 0),
Color(0, 0, 0, 0),
Color(0, 0, 0, 0)
};
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(p_framebuffer, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, clear, 1.0, 0, p_region);
_render_list(draw_list, RD::get_singleton()->framebuffer_get_format(p_framebuffer), &render_list_params, 0, render_list_params.element_count);
RD::get_singleton()->draw_list_end();
@ -1043,12 +1044,14 @@ void RenderForwardMobile::_render_uv2(const PagedArray<GeometryInstance *> &p_in
{
RenderListParameters render_list_params(render_list[RENDER_LIST_SECONDARY].elements.ptr(), render_list[RENDER_LIST_SECONDARY].element_info.ptr(), render_list[RENDER_LIST_SECONDARY].elements.size(), true, pass_mode, rp_uniform_set, true, 0);
//regular forward for now
Vector<Color> clear;
clear.push_back(Color(0, 0, 0, 0));
clear.push_back(Color(0, 0, 0, 0));
clear.push_back(Color(0, 0, 0, 0));
clear.push_back(Color(0, 0, 0, 0));
clear.push_back(Color(0, 0, 0, 0));
Vector<Color> clear = {
Color(0, 0, 0, 0),
Color(0, 0, 0, 0),
Color(0, 0, 0, 0),
Color(0, 0, 0, 0),
Color(0, 0, 0, 0)
};
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(p_framebuffer, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, clear, 1.0, 0, p_region);
const int uv_offset_count = 9;