mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Parallelize deferred writes in phys::Sys
.
This commit is contained in:
parent
f578c56db7
commit
00f8183733
@ -667,7 +667,15 @@ impl<'a> PhysicsData<'a> {
|
|||||||
&write.previous_phys_cache,
|
&write.previous_phys_cache,
|
||||||
&write.orientations,
|
&write.orientations,
|
||||||
);
|
);
|
||||||
span!(guard, "Apply terrain collision");
|
span!(
|
||||||
|
guard,
|
||||||
|
"{}",
|
||||||
|
if terrain_like_entities {
|
||||||
|
"voxel terrain collision"
|
||||||
|
} else {
|
||||||
|
"cylinder terrain collision"
|
||||||
|
}
|
||||||
|
);
|
||||||
job.cpu_stats.measure(ParMode::Rayon);
|
job.cpu_stats.measure(ParMode::Rayon);
|
||||||
let (land_on_grounds, mut outcomes) = (
|
let (land_on_grounds, mut outcomes) = (
|
||||||
&read.entities,
|
&read.entities,
|
||||||
@ -1130,36 +1138,36 @@ impl<'a> PhysicsData<'a> {
|
|||||||
write.outcomes.append(&mut outcomes);
|
write.outcomes.append(&mut outcomes);
|
||||||
|
|
||||||
prof_span!(guard, "write deferred pos and vel");
|
prof_span!(guard, "write deferred pos and vel");
|
||||||
for (_, pos, vel, pos_vel_defer, _) in (
|
(
|
||||||
&read.entities,
|
&read.entities,
|
||||||
&mut write.positions,
|
&mut write.positions,
|
||||||
&mut write.velocities,
|
&mut write.velocities,
|
||||||
&mut write.pos_vel_defers,
|
&mut write.pos_vel_defers,
|
||||||
&read.colliders,
|
&read.colliders,
|
||||||
)
|
)
|
||||||
.join()
|
.par_join()
|
||||||
.filter(|tuple| matches!(tuple.4, Collider::Voxel { .. }) == terrain_like_entities)
|
.filter(|tuple| matches!(tuple.4, Collider::Voxel { .. }) == terrain_like_entities)
|
||||||
{
|
.for_each(|(_, pos, vel, pos_vel_defer, _)| {
|
||||||
if let Some(new_pos) = pos_vel_defer.pos.take() {
|
if let Some(new_pos) = pos_vel_defer.pos.take() {
|
||||||
*pos = new_pos;
|
*pos = new_pos;
|
||||||
}
|
}
|
||||||
if let Some(new_vel) = pos_vel_defer.vel.take() {
|
if let Some(new_vel) = pos_vel_defer.vel.take() {
|
||||||
*vel = new_vel;
|
*vel = new_vel;
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
drop(guard);
|
drop(guard);
|
||||||
|
|
||||||
prof_span!(guard, "record ori into phys_cache");
|
prof_span!(guard, "record ori into phys_cache");
|
||||||
for (ori, previous_phys_cache, _) in (
|
(
|
||||||
&write.orientations,
|
&write.orientations,
|
||||||
&mut write.previous_phys_cache,
|
&mut write.previous_phys_cache,
|
||||||
&read.colliders,
|
&read.colliders,
|
||||||
)
|
)
|
||||||
.join()
|
.par_join()
|
||||||
.filter(|tuple| matches!(tuple.2, Collider::Voxel { .. }) == terrain_like_entities)
|
.filter(|tuple| matches!(tuple.2, Collider::Voxel { .. }) == terrain_like_entities)
|
||||||
{
|
.for_each(|(ori, previous_phys_cache, _)| {
|
||||||
previous_phys_cache.ori = ori.to_quat();
|
previous_phys_cache.ori = ori.to_quat();
|
||||||
}
|
});
|
||||||
drop(guard);
|
drop(guard);
|
||||||
|
|
||||||
let mut event_emitter = read.event_bus.emitter();
|
let mut event_emitter = read.event_bus.emitter();
|
||||||
|
Loading…
Reference in New Issue
Block a user