mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Sprinkle instrumentation in common crate,in particular in the ecs systems
This commit is contained in:
parent
50ceb1c93e
commit
e37a01be9d
@ -1,5 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
astar::{Astar, PathResult},
|
astar::{Astar, PathResult},
|
||||||
|
span,
|
||||||
terrain::Block,
|
terrain::Block,
|
||||||
vol::{BaseVol, ReadVol},
|
vol::{BaseVol, ReadVol},
|
||||||
};
|
};
|
||||||
@ -327,6 +328,7 @@ impl Chaser {
|
|||||||
where
|
where
|
||||||
V: BaseVol<Vox = Block> + ReadVol,
|
V: BaseVol<Vox = Block> + ReadVol,
|
||||||
{
|
{
|
||||||
|
span!(_guard, "Chaser::chase");
|
||||||
let pos_to_tgt = pos.distance(tgt);
|
let pos_to_tgt = pos.distance(tgt);
|
||||||
|
|
||||||
// If we're already close to the target then there's nothing to do
|
// If we're already close to the target then there's nothing to do
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
use crate::vol::{ReadVol, Vox};
|
use crate::{
|
||||||
|
span,
|
||||||
|
vol::{ReadVol, Vox},
|
||||||
|
};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
pub trait RayUntil<V: Vox> = FnMut(&V) -> bool;
|
pub trait RayUntil<V: Vox> = FnMut(&V) -> bool;
|
||||||
@ -52,6 +55,7 @@ impl<'a, V: ReadVol, F: RayUntil<V::Vox>, G: RayForEach<V::Vox>> Ray<'a, V, F, G
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn cast(mut self) -> (f32, Result<Option<&'a V::Vox>, V::Error>) {
|
pub fn cast(mut self) -> (f32, Result<Option<&'a V::Vox>, V::Error>) {
|
||||||
|
span!(_guard, "Ray::cast");
|
||||||
// TODO: Fully test this!
|
// TODO: Fully test this!
|
||||||
|
|
||||||
const PLANCK: f32 = 0.001;
|
const PLANCK: f32 = 0.001;
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
use crate::comp::{Pos, Vel};
|
use crate::{
|
||||||
|
comp::{Pos, Vel},
|
||||||
|
span,
|
||||||
|
};
|
||||||
use hashbrown::{hash_map::DefaultHashBuilder, HashSet};
|
use hashbrown::{hash_map::DefaultHashBuilder, HashSet};
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
use specs::{hibitset::BitSetLike, BitSet, Entities, Join, ReadStorage};
|
use specs::{hibitset::BitSetLike, BitSet, Entities, Join, ReadStorage};
|
||||||
@ -104,6 +107,7 @@ impl RegionMap {
|
|||||||
// TODO maintain within a system?
|
// TODO maintain within a system?
|
||||||
// TODO special case large entities
|
// TODO special case large entities
|
||||||
pub fn tick(&mut self, pos: ReadStorage<Pos>, vel: ReadStorage<Vel>, entities: Entities) {
|
pub fn tick(&mut self, pos: ReadStorage<Pos>, vel: ReadStorage<Vel>, entities: Entities) {
|
||||||
|
span!(_guard, "Region::tick");
|
||||||
self.tick += 1;
|
self.tick += 1;
|
||||||
// Clear events within each region
|
// Clear events within each region
|
||||||
for i in 0..self.regions.len() {
|
for i in 0..self.regions.len() {
|
||||||
|
@ -11,6 +11,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
event::{EventBus, ServerEvent},
|
event::{EventBus, ServerEvent},
|
||||||
path::{Chaser, TraversalConfig},
|
path::{Chaser, TraversalConfig},
|
||||||
|
span,
|
||||||
state::{DeltaTime, Time},
|
state::{DeltaTime, Time},
|
||||||
sync::{Uid, UidAllocator},
|
sync::{Uid, UidAllocator},
|
||||||
terrain::TerrainGrid,
|
terrain::TerrainGrid,
|
||||||
@ -116,6 +117,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
)
|
)
|
||||||
.join()
|
.join()
|
||||||
{
|
{
|
||||||
|
span!(_guard, "agent::Sys::run");
|
||||||
// Hack, replace with better system when groups are more sophisticated
|
// Hack, replace with better system when groups are more sophisticated
|
||||||
// Override alignment if in a group unless entity is owned already
|
// Override alignment if in a group unless entity is owned already
|
||||||
let alignment = if !matches!(alignment, Some(Alignment::Owned(_))) {
|
let alignment = if !matches!(alignment, Some(Alignment::Owned(_))) {
|
||||||
|
@ -4,6 +4,7 @@ use crate::{
|
|||||||
Loadout, Mounting, Ori, PhysicsState, Pos, StateUpdate, Stats, Vel,
|
Loadout, Mounting, Ori, PhysicsState, Pos, StateUpdate, Stats, Vel,
|
||||||
},
|
},
|
||||||
event::{EventBus, LocalEvent, ServerEvent},
|
event::{EventBus, LocalEvent, ServerEvent},
|
||||||
|
span,
|
||||||
state::DeltaTime,
|
state::DeltaTime,
|
||||||
states,
|
states,
|
||||||
sync::{Uid, UidAllocator},
|
sync::{Uid, UidAllocator},
|
||||||
@ -183,6 +184,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
mountings,
|
mountings,
|
||||||
): Self::SystemData,
|
): Self::SystemData,
|
||||||
) {
|
) {
|
||||||
|
span!(_guard, "character_behavior::Sys::run");
|
||||||
let mut server_emitter = server_bus.emitter();
|
let mut server_emitter = server_bus.emitter();
|
||||||
let mut local_emitter = local_bus.emitter();
|
let mut local_emitter = local_bus.emitter();
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ use crate::{
|
|||||||
Loadout, Ori, Pos, Scale, Stats,
|
Loadout, Ori, Pos, Scale, Stats,
|
||||||
},
|
},
|
||||||
event::{EventBus, LocalEvent, ServerEvent},
|
event::{EventBus, LocalEvent, ServerEvent},
|
||||||
|
span,
|
||||||
sync::Uid,
|
sync::Uid,
|
||||||
util::Dir,
|
util::Dir,
|
||||||
};
|
};
|
||||||
@ -52,6 +53,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
character_states,
|
character_states,
|
||||||
): Self::SystemData,
|
): Self::SystemData,
|
||||||
) {
|
) {
|
||||||
|
span!(_guard, "combat::Sys::run");
|
||||||
let mut server_emitter = server_bus.emitter();
|
let mut server_emitter = server_bus.emitter();
|
||||||
let mut local_emitter = local_bus.emitter();
|
let mut local_emitter = local_bus.emitter();
|
||||||
// Attacks
|
// Attacks
|
||||||
|
@ -4,6 +4,7 @@ use crate::{
|
|||||||
CharacterState, ControlEvent, Controller, InventoryManip,
|
CharacterState, ControlEvent, Controller, InventoryManip,
|
||||||
},
|
},
|
||||||
event::{EventBus, LocalEvent, ServerEvent},
|
event::{EventBus, LocalEvent, ServerEvent},
|
||||||
|
span,
|
||||||
state::DeltaTime,
|
state::DeltaTime,
|
||||||
sync::{Uid, UidAllocator},
|
sync::{Uid, UidAllocator},
|
||||||
};
|
};
|
||||||
@ -43,6 +44,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
uids,
|
uids,
|
||||||
): Self::SystemData,
|
): Self::SystemData,
|
||||||
) {
|
) {
|
||||||
|
span!(_guard, "controller::Sys::run");
|
||||||
let mut server_emitter = server_bus.emitter();
|
let mut server_emitter = server_bus.emitter();
|
||||||
|
|
||||||
for (entity, _uid, controller, character_state) in
|
for (entity, _uid, controller, character_state) in
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
comp::{Controller, MountState, Mounting, Ori, Pos, Vel},
|
comp::{Controller, MountState, Mounting, Ori, Pos, Vel},
|
||||||
|
span,
|
||||||
sync::UidAllocator,
|
sync::UidAllocator,
|
||||||
};
|
};
|
||||||
use specs::{
|
use specs::{
|
||||||
@ -36,6 +37,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
mut orientations,
|
mut orientations,
|
||||||
): Self::SystemData,
|
): Self::SystemData,
|
||||||
) {
|
) {
|
||||||
|
span!(_guard, "mount::Sys::run");
|
||||||
// Mounted entities.
|
// Mounted entities.
|
||||||
for (entity, mut mount_states) in (&entities, &mut mount_state.restrict_mut()).join() {
|
for (entity, mut mount_states) in (&entities, &mut mount_state.restrict_mut()).join() {
|
||||||
match mount_states.get_unchecked() {
|
match mount_states.get_unchecked() {
|
||||||
|
@ -95,10 +95,11 @@ impl<'a> System<'a> for Sys {
|
|||||||
projectiles,
|
projectiles,
|
||||||
): Self::SystemData,
|
): Self::SystemData,
|
||||||
) {
|
) {
|
||||||
span!(_guard, "<phys::Sys as System>::run");
|
span!(_guard, "phys::Sys::run");
|
||||||
let mut event_emitter = event_bus.emitter();
|
let mut event_emitter = event_bus.emitter();
|
||||||
|
|
||||||
// Add/reset physics state components
|
// Add/reset physics state components
|
||||||
|
span!(guard, "Add/reset physics state components");
|
||||||
for (entity, _, _, _, _) in (
|
for (entity, _, _, _, _) in (
|
||||||
&entities,
|
&entities,
|
||||||
&colliders,
|
&colliders,
|
||||||
@ -112,6 +113,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
.entry(entity)
|
.entry(entity)
|
||||||
.map(|e| e.or_insert_with(Default::default));
|
.map(|e| e.or_insert_with(Default::default));
|
||||||
}
|
}
|
||||||
|
drop(guard);
|
||||||
|
|
||||||
// Apply pushback
|
// Apply pushback
|
||||||
//
|
//
|
||||||
@ -126,6 +128,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
// terrain collision code below, although that's not trivial to do since
|
// terrain collision code below, although that's not trivial to do since
|
||||||
// it means the step needs to take into account the speeds of both
|
// it means the step needs to take into account the speeds of both
|
||||||
// entities.
|
// entities.
|
||||||
|
span!(guard, "Apply pushback");
|
||||||
for (entity, pos, scale, mass, collider, _, _, physics, projectile) in (
|
for (entity, pos, scale, mass, collider, _, _, physics, projectile) in (
|
||||||
&entities,
|
&entities,
|
||||||
&positions,
|
&positions,
|
||||||
@ -246,8 +249,10 @@ impl<'a> System<'a> for Sys {
|
|||||||
.get_mut(entity)
|
.get_mut(entity)
|
||||||
.map(|vel| vel.0 += vel_delta * dt.0);
|
.map(|vel| vel.0 += vel_delta * dt.0);
|
||||||
}
|
}
|
||||||
|
drop(guard);
|
||||||
|
|
||||||
// Apply movement inputs
|
// Apply movement inputs
|
||||||
|
span!(guard, "Apply movement and terrain collision");
|
||||||
let land_on_grounds = (
|
let land_on_grounds = (
|
||||||
&entities,
|
&entities,
|
||||||
scales.maybe(),
|
scales.maybe(),
|
||||||
@ -349,6 +354,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
radius: f32,
|
radius: f32,
|
||||||
z_range: Range<f32>,
|
z_range: Range<f32>,
|
||||||
) -> impl Iterator<Item = Aabb<f32>> + 'a {
|
) -> impl Iterator<Item = Aabb<f32>> + 'a {
|
||||||
|
span!(_guard, "collision_iter");
|
||||||
near_iter.filter_map(move |(i, j, k)| {
|
near_iter.filter_map(move |(i, j, k)| {
|
||||||
let block_pos = pos.map(|e| e.floor() as i32) + Vec3::new(i, j, k);
|
let block_pos = pos.map(|e| e.floor() as i32) + Vec3::new(i, j, k);
|
||||||
|
|
||||||
@ -648,6 +654,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
land_on_grounds_a.append(&mut land_on_grounds_b);
|
land_on_grounds_a.append(&mut land_on_grounds_b);
|
||||||
land_on_grounds_a
|
land_on_grounds_a
|
||||||
});
|
});
|
||||||
|
drop(guard);
|
||||||
|
|
||||||
land_on_grounds.into_iter().for_each(|(entity, vel)| {
|
land_on_grounds.into_iter().for_each(|(entity, vel)| {
|
||||||
event_emitter.emit(ServerEvent::LandOnGround { entity, vel: vel.0 });
|
event_emitter.emit(ServerEvent::LandOnGround { entity, vel: vel.0 });
|
||||||
|
@ -4,6 +4,7 @@ use crate::{
|
|||||||
Loadout, Ori, PhysicsState, Pos, Projectile, Vel,
|
Loadout, Ori, PhysicsState, Pos, Projectile, Vel,
|
||||||
},
|
},
|
||||||
event::{EventBus, LocalEvent, ServerEvent},
|
event::{EventBus, LocalEvent, ServerEvent},
|
||||||
|
span,
|
||||||
state::DeltaTime,
|
state::DeltaTime,
|
||||||
sync::UidAllocator,
|
sync::UidAllocator,
|
||||||
util::Dir,
|
util::Dir,
|
||||||
@ -48,6 +49,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
loadouts,
|
loadouts,
|
||||||
): Self::SystemData,
|
): Self::SystemData,
|
||||||
) {
|
) {
|
||||||
|
span!(_guard, "projectile::Sys::run");
|
||||||
let mut local_emitter = local_bus.emitter();
|
let mut local_emitter = local_bus.emitter();
|
||||||
let mut server_emitter = server_bus.emitter();
|
let mut server_emitter = server_bus.emitter();
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
comp::{CharacterState, Energy, EnergySource, HealthSource, Stats},
|
comp::{CharacterState, Energy, EnergySource, HealthSource, Stats},
|
||||||
event::{EventBus, ServerEvent},
|
event::{EventBus, ServerEvent},
|
||||||
|
span,
|
||||||
state::DeltaTime,
|
state::DeltaTime,
|
||||||
};
|
};
|
||||||
use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage};
|
use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage};
|
||||||
@ -24,6 +25,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
&mut self,
|
&mut self,
|
||||||
(entities, dt, server_event_bus, character_states, mut stats, mut energies): Self::SystemData,
|
(entities, dt, server_event_bus, character_states, mut stats, mut energies): Self::SystemData,
|
||||||
) {
|
) {
|
||||||
|
span!(_guard, "stats::Sys::run");
|
||||||
let mut server_event_emitter = server_event_bus.emitter();
|
let mut server_event_emitter = server_event_bus.emitter();
|
||||||
|
|
||||||
// Increment last change timer
|
// Increment last change timer
|
||||||
|
@ -242,7 +242,7 @@ impl<'a, V: RectRasterableVol<Vox = Block> + ReadVol + Debug>
|
|||||||
self,
|
self,
|
||||||
(range, max_texture_size): Self::Supplement,
|
(range, max_texture_size): Self::Supplement,
|
||||||
) -> MeshGen<TerrainPipeline, FluidPipeline, Self> {
|
) -> MeshGen<TerrainPipeline, FluidPipeline, Self> {
|
||||||
span!(_guard, "<&VolGrid2d as Meshable<_, _>::generate_mesh");
|
span!(_guard, "<&VolGrid2d as Meshable<_, _>>::generate_mesh");
|
||||||
// Find blocks that should glow
|
// Find blocks that should glow
|
||||||
// FIXME: Replace with real lit blocks when we actually have blocks that glow.
|
// FIXME: Replace with real lit blocks when we actually have blocks that glow.
|
||||||
let lit_blocks = core::iter::empty();
|
let lit_blocks = core::iter::empty();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user