[Bf-blender-cvs] [0e528d53611] functions: improve spacing of trail particles
Jacques Lucke
noreply at git.blender.org
Wed Sep 4 19:43:42 CEST 2019
Commit: 0e528d536114dcc07bb21c15252eb9716dc20986
Author: Jacques Lucke
Date: Wed Sep 4 16:00:13 2019 +0200
Branches: functions
https://developer.blender.org/rB0e528d536114dcc07bb21c15252eb9716dc20986
improve spacing of trail particles
===================================================================
M source/blender/simulations/bparticles/offset_handlers.cpp
M source/blender/simulations/bparticles/time_span.hpp
===================================================================
diff --git a/source/blender/simulations/bparticles/offset_handlers.cpp b/source/blender/simulations/bparticles/offset_handlers.cpp
index a99a743890f..77eea21e299 100644
--- a/source/blender/simulations/bparticles/offset_handlers.cpp
+++ b/source/blender/simulations/bparticles/offset_handlers.cpp
@@ -17,17 +17,16 @@ void CreateTrailHandler::execute(OffsetHandlerInterface &interface)
continue;
}
- float frequency = 1.0f / rate;
- float time_factor = interface.time_factors()[pindex];
TimeSpan time_span = interface.time_span(pindex);
- float current_time = frequency * (std::floor(time_span.start() / frequency) + 1.0f);
- float3 total_offset = position_offsets[pindex] * time_factor;
- while (current_time < time_span.end()) {
- float factor = time_span.get_factor_safe(current_time);
+ float factor_start, factor_step;
+ time_span.uniform_samples(rate, factor_start, factor_step);
+
+ float3 total_offset = position_offsets[pindex] * interface.time_factors()[pindex];
+ for (float factor = factor_start; factor < 1.0f; factor += factor_step) {
+ float time = time_span.interpolate(factor);
new_positions.append(positions[pindex] + total_offset * factor);
- new_birth_times.append(current_time);
- current_time += frequency;
+ new_birth_times.append(time);
}
}
diff --git a/source/blender/simulations/bparticles/time_span.hpp b/source/blender/simulations/bparticles/time_span.hpp
index f4608cb0c18..494e830d578 100644
--- a/source/blender/simulations/bparticles/time_span.hpp
+++ b/source/blender/simulations/bparticles/time_span.hpp
@@ -82,6 +82,13 @@ struct TimeSpan {
return 0.0f;
}
}
+
+ void uniform_samples(float samples_per_time, float &r_factor_start, float &r_factor_step)
+ {
+ r_factor_step = 1 / (m_duration * samples_per_time);
+ float time_start = std::ceil(m_start * samples_per_time) / samples_per_time;
+ r_factor_start = this->get_factor_safe(time_start);
+ }
};
} // namespace BParticles
More information about the Bf-blender-cvs
mailing list