mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-22 11:56:49 +01:00
Added randomize_start_time optional parameter to canvas_item_add_texture_rect_animation().
This commit is contained in:
parent
8a8193e8d3
commit
588b50e9ce
@ -273,11 +273,12 @@
|
||||
<return type="void" />
|
||||
<argument index="0" name="item" type="RID" />
|
||||
<argument index="1" name="animation_data" type="Array" />
|
||||
<argument index="2" name="randomize_start_time" type="bool" default="false" />
|
||||
<description>
|
||||
Add texture rect regions as an animation to the [CanvasItem]'s draw commands.
|
||||
You need to pass an Array of Arrays, the inner Arrays are the frames. The 0th argument is the frame time, the rest are the arguments of [member canvas_item_add_texture_rect_region] in order.
|
||||
This Animation might lag behind by a frame sometimes, using it is not recommended for highly precise gameplay related things, it's more suited for decorations.
|
||||
The Array should like this:
|
||||
The Array should look like this:
|
||||
[code]
|
||||
[
|
||||
[
|
||||
@ -292,7 +293,6 @@
|
||||
],
|
||||
# ... More Frames
|
||||
][/code]
|
||||
|
||||
</description>
|
||||
</method>
|
||||
<method name="canvas_item_add_texture_rect_region">
|
||||
|
@ -39,6 +39,8 @@
|
||||
#include "rendering_server_raster.h"
|
||||
#include "rendering_server_viewport.h"
|
||||
|
||||
#include "core/math/random_pcg.h"
|
||||
|
||||
static const int z_range = RS::CANVAS_ITEM_Z_MAX - RS::CANVAS_ITEM_Z_MIN + 1;
|
||||
|
||||
void RenderingServerCanvas::_render_canvas_item_tree(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, RasterizerCanvas::Light *p_lights) {
|
||||
@ -1512,7 +1514,7 @@ void RenderingServerCanvas::canvas_item_add_multimesh(RID p_item, RID p_mesh, RI
|
||||
}
|
||||
}
|
||||
|
||||
void RenderingServerCanvas::canvas_item_add_texture_rect_animation(RID p_item, const Array &p_animation_data) {
|
||||
void RenderingServerCanvas::canvas_item_add_texture_rect_animation(RID p_item, const Array &p_animation_data, const bool p_randomize_start_time) {
|
||||
// Important!
|
||||
if (p_animation_data.size() == 0) {
|
||||
return;
|
||||
@ -1591,6 +1593,12 @@ void RenderingServerCanvas::canvas_item_add_texture_rect_animation(RID p_item, c
|
||||
}
|
||||
|
||||
ra->total_time = total_frame_time;
|
||||
|
||||
if (p_randomize_start_time) {
|
||||
RandomPCG r;
|
||||
r.randomize();
|
||||
ra->time_elapsed = r.randf() * ra->total_time;
|
||||
}
|
||||
|
||||
canvas_item->rect_dirty = true;
|
||||
canvas_item->commands.push_back(ra);
|
||||
|
@ -247,7 +247,7 @@ public:
|
||||
void canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), const Vector<int> &p_bones = Vector<int>(), const Vector<float> &p_weights = Vector<float>(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID(), bool p_antialiased = false, bool p_antialiasing_use_indices = false);
|
||||
void canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1), RID p_texture = RID(), RID p_normal_map = RID());
|
||||
void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture = RID(), RID p_normal_map = RID());
|
||||
void canvas_item_add_texture_rect_animation(RID p_item, const Array &p_animation_data);
|
||||
void canvas_item_add_texture_rect_animation(RID p_item, const Array &p_animation_data, const bool p_randomize_start_time = false);
|
||||
|
||||
void canvas_item_add_set_transform(RID p_item, const Transform2D &p_transform);
|
||||
void canvas_item_add_clip_ignore(RID p_item, bool p_ignore);
|
||||
|
@ -612,7 +612,7 @@ public:
|
||||
BIND12(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, const Vector<int> &, const Vector<float> &, RID, int, RID, bool, bool)
|
||||
BIND6(canvas_item_add_mesh, RID, const RID &, const Transform2D &, const Color &, RID, RID)
|
||||
BIND4(canvas_item_add_multimesh, RID, RID, RID, RID)
|
||||
BIND2(canvas_item_add_texture_rect_animation, RID, const Array &)
|
||||
BIND3(canvas_item_add_texture_rect_animation, RID, const Array &, const bool)
|
||||
|
||||
BIND2(canvas_item_add_set_transform, RID, const Transform2D &)
|
||||
BIND2(canvas_item_add_clip_ignore, RID, bool)
|
||||
|
@ -514,7 +514,7 @@ public:
|
||||
FUNC7(canvas_item_add_texture_rect, RID, const Rect2 &, RID, bool, const Color &, bool, RID)
|
||||
FUNC8(canvas_item_add_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &, bool, RID, bool)
|
||||
FUNC7(canvas_item_add_texture_multirect_region, RID, const Vector<Rect2> &, RID, const Vector<Rect2> &, const Color &, uint32_t, RID)
|
||||
FUNC2(canvas_item_add_texture_rect_animation, RID, const Array &)
|
||||
FUNC3(canvas_item_add_texture_rect_animation, RID, const Array &, const bool)
|
||||
FUNC11(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &, RID)
|
||||
FUNC7(canvas_item_add_primitive, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, float, RID)
|
||||
FUNC7(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, RID, bool)
|
||||
|
@ -2155,7 +2155,7 @@ void RenderingServer::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_add_triangle_array", "item", "indices", "points", "colors", "uvs", "bones", "weights", "texture", "count", "normal_map", "antialiased", "antialiasing_use_indices"), &RenderingServer::canvas_item_add_triangle_array, DEFVAL(Vector<Point2>()), DEFVAL(Vector<int>()), DEFVAL(Vector<float>()), DEFVAL(RID()), DEFVAL(-1), DEFVAL(RID()), DEFVAL(false), DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_add_mesh", "item", "mesh", "transform", "modulate", "texture", "normal_map"), &RenderingServer::canvas_item_add_mesh, DEFVAL(Transform2D()), DEFVAL(Color(1, 1, 1)), DEFVAL(RID()), DEFVAL(RID()));
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_add_multimesh", "item", "mesh", "texture", "normal_map"), &RenderingServer::canvas_item_add_multimesh, DEFVAL(RID()));
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_add_texture_rect_animation", "item", "animation_data"), &RenderingServer::canvas_item_add_texture_rect_animation);
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_add_texture_rect_animation", "item", "animation_data", "randomize_start_time"), &RenderingServer::canvas_item_add_texture_rect_animation, DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_add_set_transform", "item", "transform"), &RenderingServer::canvas_item_add_set_transform);
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_add_clip_ignore", "item", "ignore"), &RenderingServer::canvas_item_add_clip_ignore);
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_set_sort_children_by_y", "item", "enabled"), &RenderingServer::canvas_item_set_sort_children_by_y);
|
||||
|
@ -943,7 +943,7 @@ public:
|
||||
virtual void canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), const Vector<int> &p_bones = Vector<int>(), const Vector<float> &p_weights = Vector<float>(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID(), bool p_antialiased = false, bool p_antialiasing_use_indices = false) = 0;
|
||||
virtual void canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1), RID p_texture = RID(), RID p_normal_map = RID()) = 0;
|
||||
virtual void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture = RID(), RID p_normal_map = RID()) = 0;
|
||||
virtual void canvas_item_add_texture_rect_animation(RID p_item, const Array &p_animation_data) = 0;
|
||||
virtual void canvas_item_add_texture_rect_animation(RID p_item, const Array &p_animation_data, const bool p_randomize_start_time = false) = 0;
|
||||
|
||||
virtual void canvas_item_add_set_transform(RID p_item, const Transform2D &p_transform) = 0;
|
||||
virtual void canvas_item_add_clip_ignore(RID p_item, bool p_ignore) = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user