mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-24 12:47:12 +01:00
CPUParticles initialize data on set_amount
Fills particle data with zeroes on resize using set_amount(), to prevent garbage data including Nans being sent to VisualServer, which can corrupt the spatial partitioning.
This commit is contained in:
parent
4da6c31ba9
commit
cd68b6e1e2
@ -63,6 +63,13 @@ 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);
|
||||
particle_data_prev.fill(0);
|
||||
|
||||
RS::get_singleton()->multimesh_allocate(multimesh, p_amount, RS::MULTIMESH_TRANSFORM_2D, RS::MULTIMESH_COLOR_8BIT, RS::MULTIMESH_CUSTOM_DATA_FLOAT);
|
||||
|
||||
particle_order.resize(p_amount);
|
||||
|
@ -88,7 +88,14 @@ void CPUParticles::set_amount(int p_amount) {
|
||||
|
||||
particle_data.resize((12 + 4 + 1) * p_amount);
|
||||
particle_data_prev.resize(particle_data.size());
|
||||
RS::get_singleton()->multimesh_allocate(multimesh, p_amount, RS::MULTIMESH_TRANSFORM_3D, RS::MULTIMESH_COLOR_8BIT, RS::MULTIMESH_CUSTOM_DATA_FLOAT);
|
||||
|
||||
// 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);
|
||||
|
||||
RS::get_singleton()->multimesh_allocate(multimesh, p_amount, RS::MULTIMESH_TRANSFORM_2D, RS::MULTIMESH_COLOR_8BIT, RS::MULTIMESH_CUSTOM_DATA_FLOAT);
|
||||
|
||||
particle_order.resize(p_amount);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user