Skip to content
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

CPUParticles initialize data on set_amount #66115

Merged
merged 1 commit into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions scene/2d/cpu_particles_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ void CPUParticles2D::set_amount(int p_amount) {
}

particle_data.resize((8 + 4 + 1) * p_amount);
// We must fill immediately to prevent garbage data and Nans
// being sent to the visual server with set_as_bulk_array,
// if this is sent before being regularly updated.
particle_data.fill(0);

VS::get_singleton()->multimesh_allocate(multimesh, p_amount, VS::MULTIMESH_TRANSFORM_2D, VS::MULTIMESH_COLOR_8BIT, VS::MULTIMESH_CUSTOM_DATA_FLOAT);

particle_order.resize(p_amount);
Expand Down
7 changes: 7 additions & 0 deletions scene/3d/cpu_particles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ void CPUParticles::set_amount(int p_amount) {

particle_data.resize((12 + 4 + 1) * p_amount);
particle_data_prev.resize(particle_data.size());

// We must fill immediately to prevent garbage data and Nans
// being sent to the visual server with set_as_bulk_array,
// if this is sent before being regularly updated.
particle_data.fill(0);
particle_data_prev.fill(0);

VS::get_singleton()->multimesh_allocate(multimesh, p_amount, VS::MULTIMESH_TRANSFORM_3D, VS::MULTIMESH_COLOR_8BIT, VS::MULTIMESH_CUSTOM_DATA_FLOAT);

particle_order.resize(p_amount);
Expand Down