mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Remove some of the spans in the agent system
This commit is contained in:
parent
110165de3a
commit
9e0fbd392d
@ -715,7 +715,6 @@ impl<'a> AgentData<'a> {
|
||||
if let Some((travel_to, _destination)) = &agent.rtsim_controller.travel_to {
|
||||
// if it has an rtsim destination and can fly then it should
|
||||
// if it is flying and bumps something above it then it should move down
|
||||
prof_span!(guard, "rayfly");
|
||||
if self.traversal_config.can_fly
|
||||
&& !read_data
|
||||
.terrain
|
||||
@ -733,7 +732,7 @@ impl<'a> AgentData<'a> {
|
||||
.actions
|
||||
.push(ControlAction::CancelInput(InputKind::Fly))
|
||||
}
|
||||
drop(guard);
|
||||
|
||||
if let Some((bearing, speed)) = agent.chaser.chase(
|
||||
&*read_data.terrain,
|
||||
self.pos.0,
|
||||
@ -753,7 +752,6 @@ impl<'a> AgentData<'a> {
|
||||
|
||||
controller.inputs.move_z = bearing.z
|
||||
+ if self.traversal_config.can_fly {
|
||||
prof_span!(guard, "rayobstacle");
|
||||
// NOTE: costs 4 us (imbris)
|
||||
let obstacle_ahead = read_data
|
||||
.terrain
|
||||
@ -767,11 +765,10 @@ impl<'a> AgentData<'a> {
|
||||
.cast()
|
||||
.1
|
||||
.map_or(true, |b| b.is_some());
|
||||
drop(guard);
|
||||
|
||||
let mut ground_too_close = self
|
||||
.body
|
||||
.map(|body| {
|
||||
prof_span!(_guard, "alt approx");
|
||||
#[cfg(feature = "worldgen")]
|
||||
let height_approx = self.pos.0.y
|
||||
- read_data
|
||||
@ -788,7 +785,6 @@ impl<'a> AgentData<'a> {
|
||||
|
||||
const NUM_RAYS: usize = 5;
|
||||
|
||||
prof_span!(guard, "rays");
|
||||
// NOTE: costs 15-20 us (imbris)
|
||||
for i in 0..=NUM_RAYS {
|
||||
let magnitude = self.body.map_or(20.0, |b| b.flying_height());
|
||||
@ -811,7 +807,6 @@ impl<'a> AgentData<'a> {
|
||||
.map_or(false, |b| b.is_some())
|
||||
}
|
||||
}
|
||||
drop(guard);
|
||||
|
||||
if obstacle_ahead || ground_too_close {
|
||||
1.0 //fly up when approaching obstacles
|
||||
@ -833,7 +828,6 @@ impl<'a> AgentData<'a> {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
prof_span!(_guard, "else");
|
||||
agent.bearing += Vec2::new(
|
||||
thread_rng().gen::<f32>() - 0.5,
|
||||
thread_rng().gen::<f32>() - 0.5,
|
||||
@ -844,7 +838,6 @@ impl<'a> AgentData<'a> {
|
||||
});
|
||||
|
||||
// Stop if we're too close to a wall
|
||||
prof_span!(guard, "wall ray");
|
||||
// NOTE: costs 1 us (imbris)
|
||||
agent.bearing *= 0.1
|
||||
+ if read_data
|
||||
@ -867,7 +860,6 @@ impl<'a> AgentData<'a> {
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
drop(guard);
|
||||
|
||||
if agent.bearing.magnitude_squared() > 0.5f32.powi(2) {
|
||||
controller.inputs.move_dir = agent.bearing * 0.65;
|
||||
|
Loading…
Reference in New Issue
Block a user