Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ pub struct GpuPointParticles3D {
compute_spawn_rings: AHashMap<NodeID, SpawnRingState>,
compute_spawn_origin_dirty_slots: Vec<u32>,
compute_spawn_rotation_dirty_slots: Vec<u32>,
emitter_order: Vec<usize>,
spawn_origin_cache: AHashMap<NodeID, AHashMap<u32, SpawnOriginEntry>>,
spawn_origin_generation: u64,
hybrid_map_fingerprint: u64,
Expand Down Expand Up @@ -987,6 +988,7 @@ impl GpuPointParticles3D {
compute_spawn_rings: AHashMap::new(),
compute_spawn_origin_dirty_slots: Vec::new(),
compute_spawn_rotation_dirty_slots: Vec::new(),
emitter_order: Vec::new(),
spawn_origin_cache: AHashMap::new(),
spawn_origin_generation: 0,
hybrid_map_fingerprint: 0,
Expand Down Expand Up @@ -1041,9 +1043,16 @@ impl GpuPointParticles3D {
if self.spawn_origin_generation == 0 {
self.spawn_origin_generation = 1;
}
let mut emitter_order = (0..frame.emitters.len()).collect::<Vec<_>>();
emitter_order.sort_unstable_by_key(|&i| frame.emitters[i].0.as_u64());
for idx in emitter_order {
self.emitter_order.clear();
if self.emitter_order.capacity() < frame.emitters.len() {
self.emitter_order
.reserve(frame.emitters.len() - self.emitter_order.capacity());
}
self.emitter_order.extend(0..frame.emitters.len());
self.emitter_order
.sort_unstable_by_key(|&i| frame.emitters[i].0.as_u64());
for pos in 0..self.emitter_order.len() {
let idx = self.emitter_order[pos];
let (node, emitter) = &frame.emitters[idx];
match emitter.sim_mode {
ParticleSimulationMode3D::Cpu => self.push_emitter_particles(*node, emitter),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ impl Runtime {

pub fn drain_render_commands(&mut self, out: &mut Vec<RenderCommand>) {
let mut queued_resource_commands = self.render.take_resource_queue_scratch();
queued_resource_commands.clear();
self.resource_api
.drain_commands(&mut queued_resource_commands);
if !queued_resource_commands.is_empty() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ impl RenderState {
}

pub(crate) fn drain_commands(&mut self, out: &mut Vec<RenderCommand>) {
if out.capacity() - out.len() < self.pending_commands.len() {
out.reserve(self.pending_commands.len() - (out.capacity() - out.len()));
}
out.append(&mut self.pending_commands);
}

Expand Down Expand Up @@ -587,6 +590,9 @@ impl DirtyState {

pub(crate) fn take_pending_transform_roots(&mut self, out: &mut Vec<NodeID>) {
out.clear();
if out.capacity() < self.pending_transform_roots.len() {
out.reserve(self.pending_transform_roots.len() - out.capacity());
}
out.append(&mut self.pending_transform_roots);
for id in out.iter().copied() {
let index = id.index() as usize;
Expand Down
Loading