mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixed suppressed clippy warnings for #587 - useless_conversion
This commit is contained in:
parent
2b13b7d952
commit
a9be045cb8
@ -33,7 +33,6 @@ pub struct ServerMetrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TickMetrics {
|
impl TickMetrics {
|
||||||
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
|
|
||||||
pub fn new(registry: &Registry, tick: Arc<AtomicU64>) -> Result<Self, Box<dyn Error>> {
|
pub fn new(registry: &Registry, tick: Arc<AtomicU64>) -> Result<Self, Box<dyn Error>> {
|
||||||
let player_online = IntGauge::with_opts(Opts::new(
|
let player_online = IntGauge::with_opts(Opts::new(
|
||||||
"player_online",
|
"player_online",
|
||||||
@ -65,10 +64,10 @@ impl TickMetrics {
|
|||||||
"chunks_count",
|
"chunks_count",
|
||||||
"number of all chunks currently active on the server",
|
"number of all chunks currently active on the server",
|
||||||
))?;
|
))?;
|
||||||
let tick_time = IntGaugeVec::from(IntGaugeVec::new(
|
let tick_time = IntGaugeVec::new(
|
||||||
Opts::new("tick_time", "time in ns requiered for a tick of the server"),
|
Opts::new("tick_time", "time in ns requiered for a tick of the server"),
|
||||||
&["period"],
|
&["period"],
|
||||||
)?);
|
)?;
|
||||||
|
|
||||||
let since_the_epoch = SystemTime::now()
|
let since_the_epoch = SystemTime::now()
|
||||||
.duration_since(UNIX_EPOCH)
|
.duration_since(UNIX_EPOCH)
|
||||||
|
@ -9,7 +9,7 @@ impl Animation for GlideWieldAnimation {
|
|||||||
type Dependency = (Option<ToolKind>, Option<ToolKind>, Vec3<f32>, Vec3<f32>, Vec3<f32>, f64);
|
type Dependency = (Option<ToolKind>, Option<ToolKind>, Vec3<f32>, Vec3<f32>, Vec3<f32>, f64);
|
||||||
type Skeleton = CharacterSkeleton;
|
type Skeleton = CharacterSkeleton;
|
||||||
|
|
||||||
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
|
|
||||||
fn update_skeleton(
|
fn update_skeleton(
|
||||||
skeleton: &Self::Skeleton,
|
skeleton: &Self::Skeleton,
|
||||||
(_active_tool_kind, _second_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency,
|
(_active_tool_kind, _second_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency,
|
||||||
|
@ -21,7 +21,7 @@ impl Animation for ChargeAnimation {
|
|||||||
|
|
||||||
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_charge")]
|
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_charge")]
|
||||||
#[allow(clippy::approx_constant)] // TODO: Pending review in #587
|
#[allow(clippy::approx_constant)] // TODO: Pending review in #587
|
||||||
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
|
|
||||||
fn update_skeleton_inner(
|
fn update_skeleton_inner(
|
||||||
skeleton: &Self::Skeleton,
|
skeleton: &Self::Skeleton,
|
||||||
(active_tool_kind, second_tool_kind, velocity, orientation, last_ori, _global_time): Self::Dependency,
|
(active_tool_kind, second_tool_kind, velocity, orientation, last_ori, _global_time): Self::Dependency,
|
||||||
@ -60,10 +60,10 @@ impl Animation for ChargeAnimation {
|
|||||||
let stop = ((anim_time as f32).powf(0.3 as f32)).min(1.2);
|
let stop = ((anim_time as f32).powf(0.3 as f32)).min(1.2);
|
||||||
let stopa = ((anim_time as f32).powf(0.9 as f32)).min(5.0);
|
let stopa = ((anim_time as f32).powf(0.9 as f32)).min(5.0);
|
||||||
|
|
||||||
let ori = Vec2::from(orientation);
|
let ori: Vec2<f32> = Vec2::from(orientation);
|
||||||
let last_ori = Vec2::from(last_ori);
|
let last_ori = Vec2::from(last_ori);
|
||||||
let tilt = if Vec2::new(ori, last_ori)
|
let tilt = if Vec2::new(ori, last_ori)
|
||||||
.map(|o| Vec2::<f32>::from(o).magnitude_squared())
|
.map(|o| o.magnitude_squared())
|
||||||
.map(|m| m > 0.001 && m.is_finite())
|
.map(|m| m > 0.001 && m.is_finite())
|
||||||
.reduce_and()
|
.reduce_and()
|
||||||
&& ori.angle_between(last_ori).is_finite()
|
&& ori.angle_between(last_ori).is_finite()
|
||||||
|
@ -22,7 +22,7 @@ impl Animation for GlideWieldAnimation {
|
|||||||
const UPDATE_FN: &'static [u8] = b"character_glidewield\0";
|
const UPDATE_FN: &'static [u8] = b"character_glidewield\0";
|
||||||
|
|
||||||
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_glidewield")]
|
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_glidewield")]
|
||||||
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
|
|
||||||
fn update_skeleton_inner(
|
fn update_skeleton_inner(
|
||||||
skeleton: &Self::Skeleton,
|
skeleton: &Self::Skeleton,
|
||||||
(active_tool_kind, second_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency,
|
(active_tool_kind, second_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency,
|
||||||
@ -94,10 +94,10 @@ impl Animation for GlideWieldAnimation {
|
|||||||
* 0.1,
|
* 0.1,
|
||||||
);
|
);
|
||||||
|
|
||||||
let ori = Vec2::from(orientation);
|
let ori: Vec2<f32> = Vec2::from(orientation);
|
||||||
let last_ori = Vec2::from(last_ori);
|
let last_ori = Vec2::from(last_ori);
|
||||||
let tilt = if Vec2::new(ori, last_ori)
|
let tilt = if Vec2::new(ori, last_ori)
|
||||||
.map(|o| Vec2::<f32>::from(o).magnitude_squared())
|
.map(|o| o.magnitude_squared())
|
||||||
.map(|m| m > 0.001 && m.is_finite())
|
.map(|m| m > 0.001 && m.is_finite())
|
||||||
.reduce_and()
|
.reduce_and()
|
||||||
&& ori.angle_between(last_ori).is_finite()
|
&& ori.angle_between(last_ori).is_finite()
|
||||||
|
@ -22,7 +22,7 @@ impl Animation for GlidingAnimation {
|
|||||||
const UPDATE_FN: &'static [u8] = b"character_gliding\0";
|
const UPDATE_FN: &'static [u8] = b"character_gliding\0";
|
||||||
|
|
||||||
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_gliding")]
|
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_gliding")]
|
||||||
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
|
|
||||||
fn update_skeleton_inner(
|
fn update_skeleton_inner(
|
||||||
skeleton: &Self::Skeleton,
|
skeleton: &Self::Skeleton,
|
||||||
(active_tool_kind, second_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency,
|
(active_tool_kind, second_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency,
|
||||||
@ -54,10 +54,10 @@ impl Animation for GlidingAnimation {
|
|||||||
* 0.25,
|
* 0.25,
|
||||||
);
|
);
|
||||||
|
|
||||||
let ori = Vec2::from(orientation);
|
let ori: Vec2<f32> = Vec2::from(orientation);
|
||||||
let last_ori = Vec2::from(last_ori);
|
let last_ori = Vec2::from(last_ori);
|
||||||
let tilt = if Vec2::new(ori, last_ori)
|
let tilt = if Vec2::new(ori, last_ori)
|
||||||
.map(|o| Vec2::<f32>::from(o).magnitude_squared())
|
.map(|o| o.magnitude_squared())
|
||||||
.map(|m| m > 0.0001 && m.is_finite())
|
.map(|m| m > 0.0001 && m.is_finite())
|
||||||
.reduce_and()
|
.reduce_and()
|
||||||
&& ori.angle_between(last_ori).is_finite()
|
&& ori.angle_between(last_ori).is_finite()
|
||||||
|
@ -18,7 +18,7 @@ impl Animation for JumpAnimation {
|
|||||||
const UPDATE_FN: &'static [u8] = b"character_jump\0";
|
const UPDATE_FN: &'static [u8] = b"character_jump\0";
|
||||||
|
|
||||||
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_jump")]
|
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_jump")]
|
||||||
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
|
|
||||||
fn update_skeleton_inner(
|
fn update_skeleton_inner(
|
||||||
skeleton: &Self::Skeleton,
|
skeleton: &Self::Skeleton,
|
||||||
(active_tool_kind, second_tool_kind, orientation, last_ori, global_time): Self::Dependency,
|
(active_tool_kind, second_tool_kind, orientation, last_ori, global_time): Self::Dependency,
|
||||||
@ -39,10 +39,10 @@ impl Animation for JumpAnimation {
|
|||||||
|
|
||||||
let switch = if random > 0.5 { 1.0 } else { -1.0 };
|
let switch = if random > 0.5 { 1.0 } else { -1.0 };
|
||||||
|
|
||||||
let ori = Vec2::from(orientation);
|
let ori: Vec2<f32> = Vec2::from(orientation);
|
||||||
let last_ori = Vec2::from(last_ori);
|
let last_ori = Vec2::from(last_ori);
|
||||||
let tilt = if Vec2::new(ori, last_ori)
|
let tilt = if Vec2::new(ori, last_ori)
|
||||||
.map(|o| Vec2::<f32>::from(o).magnitude_squared())
|
.map(|o| o.magnitude_squared())
|
||||||
.map(|m| m > 0.001 && m.is_finite())
|
.map(|m| m > 0.001 && m.is_finite())
|
||||||
.reduce_and()
|
.reduce_and()
|
||||||
&& ori.angle_between(last_ori).is_finite()
|
&& ori.angle_between(last_ori).is_finite()
|
||||||
|
@ -19,7 +19,7 @@ impl Animation for RollAnimation {
|
|||||||
const UPDATE_FN: &'static [u8] = b"character_roll\0";
|
const UPDATE_FN: &'static [u8] = b"character_roll\0";
|
||||||
|
|
||||||
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_roll")]
|
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_roll")]
|
||||||
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
|
|
||||||
fn update_skeleton_inner(
|
fn update_skeleton_inner(
|
||||||
skeleton: &Self::Skeleton,
|
skeleton: &Self::Skeleton,
|
||||||
(active_tool_kind, second_tool_kind, orientation, last_ori, _global_time): Self::Dependency,
|
(active_tool_kind, second_tool_kind, orientation, last_ori, _global_time): Self::Dependency,
|
||||||
@ -31,10 +31,10 @@ impl Animation for RollAnimation {
|
|||||||
let mut next = (*skeleton).clone();
|
let mut next = (*skeleton).clone();
|
||||||
|
|
||||||
let spin = anim_time as f32;
|
let spin = anim_time as f32;
|
||||||
let ori = Vec2::from(orientation);
|
let ori: Vec2<f32> = Vec2::from(orientation);
|
||||||
let last_ori = Vec2::from(last_ori);
|
let last_ori = Vec2::from(last_ori);
|
||||||
let tilt = if Vec2::new(ori, last_ori)
|
let tilt = if Vec2::new(ori, last_ori)
|
||||||
.map(|o| Vec2::<f32>::from(o).magnitude_squared())
|
.map(|o| o.magnitude_squared())
|
||||||
.map(|m| m > 0.0001 && m.is_finite())
|
.map(|m| m > 0.0001 && m.is_finite())
|
||||||
.reduce_and()
|
.reduce_and()
|
||||||
&& ori.angle_between(last_ori).is_finite()
|
&& ori.angle_between(last_ori).is_finite()
|
||||||
|
@ -23,7 +23,7 @@ impl Animation for RunAnimation {
|
|||||||
const UPDATE_FN: &'static [u8] = b"character_run\0";
|
const UPDATE_FN: &'static [u8] = b"character_run\0";
|
||||||
|
|
||||||
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_run")]
|
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_run")]
|
||||||
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
|
|
||||||
fn update_skeleton_inner(
|
fn update_skeleton_inner(
|
||||||
skeleton: &Self::Skeleton,
|
skeleton: &Self::Skeleton,
|
||||||
(active_tool_kind, second_tool_kind, velocity, orientation, last_ori, global_time, avg_vel): Self::Dependency,
|
(active_tool_kind, second_tool_kind, velocity, orientation, last_ori, global_time, avg_vel): Self::Dependency,
|
||||||
@ -96,10 +96,10 @@ impl Animation for RunAnimation {
|
|||||||
* 0.1,
|
* 0.1,
|
||||||
);
|
);
|
||||||
|
|
||||||
let ori = Vec2::from(orientation);
|
let ori: Vec2<f32> = Vec2::from(orientation);
|
||||||
let last_ori = Vec2::from(last_ori);
|
let last_ori = Vec2::from(last_ori);
|
||||||
let tilt = if Vec2::new(ori, last_ori)
|
let tilt = if Vec2::new(ori, last_ori)
|
||||||
.map(|o| Vec2::<f32>::from(o).magnitude_squared())
|
.map(|o| o.magnitude_squared())
|
||||||
.map(|m| m > 0.001 && m.is_finite())
|
.map(|m| m > 0.001 && m.is_finite())
|
||||||
.reduce_and()
|
.reduce_and()
|
||||||
&& ori.angle_between(last_ori).is_finite()
|
&& ori.angle_between(last_ori).is_finite()
|
||||||
|
@ -22,7 +22,7 @@ impl Animation for SwimAnimation {
|
|||||||
const UPDATE_FN: &'static [u8] = b"character_swim\0";
|
const UPDATE_FN: &'static [u8] = b"character_swim\0";
|
||||||
|
|
||||||
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_swim")]
|
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_swim")]
|
||||||
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
|
|
||||||
fn update_skeleton_inner(
|
fn update_skeleton_inner(
|
||||||
skeleton: &Self::Skeleton,
|
skeleton: &Self::Skeleton,
|
||||||
(active_tool_kind, second_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency,
|
(active_tool_kind, second_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency,
|
||||||
@ -57,10 +57,10 @@ impl Animation for SwimAnimation {
|
|||||||
.sin()
|
.sin()
|
||||||
* 0.1,
|
* 0.1,
|
||||||
);
|
);
|
||||||
let ori = Vec2::from(orientation);
|
let ori: Vec2<f32> = Vec2::from(orientation);
|
||||||
let last_ori = Vec2::from(last_ori);
|
let last_ori = Vec2::from(last_ori);
|
||||||
let tilt = if Vec2::new(ori, last_ori)
|
let tilt = if Vec2::new(ori, last_ori)
|
||||||
.map(|o| Vec2::<f32>::from(o).magnitude_squared())
|
.map(|o| o.magnitude_squared())
|
||||||
.map(|m| m > 0.001 && m.is_finite())
|
.map(|m| m > 0.001 && m.is_finite())
|
||||||
.reduce_and()
|
.reduce_and()
|
||||||
&& ori.angle_between(last_ori).is_finite()
|
&& ori.angle_between(last_ori).is_finite()
|
||||||
|
@ -11,7 +11,6 @@ impl Animation for RunAnimation {
|
|||||||
#[cfg(feature = "use-dyn-lib")]
|
#[cfg(feature = "use-dyn-lib")]
|
||||||
const UPDATE_FN: &'static [u8] = b"quadruped_low_run\0";
|
const UPDATE_FN: &'static [u8] = b"quadruped_low_run\0";
|
||||||
|
|
||||||
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
|
|
||||||
#[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_low_run")]
|
#[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_low_run")]
|
||||||
fn update_skeleton_inner(
|
fn update_skeleton_inner(
|
||||||
skeleton: &Self::Skeleton,
|
skeleton: &Self::Skeleton,
|
||||||
@ -71,10 +70,10 @@ impl Animation for RunAnimation {
|
|||||||
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.05).sin());
|
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.05).sin());
|
||||||
let footvertrb = (anim_time as f32 * 16.0 * lab as f32 + PI * 0.6).sin();
|
let footvertrb = (anim_time as f32 * 16.0 * lab as f32 + PI * 0.6).sin();
|
||||||
|
|
||||||
let ori = Vec2::from(orientation);
|
let ori: Vec2<f32> = Vec2::from(orientation);
|
||||||
let last_ori = Vec2::from(last_ori);
|
let last_ori = Vec2::from(last_ori);
|
||||||
let tilt = if Vec2::new(ori, last_ori)
|
let tilt = if Vec2::new(ori, last_ori)
|
||||||
.map(|o| Vec2::<f32>::from(o).magnitude_squared())
|
.map(|o| o.magnitude_squared())
|
||||||
.map(|m| m > 0.001 && m.is_finite())
|
.map(|m| m > 0.001 && m.is_finite())
|
||||||
.reduce_and()
|
.reduce_and()
|
||||||
&& ori.angle_between(last_ori).is_finite()
|
&& ori.angle_between(last_ori).is_finite()
|
||||||
|
@ -11,7 +11,6 @@ impl Animation for RunAnimation {
|
|||||||
#[cfg(feature = "use-dyn-lib")]
|
#[cfg(feature = "use-dyn-lib")]
|
||||||
const UPDATE_FN: &'static [u8] = b"quadruped_medium_run\0";
|
const UPDATE_FN: &'static [u8] = b"quadruped_medium_run\0";
|
||||||
|
|
||||||
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
|
|
||||||
#[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_medium_run")]
|
#[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_medium_run")]
|
||||||
fn update_skeleton_inner(
|
fn update_skeleton_inner(
|
||||||
skeleton: &Self::Skeleton,
|
skeleton: &Self::Skeleton,
|
||||||
@ -58,10 +57,10 @@ impl Animation for RunAnimation {
|
|||||||
let footvertaltfslow = (anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 1.8).sin();
|
let footvertaltfslow = (anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 1.8).sin();
|
||||||
let footverttaltfslow = (anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 2.2).sin();
|
let footverttaltfslow = (anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 2.2).sin();
|
||||||
//
|
//
|
||||||
let ori = Vec2::from(orientation);
|
let ori: Vec2<f32> = Vec2::from(orientation);
|
||||||
let last_ori = Vec2::from(last_ori);
|
let last_ori = Vec2::from(last_ori);
|
||||||
let tilt = if Vec2::new(ori, last_ori)
|
let tilt = if Vec2::new(ori, last_ori)
|
||||||
.map(|o| Vec2::<f32>::from(o).magnitude_squared())
|
.map(|o| o.magnitude_squared())
|
||||||
.map(|m| m > 0.001 && m.is_finite())
|
.map(|m| m > 0.001 && m.is_finite())
|
||||||
.reduce_and()
|
.reduce_and()
|
||||||
&& ori.angle_between(last_ori).is_finite()
|
&& ori.angle_between(last_ori).is_finite()
|
||||||
|
@ -17,11 +17,10 @@ impl From<gfx::PipelineStateError<String>> for RenderError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl From<gfx::PipelineStateError<&str>> for RenderError {
|
impl From<gfx::PipelineStateError<&str>> for RenderError {
|
||||||
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
|
|
||||||
fn from(err: gfx::PipelineStateError<&str>) -> Self {
|
fn from(err: gfx::PipelineStateError<&str>) -> Self {
|
||||||
match err {
|
match err {
|
||||||
gfx::PipelineStateError::DescriptorInit(err) => {
|
gfx::PipelineStateError::DescriptorInit(err) => {
|
||||||
gfx::PipelineStateError::DescriptorInit(err.into())
|
gfx::PipelineStateError::DescriptorInit(err)
|
||||||
},
|
},
|
||||||
err => err,
|
err => err,
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,6 @@ impl<'a, R: Rng> GenCtx<'a, R> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Civs {
|
impl Civs {
|
||||||
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
|
|
||||||
pub fn generate(seed: u32, sim: &mut WorldSim) -> Self {
|
pub fn generate(seed: u32, sim: &mut WorldSim) -> Self {
|
||||||
let mut this = Self::default();
|
let mut this = Self::default();
|
||||||
let rng = ChaChaRng::from_seed(seed_expan::rng_state(seed));
|
let rng = ChaChaRng::from_seed(seed_expan::rng_state(seed));
|
||||||
@ -120,7 +119,7 @@ impl Civs {
|
|||||||
for site in this.sites.iter() {
|
for site in this.sites.iter() {
|
||||||
let radius = 48i32;
|
let radius = 48i32;
|
||||||
|
|
||||||
let wpos = site.center * Vec2::from(TerrainChunkSize::RECT_SIZE).map(|e: u32| e as i32);
|
let wpos = site.center * TerrainChunkSize::RECT_SIZE.map(|e: u32| e as i32);
|
||||||
|
|
||||||
let flatten_radius = match &site.kind {
|
let flatten_radius = match &site.kind {
|
||||||
SiteKind::Settlement => 10.0,
|
SiteKind::Settlement => 10.0,
|
||||||
@ -164,9 +163,7 @@ impl Civs {
|
|||||||
let mut cnt = 0;
|
let mut cnt = 0;
|
||||||
for site in this.sites.iter() {
|
for site in this.sites.iter() {
|
||||||
cnt += 1;
|
cnt += 1;
|
||||||
let wpos = site
|
let wpos = site.center.map2(TerrainChunkSize::RECT_SIZE, |e, sz: u32| {
|
||||||
.center
|
|
||||||
.map2(Vec2::from(TerrainChunkSize::RECT_SIZE), |e, sz: u32| {
|
|
||||||
e * sz as i32 + sz as i32 / 2
|
e * sz as i32 + sz as i32 / 2
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -64,7 +64,6 @@ impl World {
|
|||||||
|
|
||||||
pub fn sample_blocks(&self) -> BlockGen { BlockGen::new(ColumnGen::new(&self.sim)) }
|
pub fn sample_blocks(&self) -> BlockGen { BlockGen::new(ColumnGen::new(&self.sim)) }
|
||||||
|
|
||||||
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
|
|
||||||
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
||||||
pub fn generate_chunk(
|
pub fn generate_chunk(
|
||||||
&self,
|
&self,
|
||||||
@ -74,7 +73,7 @@ impl World {
|
|||||||
) -> Result<(TerrainChunk, ChunkSupplement), ()> {
|
) -> Result<(TerrainChunk, ChunkSupplement), ()> {
|
||||||
let mut sampler = self.sample_blocks();
|
let mut sampler = self.sample_blocks();
|
||||||
|
|
||||||
let chunk_wpos2d = Vec2::from(chunk_pos) * TerrainChunkSize::RECT_SIZE.map(|e| e as i32);
|
let chunk_wpos2d = chunk_pos * TerrainChunkSize::RECT_SIZE.map(|e| e as i32);
|
||||||
let grid_border = 4;
|
let grid_border = 4;
|
||||||
let zcache_grid = Grid::populate_from(
|
let zcache_grid = Grid::populate_from(
|
||||||
TerrainChunkSize::RECT_SIZE.map(|e| e as i32) + grid_border * 2,
|
TerrainChunkSize::RECT_SIZE.map(|e| e as i32) + grid_border * 2,
|
||||||
|
@ -109,7 +109,6 @@ impl MapConfig {
|
|||||||
/// to the caller to provide a function that translates this information
|
/// to the caller to provide a function that translates this information
|
||||||
/// into the correct format for a buffer and writes to it.
|
/// into the correct format for a buffer and writes to it.
|
||||||
#[allow(clippy::if_same_then_else)] // TODO: Pending review in #587
|
#[allow(clippy::if_same_then_else)] // TODO: Pending review in #587
|
||||||
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
|
|
||||||
#[allow(clippy::unnested_or_patterns)] // TODO: Pending review in #587
|
#[allow(clippy::unnested_or_patterns)] // TODO: Pending review in #587
|
||||||
#[allow(clippy::many_single_char_names)]
|
#[allow(clippy::many_single_char_names)]
|
||||||
pub fn generate(
|
pub fn generate(
|
||||||
@ -142,14 +141,11 @@ impl MapConfig {
|
|||||||
let focus_rect = Vec2::from(focus);
|
let focus_rect = Vec2::from(focus);
|
||||||
let true_sea_level = (CONFIG.sea_level as f64 - focus.z) / gain as f64;
|
let true_sea_level = (CONFIG.sea_level as f64 - focus.z) / gain as f64;
|
||||||
|
|
||||||
(0..dimensions.y * dimensions.x)
|
(0..dimensions.y * dimensions.x).for_each(|chunk_idx| {
|
||||||
.into_iter()
|
|
||||||
.for_each(|chunk_idx| {
|
|
||||||
let i = chunk_idx % dimensions.x as usize;
|
let i = chunk_idx % dimensions.x as usize;
|
||||||
let j = chunk_idx / dimensions.x as usize;
|
let j = chunk_idx / dimensions.x as usize;
|
||||||
|
|
||||||
let pos =
|
let pos = (focus_rect + Vec2::new(i as f64, j as f64) * scale).map(|e: f64| e as i32);
|
||||||
(focus_rect + Vec2::new(i as f64, j as f64) * scale).map(|e: f64| e as i32);
|
|
||||||
|
|
||||||
let (
|
let (
|
||||||
alt,
|
alt,
|
||||||
@ -240,9 +236,8 @@ impl MapConfig {
|
|||||||
let water_alt = true_water_alt.min(1.0).max(0.0);
|
let water_alt = true_water_alt.min(1.0).max(0.0);
|
||||||
let alt = true_alt.min(1.0).max(0.0);
|
let alt = true_alt.min(1.0).max(0.0);
|
||||||
if is_debug {
|
if is_debug {
|
||||||
let quad = |x: f32| {
|
let quad =
|
||||||
((x as f64 * QUADRANTS as f64).floor() as usize).min(QUADRANTS - 1)
|
|x: f32| ((x as f64 * QUADRANTS as f64).floor() as usize).min(QUADRANTS - 1);
|
||||||
};
|
|
||||||
if river_kind.is_none() || humidity != 0.0 {
|
if river_kind.is_none() || humidity != 0.0 {
|
||||||
quads[quad(humidity)][quad(temperature)] += 1;
|
quads[quad(humidity)][quad(temperature)] += 1;
|
||||||
}
|
}
|
||||||
@ -310,8 +305,8 @@ impl MapConfig {
|
|||||||
0,
|
0,
|
||||||
(((g_water + water_alt * (127.0 - 32.0)) + (-water_depth * g_water)) * 1.0)
|
(((g_water + water_alt * (127.0 - 32.0)) + (-water_depth * g_water)) * 1.0)
|
||||||
as u8,
|
as u8,
|
||||||
(((b_water + water_alt * (255.0 - b_water)) + (-water_depth * b_water))
|
(((b_water + water_alt * (255.0 - b_water)) + (-water_depth * b_water)) * 1.0)
|
||||||
* 1.0) as u8,
|
as u8,
|
||||||
255,
|
255,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user