Merge pull request #86474 from KoBeWi/particular_velocity
Only update particle velocity when it changes
This commit is contained in:
commit
97607b6ab3
4 changed files with 16 additions and 6 deletions
|
@ -712,12 +712,15 @@ void GPUParticles2D::_notification(int p_what) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case NOTIFICATION_INTERNAL_PROCESS: {
|
case NOTIFICATION_INTERNAL_PROCESS: {
|
||||||
RS::get_singleton()->particles_set_emitter_velocity(particles,
|
const Vector3 velocity = Vector3((get_global_position() - previous_position).x, (get_global_position() - previous_position).y, 0.0) /
|
||||||
Vector3((get_global_position() - previous_position).x,
|
get_process_delta_time();
|
||||||
(get_global_position() - previous_position).y,
|
|
||||||
0.0) /
|
if (velocity != previous_velocity) {
|
||||||
get_process_delta_time());
|
RS::get_singleton()->particles_set_emitter_velocity(particles, velocity);
|
||||||
|
previous_velocity = velocity;
|
||||||
|
}
|
||||||
previous_position = get_global_position();
|
previous_position = get_global_position();
|
||||||
|
|
||||||
if (one_shot) {
|
if (one_shot) {
|
||||||
time += get_process_delta_time();
|
time += get_process_delta_time();
|
||||||
if (time > emission_time) {
|
if (time > emission_time) {
|
||||||
|
|
|
@ -64,6 +64,7 @@ private:
|
||||||
bool fractional_delta = false;
|
bool fractional_delta = false;
|
||||||
bool interpolate = true;
|
bool interpolate = true;
|
||||||
float interp_to_end_factor = 0;
|
float interp_to_end_factor = 0;
|
||||||
|
Vector3 previous_velocity;
|
||||||
Vector2 previous_position;
|
Vector2 previous_position;
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
bool show_visibility_rect = false;
|
bool show_visibility_rect = false;
|
||||||
|
|
|
@ -460,7 +460,12 @@ void GPUParticles3D::_notification(int p_what) {
|
||||||
// Use internal process when emitting and one_shot is on so that when
|
// Use internal process when emitting and one_shot is on so that when
|
||||||
// the shot ends the editor can properly update.
|
// the shot ends the editor can properly update.
|
||||||
case NOTIFICATION_INTERNAL_PROCESS: {
|
case NOTIFICATION_INTERNAL_PROCESS: {
|
||||||
RS::get_singleton()->particles_set_emitter_velocity(particles, (get_global_position() - previous_position) / get_process_delta_time());
|
const Vector3 velocity = (get_global_position() - previous_position) / get_process_delta_time();
|
||||||
|
|
||||||
|
if (velocity != previous_velocity) {
|
||||||
|
RS::get_singleton()->particles_set_emitter_velocity(particles, velocity);
|
||||||
|
previous_velocity = velocity;
|
||||||
|
}
|
||||||
previous_position = get_global_position();
|
previous_position = get_global_position();
|
||||||
|
|
||||||
if (one_shot) {
|
if (one_shot) {
|
||||||
|
|
|
@ -95,6 +95,7 @@ private:
|
||||||
double emission_time = 0.0;
|
double emission_time = 0.0;
|
||||||
double active_time = 0.0;
|
double active_time = 0.0;
|
||||||
float interp_to_end_factor = 0;
|
float interp_to_end_factor = 0;
|
||||||
|
Vector3 previous_velocity;
|
||||||
Vector3 previous_position;
|
Vector3 previous_position;
|
||||||
|
|
||||||
void _attach_sub_emitter();
|
void _attach_sub_emitter();
|
||||||
|
|
Loading…
Reference in a new issue