summaryrefslogtreecommitdiffstats
path: root/scene/2d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/gpu_particles_2d.cpp34
-rw-r--r--scene/2d/gpu_particles_2d.h8
-rw-r--r--scene/2d/tile_map.cpp16
3 files changed, 56 insertions, 2 deletions
diff --git a/scene/2d/gpu_particles_2d.cpp b/scene/2d/gpu_particles_2d.cpp
index 67b14692a2..ee33ff88d4 100644
--- a/scene/2d/gpu_particles_2d.cpp
+++ b/scene/2d/gpu_particles_2d.cpp
@@ -192,6 +192,11 @@ void GPUParticles2D::set_trail_section_subdivisions(int p_subdivisions) {
queue_redraw();
}
+void GPUParticles2D::set_interp_to_end(float p_interp) {
+ interp_to_end_factor = CLAMP(p_interp, 0.0, 1.0);
+ RS::get_singleton()->particles_set_interp_to_end(particles, interp_to_end_factor);
+}
+
#ifdef TOOLS_ENABLED
void GPUParticles2D::set_show_visibility_rect(bool p_show_visibility_rect) {
show_visibility_rect = p_show_visibility_rect;
@@ -318,6 +323,10 @@ bool GPUParticles2D::get_interpolate() const {
return interpolate;
}
+float GPUParticles2D::get_interp_to_end() const {
+ return interp_to_end_factor;
+}
+
PackedStringArray GPUParticles2D::get_configuration_warnings() const {
PackedStringArray warnings = Node2D::get_configuration_warnings();
@@ -423,6 +432,15 @@ NodePath GPUParticles2D::get_sub_emitter() const {
return sub_emitter;
}
+void GPUParticles2D::set_amount_ratio(float p_ratio) {
+ amount_ratio = p_ratio;
+ RenderingServer::get_singleton()->particles_set_amount_ratio(particles, p_ratio);
+}
+
+float GPUParticles2D::get_amount_ratio() const {
+ return amount_ratio;
+}
+
void GPUParticles2D::restart() {
RS::get_singleton()->particles_restart(particles);
RS::get_singleton()->particles_set_emitting(particles, true);
@@ -670,6 +688,8 @@ void GPUParticles2D::_notification(int p_what) {
} else {
RS::get_singleton()->particles_set_speed_scale(particles, 0);
}
+ set_process_internal(true);
+ previous_position = get_global_position();
} break;
case NOTIFICATION_EXIT_TREE: {
@@ -692,6 +712,12 @@ void GPUParticles2D::_notification(int p_what) {
} break;
case NOTIFICATION_INTERNAL_PROCESS: {
+ RS::get_singleton()->particles_set_emitter_velocity(particles,
+ Vector3((get_global_position() - previous_position).x,
+ (get_global_position() - previous_position).y,
+ 0.0) /
+ get_process_delta_time());
+ previous_position = get_global_position();
if (one_shot) {
time += get_process_delta_time();
if (time > emission_time) {
@@ -730,6 +756,7 @@ void GPUParticles2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_process_material", "material"), &GPUParticles2D::set_process_material);
ClassDB::bind_method(D_METHOD("set_speed_scale", "scale"), &GPUParticles2D::set_speed_scale);
ClassDB::bind_method(D_METHOD("set_collision_base_size", "size"), &GPUParticles2D::set_collision_base_size);
+ ClassDB::bind_method(D_METHOD("set_interp_to_end", "interp"), &GPUParticles2D::set_interp_to_end);
ClassDB::bind_method(D_METHOD("is_emitting"), &GPUParticles2D::is_emitting);
ClassDB::bind_method(D_METHOD("get_amount"), &GPUParticles2D::get_amount);
@@ -746,6 +773,7 @@ void GPUParticles2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_process_material"), &GPUParticles2D::get_process_material);
ClassDB::bind_method(D_METHOD("get_speed_scale"), &GPUParticles2D::get_speed_scale);
ClassDB::bind_method(D_METHOD("get_collision_base_size"), &GPUParticles2D::get_collision_base_size);
+ ClassDB::bind_method(D_METHOD("get_interp_to_end"), &GPUParticles2D::get_interp_to_end);
ClassDB::bind_method(D_METHOD("set_draw_order", "order"), &GPUParticles2D::set_draw_order);
ClassDB::bind_method(D_METHOD("get_draw_order"), &GPUParticles2D::get_draw_order);
@@ -776,11 +804,15 @@ void GPUParticles2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("convert_from_particles", "particles"), &GPUParticles2D::convert_from_particles);
+ ClassDB::bind_method(D_METHOD("set_amount_ratio", "ratio"), &GPUParticles2D::set_amount_ratio);
+ ClassDB::bind_method(D_METHOD("get_amount_ratio"), &GPUParticles2D::get_amount_ratio);
+
ADD_SIGNAL(MethodInfo("finished"));
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "emitting"), "set_emitting", "is_emitting");
ADD_PROPERTY_DEFAULT("emitting", true); // Workaround for doctool in headless mode, as dummy rasterizer always returns false.
ADD_PROPERTY(PropertyInfo(Variant::INT, "amount", PROPERTY_HINT_RANGE, "1,1000000,1,exp"), "set_amount", "get_amount");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "amount_ratio", PROPERTY_HINT_RANGE, "0,1,0.0001"), "set_amount_ratio", "get_amount_ratio");
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "sub_emitter", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "GPUParticles2D"), "set_sub_emitter", "get_sub_emitter");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "process_material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,ParticleProcessMaterial"), "set_process_material", "get_process_material");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture");
@@ -794,6 +826,7 @@ void GPUParticles2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "fixed_fps", PROPERTY_HINT_RANGE, "0,1000,1,suffix:FPS"), "set_fixed_fps", "get_fixed_fps");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "interpolate"), "set_interpolate", "get_interpolate");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fract_delta"), "set_fractional_delta", "get_fractional_delta");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "interp_to_end", PROPERTY_HINT_RANGE, "0.00,1.0,0.001"), "set_interp_to_end", "get_interp_to_end");
ADD_GROUP("Collision", "collision_");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "collision_base_size", PROPERTY_HINT_RANGE, "0,128,0.01,or_greater"), "set_collision_base_size", "get_collision_base_size");
ADD_GROUP("Drawing", "");
@@ -829,6 +862,7 @@ GPUParticles2D::GPUParticles2D() {
set_emitting(true);
set_one_shot(false);
set_amount(8);
+ set_amount_ratio(1.0);
set_lifetime(1);
set_fixed_fps(0);
set_fractional_delta(true);
diff --git a/scene/2d/gpu_particles_2d.h b/scene/2d/gpu_particles_2d.h
index 3a342e2c22..40831cd30e 100644
--- a/scene/2d/gpu_particles_2d.h
+++ b/scene/2d/gpu_particles_2d.h
@@ -52,6 +52,7 @@ private:
bool signal_canceled = false;
bool one_shot = false;
int amount = 0;
+ float amount_ratio = 1.0;
double lifetime = 0.0;
double pre_process_time = 0.0;
real_t explosiveness_ratio = 0.0;
@@ -62,6 +63,8 @@ private:
int fixed_fps = 0;
bool fractional_delta = false;
bool interpolate = true;
+ float interp_to_end_factor = 0;
+ Vector2 previous_position;
#ifdef TOOLS_ENABLED
bool show_visibility_rect = false;
#endif
@@ -114,6 +117,7 @@ public:
void set_trail_lifetime(double p_seconds);
void set_trail_sections(int p_sections);
void set_trail_section_subdivisions(int p_subdivisions);
+ void set_interp_to_end(float p_interp);
#ifdef TOOLS_ENABLED
void set_show_visibility_rect(bool p_show_visibility_rect);
@@ -136,6 +140,7 @@ public:
double get_trail_lifetime() const;
int get_trail_sections() const;
int get_trail_section_subdivisions() const;
+ float get_interp_to_end() const;
void set_fixed_fps(int p_count);
int get_fixed_fps() const;
@@ -152,6 +157,9 @@ public:
void set_texture(const Ref<Texture2D> &p_texture);
Ref<Texture2D> get_texture() const;
+ void set_amount_ratio(float p_ratio);
+ float get_amount_ratio() const;
+
PackedStringArray get_configuration_warnings() const override;
void set_sub_emitter(const NodePath &p_path);
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 7b0bd7e26c..b1c5677726 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -197,10 +197,10 @@ void TileMapLayer::_rendering_update() {
if (!canvas_item.is_valid()) {
RID ci = rs->canvas_item_create();
rs->canvas_item_set_parent(ci, tile_map_node->get_canvas_item());
- rs->canvas_item_set_draw_index(ci, layer_index_in_tile_map_node - (int64_t)0x80000000);
canvas_item = ci;
}
RID &ci = canvas_item;
+ rs->canvas_item_set_draw_index(ci, layer_index_in_tile_map_node - (int64_t)0x80000000);
rs->canvas_item_set_sort_children_by_y(ci, y_sort_enabled);
rs->canvas_item_set_use_parent_material(ci, tile_map_node->get_use_parent_material() || tile_map_node->get_material().is_valid());
rs->canvas_item_set_z_index(ci, z_index);
@@ -4518,14 +4518,26 @@ PackedStringArray TileMap::get_configuration_warnings() const {
}
}
- // Check if Y-sort is enabled on a layer but not on the node.
if (!is_y_sort_enabled()) {
+ // Check if Y-sort is enabled on a layer but not on the node.
for (const Ref<TileMapLayer> &layer : layers) {
if (layer->is_y_sort_enabled()) {
warnings.push_back(RTR("A TileMap layer is set as Y-sorted, but Y-sort is not enabled on the TileMap node itself."));
break;
}
}
+ } else {
+ // Check if Y-sort is enabled on the node, but not on any of the layers.
+ bool need_warning = true;
+ for (const Ref<TileMapLayer> &layer : layers) {
+ if (layer->is_y_sort_enabled()) {
+ need_warning = false;
+ break;
+ }
+ }
+ if (need_warning) {
+ warnings.push_back(RTR("The TileMap node is set as Y-sorted, but Y-sort is not enabled on any of the TileMap's layers.\nThis may lead to unwanted behaviors, as a layer that is not Y-sorted will be Y-sorted as a whole."));
+ }
}
// Check if we are in isometric mode without Y-sort enabled.