mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
cargo fmt after updating new toolchain
This commit is contained in:
parent
cb25a409d5
commit
8e95cb944d
@ -1809,18 +1809,16 @@ impl Client {
|
||||
// significant changes to this code. Here is the approximate order of
|
||||
// things. Please update it as this code changes.
|
||||
//
|
||||
// 1) Collect input from the frontend, apply input effects to the state
|
||||
// of the game
|
||||
// 1) Collect input from the frontend, apply input effects to the state of the
|
||||
// game
|
||||
// 2) Handle messages from the server
|
||||
// 3) Go through any events (timer-driven or otherwise) that need handling
|
||||
// and apply them to the state of the game
|
||||
// 4) Perform a single LocalState tick (i.e: update the world and entities
|
||||
// in the world)
|
||||
// 5) Go through the terrain update queue and apply all changes
|
||||
// to the terrain
|
||||
// 3) Go through any events (timer-driven or otherwise) that need handling and
|
||||
// apply them to the state of the game
|
||||
// 4) Perform a single LocalState tick (i.e: update the world and entities in
|
||||
// the world)
|
||||
// 5) Go through the terrain update queue and apply all changes to the terrain
|
||||
// 6) Sync information to the server
|
||||
// 7) Finish the tick, passing actions of the main thread back
|
||||
// to the frontend
|
||||
// 7) Finish the tick, passing actions of the main thread back to the frontend
|
||||
|
||||
// 1) Handle input from frontend.
|
||||
// Pass character actions from frontend input to the player's entity.
|
||||
|
@ -118,14 +118,17 @@ pub fn members<'a>(
|
||||
) -> impl Iterator<Item = (specs::Entity, Role)> + 'a {
|
||||
(entities, groups, alignments, uids)
|
||||
.join()
|
||||
.filter(move |&(_e, g, _a, _u)| (*g == group)).map(|(e, _g, a, u)| (
|
||||
.filter(move |&(_e, g, _a, _u)| (*g == group))
|
||||
.map(|(e, _g, a, u)| {
|
||||
(
|
||||
e,
|
||||
if matches!(a, Alignment::Owned(owner) if owner != u) {
|
||||
Role::Pet
|
||||
} else {
|
||||
Role::Member
|
||||
},
|
||||
))
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
// TODO: optimize add/remove for massive NPC groups
|
||||
|
@ -121,16 +121,8 @@ impl Hands {
|
||||
Hands::InHands((mainhand, offhand)) => {
|
||||
let mut from_spec = |i: &ItemSpec| i.try_to_item(rng);
|
||||
|
||||
let mainhand = mainhand
|
||||
.as_ref()
|
||||
.map(&mut from_spec)
|
||||
.transpose()?
|
||||
.flatten();
|
||||
let offhand = offhand
|
||||
.as_ref()
|
||||
.map(&mut from_spec)
|
||||
.transpose()?
|
||||
.flatten();
|
||||
let mainhand = mainhand.as_ref().map(&mut from_spec).transpose()?.flatten();
|
||||
let offhand = offhand.as_ref().map(&mut from_spec).transpose()?.flatten();
|
||||
Ok((mainhand, offhand))
|
||||
},
|
||||
Hands::Choice(pairs) => {
|
||||
|
@ -133,8 +133,12 @@ pub fn distribute_many<T: Copy + Eq + Hash, I>(
|
||||
|
||||
let Some(mut give) = participants
|
||||
.iter()
|
||||
.map(|participant| (total_item_amount as f32 * participant.weight / total_weight).ceil() as u32 - participant.recieved_count)
|
||||
.min() else {
|
||||
.map(|participant| {
|
||||
(total_item_amount as f32 * participant.weight / total_weight).ceil() as u32
|
||||
- participant.recieved_count
|
||||
})
|
||||
.min()
|
||||
else {
|
||||
tracing::error!("Tried to distribute items to no participants.");
|
||||
return;
|
||||
};
|
||||
@ -152,8 +156,7 @@ pub fn distribute_many<T: Copy + Eq + Hash, I>(
|
||||
|
||||
let participant_count = participants.len();
|
||||
|
||||
let Some(winner) = participants
|
||||
.get_mut(index) else {
|
||||
let Some(winner) = participants.get_mut(index) else {
|
||||
tracing::error!("Tried to distribute items to no participants.");
|
||||
return;
|
||||
};
|
||||
|
@ -381,7 +381,8 @@ impl Link for VolumeMounting {
|
||||
Volume::Entity(uid) => {
|
||||
let Some(riders) = entity(uid)
|
||||
.filter(|entity| is_alive(*entity))
|
||||
.and_then(|entity| volume_riders.get(entity)) else {
|
||||
.and_then(|entity| volume_riders.get(entity))
|
||||
else {
|
||||
return false;
|
||||
};
|
||||
riders
|
||||
|
@ -86,10 +86,10 @@ impl<V, S: VolSize, M> Chunk<V, S, M> {
|
||||
//
|
||||
// Rationales:
|
||||
//
|
||||
// 1. We have code in the implementation that assumes it. In particular,
|
||||
// code using `.count_ones()`.
|
||||
// 2. The maximum group size is `256x256x256`, because there's code that
|
||||
// stores group relative indices as `u8`.
|
||||
// 1. We have code in the implementation that assumes it. In particular, code
|
||||
// using `.count_ones()`.
|
||||
// 2. The maximum group size is `256x256x256`, because there's code that stores
|
||||
// group relative indices as `u8`.
|
||||
// 3. There's code that stores group indices as `u8`.
|
||||
debug_assert!(S::SIZE.x.is_power_of_two());
|
||||
debug_assert!(S::SIZE.y.is_power_of_two());
|
||||
|
@ -84,7 +84,9 @@ pub(crate) fn wasi_fd_write(
|
||||
let Ok(cio) = iov_addr
|
||||
.add_offset(i)
|
||||
.and_then(|p| p.read(&memory.view(&store)))
|
||||
else { return Errno::Memviolation as i32; };
|
||||
else {
|
||||
return Errno::Memviolation as i32;
|
||||
};
|
||||
if let Err(e) = print_impl(env.data(), &store, cio.buf, cio.buf_len) {
|
||||
return e as i32;
|
||||
}
|
||||
|
@ -53,27 +53,35 @@ impl<'a> System<'a> for Sys {
|
||||
// For each mount...
|
||||
for (entity, is_mount, body) in (&entities, &is_mounts, bodies.maybe()).join() {
|
||||
// ...find the rider...
|
||||
let Some((inputs_and_actions, rider)) = id_maps
|
||||
.uid_entity(is_mount.rider)
|
||||
.and_then(|rider| {
|
||||
controllers
|
||||
.get_mut(rider)
|
||||
.map(|c| (
|
||||
// Only take inputs and actions from the rider if the mount is not intelligent (TODO: expand the definition of 'intelligent').
|
||||
let Some((inputs_and_actions, rider)) =
|
||||
id_maps.uid_entity(is_mount.rider).and_then(|rider| {
|
||||
controllers.get_mut(rider).map(|c| {
|
||||
(
|
||||
// Only take inputs and actions from the rider if the mount is not
|
||||
// intelligent (TODO: expand the definition of 'intelligent').
|
||||
if !matches!(body, Some(Body::Humanoid(_))) {
|
||||
let actions = c.actions.extract_if(|action| match action {
|
||||
let actions = c
|
||||
.actions
|
||||
.extract_if(|action| match action {
|
||||
ControlAction::StartInput { input: i, .. }
|
||||
| ControlAction::CancelInput(i) => matches!(i, InputKind::Jump | InputKind::Fly | InputKind::Roll),
|
||||
_ => false
|
||||
}).collect();
|
||||
| ControlAction::CancelInput(i) => matches!(
|
||||
i,
|
||||
InputKind::Jump | InputKind::Fly | InputKind::Roll
|
||||
),
|
||||
_ => false,
|
||||
})
|
||||
.collect();
|
||||
Some((c.inputs.clone(), actions))
|
||||
} else {
|
||||
None
|
||||
},
|
||||
rider,
|
||||
))
|
||||
)
|
||||
})
|
||||
else { continue };
|
||||
})
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
|
||||
// ...apply the mount's position/ori/velocity to the rider...
|
||||
let pos = positions.get(entity).copied();
|
||||
|
@ -94,7 +94,9 @@ impl Data {
|
||||
.faction
|
||||
.and_then(|f| this.factions.get(f))
|
||||
.map(|f| f.good_or_evil)
|
||||
else { continue };
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let rand_wpos = |rng: &mut SmallRng, matches_plot: fn(&PlotKind) -> bool| {
|
||||
let wpos2d = site2
|
||||
@ -257,18 +259,23 @@ impl Data {
|
||||
let Some(species) = [
|
||||
Some(comp::body::biped_large::Species::Ogre),
|
||||
Some(comp::body::biped_large::Species::Cyclops),
|
||||
Some(comp::body::biped_large::Species::Wendigo).filter(|_| biome == BiomeKind::Taiga),
|
||||
Some(comp::body::biped_large::Species::Wendigo)
|
||||
.filter(|_| biome == BiomeKind::Taiga),
|
||||
Some(comp::body::biped_large::Species::Cavetroll),
|
||||
Some(comp::body::biped_large::Species::Mountaintroll).filter(|_| biome == BiomeKind::Mountain),
|
||||
Some(comp::body::biped_large::Species::Swamptroll).filter(|_| biome == BiomeKind::Swamp),
|
||||
Some(comp::body::biped_large::Species::Mountaintroll)
|
||||
.filter(|_| biome == BiomeKind::Mountain),
|
||||
Some(comp::body::biped_large::Species::Swamptroll)
|
||||
.filter(|_| biome == BiomeKind::Swamp),
|
||||
Some(comp::body::biped_large::Species::Blueoni),
|
||||
Some(comp::body::biped_large::Species::Redoni),
|
||||
Some(comp::body::biped_large::Species::Tursus).filter(|_| chunk.temp < CONFIG.snow_temp),
|
||||
Some(comp::body::biped_large::Species::Tursus)
|
||||
.filter(|_| chunk.temp < CONFIG.snow_temp),
|
||||
]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.choose(&mut rng)
|
||||
else { continue };
|
||||
.choose(&mut rng) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
this.npcs.create_npc(Npc::new(
|
||||
rng.gen(),
|
||||
|
@ -2924,7 +2924,8 @@ impl<'a> AgentData<'a> {
|
||||
{
|
||||
agent.action_state.counters[FCounters::SummonThreshold as usize] -=
|
||||
SUMMON_THRESHOLD;
|
||||
agent.action_state.conditions[Conditions::AttackToggle as usize] = !agent.action_state.conditions[Conditions::AttackToggle as usize];
|
||||
agent.action_state.conditions[Conditions::AttackToggle as usize] =
|
||||
!agent.action_state.conditions[Conditions::AttackToggle as usize];
|
||||
}
|
||||
} else {
|
||||
// If target is in melee range use flamecrush
|
||||
|
@ -4,13 +4,7 @@
|
||||
clippy::needless_pass_by_ref_mut //until we find a better way for specs
|
||||
)]
|
||||
#![deny(clippy::clone_on_ref_ptr)]
|
||||
#![feature(
|
||||
box_patterns,
|
||||
let_chains,
|
||||
never_type,
|
||||
option_zip,
|
||||
unwrap_infallible
|
||||
)]
|
||||
#![feature(box_patterns, let_chains, never_type, option_zip, unwrap_infallible)]
|
||||
|
||||
pub mod automod;
|
||||
mod character_creator;
|
||||
@ -711,22 +705,20 @@ impl Server {
|
||||
// significant changes to this code. Here is the approximate order of
|
||||
// things. Please update it as this code changes.
|
||||
//
|
||||
// 1) Collect input from the frontend, apply input effects to the
|
||||
// state of the game
|
||||
// 2) Go through any events (timer-driven or otherwise) that need handling
|
||||
// and apply them to the state of the game
|
||||
// 3) Go through all incoming client network communications, apply them to
|
||||
// the game state
|
||||
// 4) Perform a single LocalState tick (i.e: update the world and entities
|
||||
// in the world)
|
||||
// 5) Go through the terrain update queue and apply all changes to
|
||||
// the terrain
|
||||
// 1) Collect input from the frontend, apply input effects to the state of the
|
||||
// game
|
||||
// 2) Go through any events (timer-driven or otherwise) that need handling and
|
||||
// apply them to the state of the game
|
||||
// 3) Go through all incoming client network communications, apply them to the
|
||||
// game state
|
||||
// 4) Perform a single LocalState tick (i.e: update the world and entities in
|
||||
// the world)
|
||||
// 5) Go through the terrain update queue and apply all changes to the terrain
|
||||
// 6) Send relevant state updates to all clients
|
||||
// 7) Check for persistence updates related to character data, and message the
|
||||
// relevant entities
|
||||
// 8) Update Metrics with current data
|
||||
// 9) Finish the tick, passing control of the main thread back
|
||||
// to the frontend
|
||||
// 9) Finish the tick, passing control of the main thread back to the frontend
|
||||
|
||||
// 1) Build up a list of events for this frame, to be passed to the frontend.
|
||||
let mut frontend_events = Vec::new();
|
||||
|
@ -875,8 +875,12 @@ impl StateExt for State {
|
||||
let mut automod = self.ecs().write_resource::<AutoMod>();
|
||||
let client = self.ecs().read_storage::<Client>();
|
||||
let player = self.ecs().read_storage::<Player>();
|
||||
let Some(client) = client.get(entity) else { return true };
|
||||
let Some(player) = player.get(entity) else { return true };
|
||||
let Some(client) = client.get(entity) else {
|
||||
return true;
|
||||
};
|
||||
let Some(player) = player.get(entity) else {
|
||||
return true;
|
||||
};
|
||||
|
||||
match automod.validate_chat_msg(
|
||||
player.uuid(),
|
||||
|
@ -885,11 +885,7 @@ fn remembers_fight_with(
|
||||
// read_data: &ReadData,
|
||||
// agent: &mut Agent,
|
||||
// target: EcsEntity,
|
||||
// ) {
|
||||
// rtsim_entity.is_some().then(|| {
|
||||
// read_data
|
||||
// .stats
|
||||
// .get(target)
|
||||
// ) { rtsim_entity.is_some().then(|| { read_data .stats .get(target)
|
||||
// .map(|stats| agent.add_fight_to_memory(&stats.name,
|
||||
// read_data.time.0)) });
|
||||
// }
|
||||
|
@ -61,8 +61,8 @@ impl<'a> System<'a> for Sys {
|
||||
// To update subscriptions
|
||||
// 1. Iterate through clients
|
||||
// 2. Calculate current chunk position
|
||||
// 3. If chunk is different (use fuzziness) or the client view distance
|
||||
// has changed continue, otherwise return
|
||||
// 3. If chunk is different (use fuzziness) or the client view distance has
|
||||
// changed continue, otherwise return
|
||||
// 4. Iterate through subscribed regions
|
||||
// 5. Check if region is still in range (use fuzziness)
|
||||
// 6. If not in range
|
||||
|
@ -83,11 +83,14 @@ impl<'a> System<'a> for Sys {
|
||||
.join()
|
||||
{
|
||||
let portal_pos = positions.get(teleporting.portal);
|
||||
let Some(Object::Portal { target, requires_no_aggro, .. }) = objects
|
||||
.get(teleporting.portal)
|
||||
let Some(Object::Portal {
|
||||
target,
|
||||
requires_no_aggro,
|
||||
..
|
||||
}) = objects.get(teleporting.portal)
|
||||
else {
|
||||
cancel_teleporting.push(entity);
|
||||
continue
|
||||
continue;
|
||||
};
|
||||
|
||||
if portal_pos.map_or(true, |portal_pos| {
|
||||
|
@ -1487,9 +1487,7 @@ impl<'a> Widget for Crafting<'a> {
|
||||
});
|
||||
}
|
||||
|
||||
let can_perform = repair_slot
|
||||
.item(self.inventory)
|
||||
.map_or(false, can_repair);
|
||||
let can_perform = repair_slot.item(self.inventory).map_or(false, can_repair);
|
||||
|
||||
(repair_slot.slot, None, can_perform)
|
||||
},
|
||||
|
@ -515,9 +515,7 @@ impl BuffIconKind {
|
||||
}
|
||||
|
||||
impl PartialOrd for BuffIconKind {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> { Some(self.cmp(other)) }
|
||||
}
|
||||
|
||||
impl Ord for BuffIconKind {
|
||||
|
@ -39,7 +39,11 @@ impl Add<Vertex> for Vertex {
|
||||
|
||||
fn add(self, other: Self) -> Self::Output {
|
||||
Self {
|
||||
pos: [self.pos[0] + other.pos[0], self.pos[1] + other.pos[1], self.pos[2] + other.pos[2]],
|
||||
pos: [
|
||||
self.pos[0] + other.pos[0],
|
||||
self.pos[1] + other.pos[1],
|
||||
self.pos[2] + other.pos[2],
|
||||
],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1484,27 +1484,13 @@ impl Renderer {
|
||||
// _bones: &Consts<figure::BoneData>,
|
||||
// _lod: &lod_terrain::LodData,
|
||||
// _locals: &Consts<shadow::Locals>,
|
||||
// ) {
|
||||
// // FIXME: Consider reenabling at some point.
|
||||
// /* let (point_shadow_maps, directed_shadow_maps) =
|
||||
// if let Some(shadow_map) = &mut self.shadow_map {
|
||||
// (
|
||||
// (
|
||||
// shadow_map.point_res.clone(),
|
||||
// shadow_map.point_sampler.clone(),
|
||||
// ),
|
||||
// (
|
||||
// shadow_map.directed_res.clone(),
|
||||
// shadow_map.directed_sampler.clone(),
|
||||
// ),
|
||||
// )
|
||||
// } else {
|
||||
// (
|
||||
// (self.noise_tex.srv.clone(), self.noise_tex.sampler.clone()),
|
||||
// (self.noise_tex.srv.clone(), self.noise_tex.sampler.clone()),
|
||||
// )
|
||||
// };
|
||||
// let model = &model.opaque;
|
||||
// ) { // FIXME: Consider reenabling at some point. /* let (point_shadow_maps,
|
||||
// directed_shadow_maps) = if let Some(shadow_map) = &mut self.shadow_map { (
|
||||
// ( shadow_map.point_res.clone(), shadow_map.point_sampler.clone(), ), (
|
||||
// shadow_map.directed_res.clone(), shadow_map.directed_sampler.clone(), ), )
|
||||
// } else { ( (self.noise_tex.srv.clone(), self.noise_tex.sampler.clone()),
|
||||
// (self.noise_tex.srv.clone(), self.noise_tex.sampler.clone()), ) }; let
|
||||
// model = &model.opaque;
|
||||
|
||||
// self.encoder.draw(
|
||||
// &gfx::Slice {
|
||||
|
@ -445,7 +445,9 @@ impl<'frame> Drawer<'frame> {
|
||||
/// pending uploads.
|
||||
fn run_ui_premultiply_passes(&mut self) {
|
||||
prof_span!("run_ui_premultiply_passes");
|
||||
let Some(premultiply_alpha) = self.borrow.pipelines.premultiply_alpha() else { return };
|
||||
let Some(premultiply_alpha) = self.borrow.pipelines.premultiply_alpha() else {
|
||||
return;
|
||||
};
|
||||
let encoder = self.encoder.as_mut().unwrap();
|
||||
let device = self.borrow.device;
|
||||
|
||||
|
@ -59,7 +59,7 @@ impl Interactable {
|
||||
volume_pos: VolumePos,
|
||||
interaction: Interaction,
|
||||
) -> Option<Self> {
|
||||
let block= volume_pos.get_block(terrain, id_maps, colliders)?;
|
||||
let block = volume_pos.get_block(terrain, id_maps, colliders)?;
|
||||
let block_interaction = match interaction {
|
||||
Interaction::Collect => {
|
||||
// Check if this is an unlockable sprite
|
||||
@ -114,9 +114,9 @@ impl Interactable {
|
||||
/// interact with if the interact key is pressed
|
||||
/// Selected in the following order:
|
||||
/// 1) Targeted items, in order of nearest under cursor:
|
||||
/// (a) entity (if within range)
|
||||
/// (b) collectable
|
||||
/// (c) can be mined, and is a mine sprite (Air) not a weak rock.
|
||||
/// a) entity (if within range)
|
||||
/// b) collectable
|
||||
/// c) can be mined, and is a mine sprite (Air) not a weak rock.
|
||||
/// 2) outside of targeted cam ray
|
||||
/// -> closest of nearest interactable entity/block
|
||||
pub(super) fn select_interactable(
|
||||
|
@ -196,10 +196,7 @@ fn palette(conn: Connection) -> Result<(), Box<dyn Error>> {
|
||||
let kind = BlockKind::from_str(&row.get::<_, String>(0)?)?;
|
||||
let rgb: Rgb<u8> = Rgb::new(row.get(1)?, row.get(2)?, row.get(3)?);
|
||||
let count: i64 = row.get(4)?;
|
||||
block_colors
|
||||
.entry(kind)
|
||||
.or_default()
|
||||
.push((rgb, count));
|
||||
block_colors.entry(kind).or_default().push((rgb, count));
|
||||
}
|
||||
for (_, v) in block_colors.iter_mut() {
|
||||
v.sort_by(|a, b| b.1.cmp(&a.1));
|
||||
|
@ -1569,7 +1569,9 @@ fn walk_in_all_dirs(
|
||||
|
||||
let adjacents = NEIGHBORS.map(|dir| a + dir);
|
||||
|
||||
let Some(a_chunk) = sim.get(a) else { return potential };
|
||||
let Some(a_chunk) = sim.get(a) else {
|
||||
return potential;
|
||||
};
|
||||
let mut chunks = [None; 8];
|
||||
for i in 0..8 {
|
||||
if loc_suitable_for_walking(sim, adjacents[i]) {
|
||||
|
@ -145,7 +145,9 @@ impl Tunnel {
|
||||
}
|
||||
|
||||
fn biome_at(&self, wpos: Vec3<i32>, info: &CanvasInfo) -> Biome {
|
||||
let Some(col) = info.col_or_gen(wpos.xy()) else { return Biome::default() };
|
||||
let Some(col) = info.col_or_gen(wpos.xy()) else {
|
||||
return Biome::default();
|
||||
};
|
||||
|
||||
// Below the ground
|
||||
let below = ((col.alt - wpos.z as f32) / 120.0).clamped(0.0, 1.0);
|
||||
|
@ -636,31 +636,31 @@ impl m32 {
|
||||
///
|
||||
/// This algorithm does this in four steps:
|
||||
///
|
||||
/// 1. Sort the nodes in h by height (so the lowest node by altitude is first
|
||||
/// in the list, and the highest node by altitude is last).
|
||||
/// 1. Sort the nodes in h by height (so the lowest node by altitude is first in
|
||||
/// the list, and the highest node by altitude is last).
|
||||
/// 2. Iterate through the list in *reverse.* For each node, we compute its
|
||||
/// drainage area as the sum of the drainage areas of its "children" nodes
|
||||
/// (i.e. the nodes with directed edges to this node). To do this
|
||||
/// efficiently, we start with the "leaves" (the highest nodes), which
|
||||
/// have no neighbors higher than them, hence no directed edges to them.
|
||||
/// We add their area to themselves, and then to all neighbors that they
|
||||
/// flow into (their "ancestors" in the flow graph); currently, this just
|
||||
/// means the node immediately downhill of this node. As we go lower, we
|
||||
/// know that all our "children" already had their areas computed, which
|
||||
/// means that we can repeat the process in order to derive all the final
|
||||
/// areas.
|
||||
/// efficiently, we start with the "leaves" (the highest nodes), which have
|
||||
/// no neighbors higher than them, hence no directed edges to them. We add
|
||||
/// their area to themselves, and then to all neighbors that they flow into
|
||||
/// (their "ancestors" in the flow graph); currently, this just means the
|
||||
/// node immediately downhill of this node. As we go lower, we know that all
|
||||
/// our "children" already had their areas computed, which means that we can
|
||||
/// repeat the process in order to derive all the final areas.
|
||||
/// 3. Now, iterate through the list in *order.* Whether we used the filling
|
||||
/// method to compute a "filled" version of each depression, or used the lake
|
||||
/// connection algorithm described in [1], each node is guaranteed to have
|
||||
/// zero or one drainage edges out, representing the direction of water flow
|
||||
/// for that node. For nodes i with zero drainage edges out (boundary nodes
|
||||
/// and lake bottoms) we set the slope to 0 (so the change in altitude is
|
||||
/// uplift(i))
|
||||
/// For nodes with at least one drainage edge out, we take advantage of the
|
||||
/// fact that we are computing new heights in order and rewrite our equation
|
||||
/// as (letting j = downhill[i], A[i] be the computed area of point i,
|
||||
/// p(i) be the x-y position of point i,
|
||||
/// flux(i) = k * A[i]^m / ((p(i) - p(j)).magnitude()), and δt = 1):
|
||||
/// uplift(i)).
|
||||
///
|
||||
/// For nodes with at least one drainage edge out, we take
|
||||
/// advantage of the fact that we are computing new heights in order and
|
||||
/// rewrite our equation as (letting j = downhill[i], A[i] be the computed
|
||||
/// area of point i, p(i) be the x-y position of point i, flux(i) = k *
|
||||
/// A[i]^m / ((p(i) - p(j)).magnitude()), and δt = 1):
|
||||
///
|
||||
/// h[i](t + dt) = h[i](t) + δt * (uplift[i] + flux(i) * h[j](t + δt)) / (1 +
|
||||
/// flux(i) * δt).
|
||||
|
@ -53,8 +53,8 @@ pub fn map_edge_factor(map_size_lg: MapSizeLg, posi: usize) -> f32 {
|
||||
/// At some point, we should probably contribute this back to stats-rs.
|
||||
///
|
||||
/// 1. [https://www.r-bloggers.com/sums-of-random-variables/][1],
|
||||
/// 2. Sadooghi-Alvandi, S., A. Nematollahi, & R. Habibi, 2009.
|
||||
/// On the Distribution of the Sum of Independent Uniform Random Variables.
|
||||
/// 2. Sadooghi-Alvandi, S., A. Nematollahi, & R. Habibi, 2009. On the
|
||||
/// Distribution of the Sum of Independent Uniform Random Variables.
|
||||
/// Statistical Papers, 50, 171-175.
|
||||
/// 3. [https://en.wikipedia.org/wiki/Cumulative_distribution_function][3]
|
||||
///
|
||||
|
@ -61,8 +61,9 @@ impl Citadel {
|
||||
.filter_map(|rpos| Some(grid.get(pos + rpos)?.as_ref()?.alt))
|
||||
.min()
|
||||
{
|
||||
let Some(Some(cell)) = grid.get_mut(pos)
|
||||
else { continue };
|
||||
let Some(Some(cell)) = grid.get_mut(pos) else {
|
||||
continue;
|
||||
};
|
||||
if min_alt < cell.alt {
|
||||
cell.colonade = Some(min_alt);
|
||||
}
|
||||
|
@ -294,12 +294,7 @@ impl GnarlingFortification {
|
||||
.collect::<Vec<_>>();
|
||||
let wall_segments = outer_wall_segments
|
||||
.into_iter()
|
||||
.chain(
|
||||
wall_connections
|
||||
.iter()
|
||||
.copied()
|
||||
.zip(inner_tower_locs),
|
||||
)
|
||||
.chain(wall_connections.iter().copied().zip(inner_tower_locs))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
Self {
|
||||
|
@ -1703,8 +1703,8 @@ impl Structure for House {
|
||||
//1 => {
|
||||
// painter.prim(Primitive::Aabb(Aabb {
|
||||
// min: Vec2::new(stair_origin.x, stair_origin.y
|
||||
// + 10).with_z(alt + previous_floor_height),
|
||||
// max: Vec2::new(stair_origin.x + stair_width,
|
||||
// + 10).with_z(alt + previous_floor_height), max:
|
||||
// Vec2::new(stair_origin.x + stair_width,
|
||||
// stair_origin.y + 12).with_z(alt + previous_height +
|
||||
// 1), }))
|
||||
//},
|
||||
@ -1719,8 +1719,8 @@ impl Structure for House {
|
||||
//_ => {
|
||||
// painter.prim(Primitive::Aabb(Aabb {
|
||||
// min: Vec2::new(stair_origin.x, stair_origin.y
|
||||
// + 10).with_z(alt + previous_floor_height),
|
||||
// max: Vec2::new(stair_origin.x + stair_width,
|
||||
// + 10).with_z(alt + previous_floor_height), max:
|
||||
// Vec2::new(stair_origin.x + stair_width,
|
||||
// stair_origin.y + 12).with_z(alt + previous_height +
|
||||
// 1), }))
|
||||
//},
|
||||
|
Loading…
Reference in New Issue
Block a user