-
-
Notifications
You must be signed in to change notification settings - Fork 21k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preview the color animation in the animation editor #47230
Conversation
6a7bc24
to
301e344
Compare
@timothyqiu should be fixed now. |
5e3bdeb
to
2c31dae
Compare
points.write[points.size() - i] = Vector2(x_pos, y_from + fh); | ||
colors.write[points.size() - i] = color_samples[i]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
points.write[points.size() - i] = Vector2(x_pos, y_from + fh); | |
colors.write[points.size() - i] = color_samples[i]; | |
points.write[points.size() - i - 1] = Vector2(x_pos, y_from + fh); | |
colors.write[points.size() - i - 1] = color_samples[i]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After debugging a bit, it seems a bug in the renderer as it appears only when there are 8 or more points.
I fix it by splitting the polygon in chunks of 6 points.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh, the code looks too complicated now .-.
But that maybe it should be fine if you add a comment saying that this is a workaround for a bug. Or alternatively you could return to the first approach...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same issue happens in 3.x, so I think it is better to return to the draw_primitive
approach.
chunked draw_polygon approach
const int polygon_points = 3;
Vector<Vector2> points;
Vector<Color> colors;
points.resize(polygon_points * 2);
colors.resize(polygon_points * 2);
int j = 0;
for (int i = 0; i < color_samples.size() || j == polygon_points; i++) {
if (j == polygon_points) {
j = 0;
i -= 2;
draw_polygon(points.duplicate(), colors.duplicate());
} else {
int x_pos = Math::lerp(x_from, x_to, float(i) / (color_samples.size() - 1));
points.write[j] = Vector2(x_pos, y_from);
colors.write[j] = color_samples[i];
points.write[points.size() - j - 1] = Vector2(x_pos, y_from + fh);
colors.write[points.size() - j - 1] = color_samples[i];
j++;
}
}
if (j > 1) {
Vector<Vector2> points_aux = points.subarray(points.size() - j, points.size() - 1);
Vector<Color> colors_aux = colors.subarray(points.size() - j, points.size() - 1);
points.resize(j);
colors.resize(j);
points.append_array(points_aux);
colors.append_array(colors_aux);
draw_polygon(points, colors);
}
2c31dae
to
a85af26
Compare
6474aa8
to
ae8f732
Compare
ae8f732
to
735c839
Compare
Thanks! |
Cherry-picked for 3.4. |
Fixes godotengine/godot-proposals#289 for color tracks (not sure if it is enough to close the proposal)
It is done by splitting the link between the 2 keys in chunks.