mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixed floating sprites in towns, clippy fixes
This commit is contained in:
parent
50a85853e3
commit
e3cab272c3
@ -47,14 +47,11 @@ impl<T> Lottery<T> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{
|
use super::*;
|
||||||
assets,
|
use crate::{assets, comp::Item};
|
||||||
comp::inventory::item::{lottery::Lottery, Item},
|
|
||||||
};
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_loot_table() {
|
fn test_loot_table() {
|
||||||
let test = assets::load_expect::<Lottery<_>>("common.loot_table");
|
let test = assets::load_expect::<Lottery<String>>("common.loot_table");
|
||||||
let test = test;
|
|
||||||
|
|
||||||
for (_, item) in test.iter() {
|
for (_, item) in test.iter() {
|
||||||
assert!(
|
assert!(
|
||||||
|
@ -209,7 +209,7 @@ fn handle_make_block(
|
|||||||
} else {
|
} else {
|
||||||
server.notify_client(
|
server.notify_client(
|
||||||
client,
|
client,
|
||||||
ChatType::CommandError.server_msg(String::from(action.help_string())),
|
ChatType::CommandError.server_msg(action.help_string()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,65 +41,60 @@ impl Animation for BetaAnimation {
|
|||||||
.sqrt())
|
.sqrt())
|
||||||
* ((anim_time as f32 * lab as f32 * 14.0).sin());
|
* ((anim_time as f32 * lab as f32 * 14.0).sin());
|
||||||
|
|
||||||
match active_tool_kind {
|
if let Some(
|
||||||
//TODO: Inventory
|
ToolKind::Axe(_) | ToolKind::Hammer(_) | ToolKind::Sword(_) | ToolKind::Dagger(_),
|
||||||
Some(ToolKind::Axe(_))
|
) = active_tool_kind
|
||||||
| Some(ToolKind::Hammer(_))
|
{
|
||||||
| Some(ToolKind::Sword(_))
|
//INTENTION: SWORD
|
||||||
| Some(ToolKind::Dagger(_)) => {
|
next.head.offset = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
|
||||||
//INTENTION: SWORD
|
next.head.ori = Quaternion::rotation_z(slow * -0.18)
|
||||||
next.head.offset =
|
* Quaternion::rotation_x(-0.1 + slow * -0.28)
|
||||||
Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
|
* Quaternion::rotation_y(0.2 + slow * 0.18);
|
||||||
next.head.ori = Quaternion::rotation_z(slow * -0.18)
|
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
|
||||||
* Quaternion::rotation_x(-0.1 + slow * -0.28)
|
|
||||||
* Quaternion::rotation_y(0.2 + slow * 0.18);
|
|
||||||
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
|
|
||||||
|
|
||||||
next.chest.offset = Vec3::new(0.0 + foot * 2.0, 0.0, 7.0);
|
next.chest.offset = Vec3::new(0.0 + foot * 2.0, 0.0, 7.0);
|
||||||
next.chest.ori = Quaternion::rotation_z(slow * 0.2)
|
next.chest.ori = Quaternion::rotation_z(slow * 0.2)
|
||||||
* Quaternion::rotation_x(slow * 0.2)
|
* Quaternion::rotation_x(slow * 0.2)
|
||||||
* Quaternion::rotation_y(slow * -0.1);
|
* Quaternion::rotation_y(slow * -0.1);
|
||||||
|
|
||||||
next.belt.offset = Vec3::new(0.0, 0.0, -2.0);
|
next.belt.offset = Vec3::new(0.0, 0.0, -2.0);
|
||||||
next.belt.ori = Quaternion::rotation_z(slow * 0.1)
|
next.belt.ori = Quaternion::rotation_z(slow * 0.1)
|
||||||
* Quaternion::rotation_x(slow * 0.1)
|
* Quaternion::rotation_x(slow * 0.1)
|
||||||
* Quaternion::rotation_y(slow * -0.04);
|
* Quaternion::rotation_y(slow * -0.04);
|
||||||
|
|
||||||
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0);
|
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0);
|
||||||
next.shorts.ori = Quaternion::rotation_z(slow * 0.1)
|
next.shorts.ori = Quaternion::rotation_z(slow * 0.1)
|
||||||
* Quaternion::rotation_x(slow * 0.1)
|
* Quaternion::rotation_x(slow * 0.1)
|
||||||
* Quaternion::rotation_y(slow * -0.05);
|
* Quaternion::rotation_y(slow * -0.05);
|
||||||
|
|
||||||
next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5);
|
next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5);
|
||||||
next.l_hand.ori = Quaternion::rotation_x(1.27);
|
next.l_hand.ori = Quaternion::rotation_x(1.27);
|
||||||
next.l_hand.scale = Vec3::one() * 1.04;
|
next.l_hand.scale = Vec3::one() * 1.04;
|
||||||
next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5);
|
next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5);
|
||||||
next.r_hand.ori = Quaternion::rotation_x(1.27);
|
next.r_hand.ori = Quaternion::rotation_x(1.27);
|
||||||
next.r_hand.scale = Vec3::one() * 1.05;
|
next.r_hand.scale = Vec3::one() * 1.05;
|
||||||
next.main.offset = Vec3::new(0.0, 6.0, -1.0);
|
next.main.offset = Vec3::new(0.0, 6.0, -1.0);
|
||||||
next.main.ori = Quaternion::rotation_x(-0.3);
|
next.main.ori = Quaternion::rotation_x(-0.3);
|
||||||
|
|
||||||
next.control.offset = Vec3::new(-8.0 + slow * 1.5, 1.5 + slow * 1.0, 0.0);
|
next.control.offset = Vec3::new(-8.0 + slow * 1.5, 1.5 + slow * 1.0, 0.0);
|
||||||
next.control.ori = Quaternion::rotation_x(-1.4)
|
next.control.ori = Quaternion::rotation_x(-1.4)
|
||||||
* Quaternion::rotation_y(slow * 2.0 + 0.7)
|
* Quaternion::rotation_y(slow * 2.0 + 0.7)
|
||||||
* Quaternion::rotation_z(1.7 - slow * 0.4 + fast * 0.6);
|
* Quaternion::rotation_z(1.7 - slow * 0.4 + fast * 0.6);
|
||||||
next.control.scale = Vec3::one();
|
next.control.scale = Vec3::one();
|
||||||
next.l_foot.offset = Vec3::new(
|
next.l_foot.offset = Vec3::new(
|
||||||
-skeleton_attr.foot.0,
|
-skeleton_attr.foot.0,
|
||||||
footquick * -9.5,
|
footquick * -9.5,
|
||||||
skeleton_attr.foot.2,
|
skeleton_attr.foot.2,
|
||||||
);
|
);
|
||||||
next.l_foot.ori = Quaternion::rotation_x(footquick * 0.3)
|
next.l_foot.ori =
|
||||||
* Quaternion::rotation_y(footquick * -0.6);
|
Quaternion::rotation_x(footquick * 0.3) * Quaternion::rotation_y(footquick * -0.6);
|
||||||
|
|
||||||
next.r_foot.offset =
|
next.r_foot.offset =
|
||||||
Vec3::new(skeleton_attr.foot.0, footquick * 9.5, skeleton_attr.foot.2);
|
Vec3::new(skeleton_attr.foot.0, footquick * 9.5, skeleton_attr.foot.2);
|
||||||
next.r_foot.ori = Quaternion::rotation_x(footquick * -0.3)
|
next.r_foot.ori =
|
||||||
* Quaternion::rotation_y(footquick * 0.2);
|
Quaternion::rotation_x(footquick * -0.3) * Quaternion::rotation_y(footquick * 0.2);
|
||||||
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
|
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
|
||||||
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
|
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
|
||||||
},
|
|
||||||
_ => {},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
next.l_shoulder.offset = Vec3::new(
|
next.l_shoulder.offset = Vec3::new(
|
||||||
|
@ -38,60 +38,56 @@ impl Animation for SpinAnimation {
|
|||||||
let spin = (anim_time as f32 * 2.8 * lab as f32).sin();
|
let spin = (anim_time as f32 * 2.8 * lab as f32).sin();
|
||||||
let spinhalf = (anim_time as f32 * 1.4 * lab as f32).sin();
|
let spinhalf = (anim_time as f32 * 1.4 * lab as f32).sin();
|
||||||
|
|
||||||
match active_tool_kind {
|
if let Some(
|
||||||
//TODO: Inventory
|
ToolKind::Axe(_) | ToolKind::Hammer(_) | ToolKind::Sword(_) | ToolKind::Dagger(_),
|
||||||
Some(ToolKind::Axe(_))
|
) = active_tool_kind
|
||||||
| Some(ToolKind::Hammer(_))
|
{
|
||||||
| Some(ToolKind::Sword(_))
|
//INTENTION: SWORD
|
||||||
| Some(ToolKind::Dagger(_)) => {
|
next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5);
|
||||||
//INTENTION: SWORD
|
next.l_hand.ori = Quaternion::rotation_x(1.27);
|
||||||
next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5);
|
next.l_hand.scale = Vec3::one() * 1.04;
|
||||||
next.l_hand.ori = Quaternion::rotation_x(1.27);
|
next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5);
|
||||||
next.l_hand.scale = Vec3::one() * 1.04;
|
next.r_hand.ori = Quaternion::rotation_x(1.27);
|
||||||
next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5);
|
next.r_hand.scale = Vec3::one() * 1.05;
|
||||||
next.r_hand.ori = Quaternion::rotation_x(1.27);
|
next.main.offset = Vec3::new(0.0, 6.0, -1.0);
|
||||||
next.r_hand.scale = Vec3::one() * 1.05;
|
next.main.ori = Quaternion::rotation_x(-0.3)
|
||||||
next.main.offset = Vec3::new(0.0, 6.0, -1.0);
|
* Quaternion::rotation_y(0.0)
|
||||||
next.main.ori = Quaternion::rotation_x(-0.3)
|
* Quaternion::rotation_z(0.0);
|
||||||
* Quaternion::rotation_y(0.0)
|
next.main.scale = Vec3::one();
|
||||||
* Quaternion::rotation_z(0.0);
|
|
||||||
next.main.scale = Vec3::one();
|
|
||||||
|
|
||||||
next.control.offset = Vec3::new(-4.5 + spinhalf * 4.0, 11.0, 8.0);
|
next.control.offset = Vec3::new(-4.5 + spinhalf * 4.0, 11.0, 8.0);
|
||||||
next.control.ori = Quaternion::rotation_x(-1.7)
|
next.control.ori = Quaternion::rotation_x(-1.7)
|
||||||
* Quaternion::rotation_y(0.2 + spin * -2.0)
|
* Quaternion::rotation_y(0.2 + spin * -2.0)
|
||||||
* Quaternion::rotation_z(1.4 + spin * 0.1);
|
* Quaternion::rotation_z(1.4 + spin * 0.1);
|
||||||
next.control.scale = Vec3::one();
|
next.control.scale = Vec3::one();
|
||||||
next.head.offset = Vec3::new(
|
next.head.offset = Vec3::new(
|
||||||
0.0,
|
0.0,
|
||||||
-2.0 + skeleton_attr.head.0 + spin * -0.8,
|
-2.0 + skeleton_attr.head.0 + spin * -0.8,
|
||||||
skeleton_attr.head.1,
|
skeleton_attr.head.1,
|
||||||
);
|
);
|
||||||
next.head.ori = Quaternion::rotation_z(spin * -0.25)
|
next.head.ori = Quaternion::rotation_z(spin * -0.25)
|
||||||
* Quaternion::rotation_x(0.0 + spin * -0.1)
|
* Quaternion::rotation_x(0.0 + spin * -0.1)
|
||||||
* Quaternion::rotation_y(spin * -0.2);
|
* Quaternion::rotation_y(spin * -0.2);
|
||||||
next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1);
|
next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1);
|
||||||
next.chest.ori = Quaternion::rotation_z(spin * 0.1)
|
next.chest.ori = Quaternion::rotation_z(spin * 0.1)
|
||||||
* Quaternion::rotation_x(0.0 + spin * 0.1)
|
* Quaternion::rotation_x(0.0 + spin * 0.1)
|
||||||
* Quaternion::rotation_y(decel * -0.2);
|
* Quaternion::rotation_y(decel * -0.2);
|
||||||
next.chest.scale = Vec3::one();
|
next.chest.scale = Vec3::one();
|
||||||
|
|
||||||
next.belt.offset = Vec3::new(0.0, 0.0, -2.0);
|
next.belt.offset = Vec3::new(0.0, 0.0, -2.0);
|
||||||
next.belt.ori = next.chest.ori * -0.1;
|
next.belt.ori = next.chest.ori * -0.1;
|
||||||
next.belt.scale = Vec3::one();
|
next.belt.scale = Vec3::one();
|
||||||
|
|
||||||
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0);
|
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0);
|
||||||
next.belt.ori = next.chest.ori * -0.08;
|
next.belt.ori = next.chest.ori * -0.08;
|
||||||
next.shorts.scale = Vec3::one();
|
next.shorts.scale = Vec3::one();
|
||||||
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
|
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
|
||||||
next.torso.ori = Quaternion::rotation_z((spin * 7.0).max(0.3))
|
next.torso.ori = Quaternion::rotation_z((spin * 7.0).max(0.3))
|
||||||
* Quaternion::rotation_x(0.0)
|
* Quaternion::rotation_x(0.0)
|
||||||
* Quaternion::rotation_y(0.0);
|
* Quaternion::rotation_y(0.0);
|
||||||
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
|
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
|
||||||
},
|
|
||||||
|
|
||||||
_ => {},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
next.l_foot.offset = Vec3::new(-skeleton_attr.foot.0, foot * 1.0, skeleton_attr.foot.2);
|
next.l_foot.offset = Vec3::new(-skeleton_attr.foot.0, foot * 1.0, skeleton_attr.foot.2);
|
||||||
next.l_foot.ori = Quaternion::rotation_x(foot * -1.2);
|
next.l_foot.ori = Quaternion::rotation_x(foot * -1.2);
|
||||||
next.l_foot.scale = Vec3::one();
|
next.l_foot.scale = Vec3::one();
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#![feature(or_patterns)]
|
||||||
#[cfg(all(feature = "be-dyn-lib", feature = "use-dyn-lib"))]
|
#[cfg(all(feature = "be-dyn-lib", feature = "use-dyn-lib"))]
|
||||||
compile_error!("Can't use both \"be-dyn-lib\" and \"use-dyn-lib\" features at once");
|
compile_error!("Can't use both \"be-dyn-lib\" and \"use-dyn-lib\" features at once");
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ fn maps_idle() {
|
|||||||
on_ceiling: false,
|
on_ceiling: false,
|
||||||
on_wall: None,
|
on_wall: None,
|
||||||
touch_entity: None,
|
touch_entity: None,
|
||||||
in_fluid: false,
|
in_fluid: None,
|
||||||
},
|
},
|
||||||
&PreviousEntityState {
|
&PreviousEntityState {
|
||||||
event: SfxEvent::Idle,
|
event: SfxEvent::Idle,
|
||||||
@ -107,7 +107,7 @@ fn maps_run_with_sufficient_velocity() {
|
|||||||
on_ceiling: false,
|
on_ceiling: false,
|
||||||
on_wall: None,
|
on_wall: None,
|
||||||
touch_entity: None,
|
touch_entity: None,
|
||||||
in_fluid: false,
|
in_fluid: None,
|
||||||
},
|
},
|
||||||
&PreviousEntityState {
|
&PreviousEntityState {
|
||||||
event: SfxEvent::Idle,
|
event: SfxEvent::Idle,
|
||||||
@ -129,7 +129,7 @@ fn does_not_map_run_with_insufficient_velocity() {
|
|||||||
on_ceiling: false,
|
on_ceiling: false,
|
||||||
on_wall: None,
|
on_wall: None,
|
||||||
touch_entity: None,
|
touch_entity: None,
|
||||||
in_fluid: false,
|
in_fluid: None,
|
||||||
},
|
},
|
||||||
&PreviousEntityState {
|
&PreviousEntityState {
|
||||||
event: SfxEvent::Idle,
|
event: SfxEvent::Idle,
|
||||||
@ -151,7 +151,7 @@ fn does_not_map_run_with_sufficient_velocity_but_not_on_ground() {
|
|||||||
on_ceiling: false,
|
on_ceiling: false,
|
||||||
on_wall: None,
|
on_wall: None,
|
||||||
touch_entity: None,
|
touch_entity: None,
|
||||||
in_fluid: false,
|
in_fluid: None,
|
||||||
},
|
},
|
||||||
&PreviousEntityState {
|
&PreviousEntityState {
|
||||||
event: SfxEvent::Idle,
|
event: SfxEvent::Idle,
|
||||||
@ -176,7 +176,7 @@ fn maps_roll() {
|
|||||||
on_ceiling: false,
|
on_ceiling: false,
|
||||||
on_wall: None,
|
on_wall: None,
|
||||||
touch_entity: None,
|
touch_entity: None,
|
||||||
in_fluid: false,
|
in_fluid: None,
|
||||||
},
|
},
|
||||||
&PreviousEntityState {
|
&PreviousEntityState {
|
||||||
event: SfxEvent::Run,
|
event: SfxEvent::Run,
|
||||||
@ -198,7 +198,7 @@ fn maps_land_on_ground_to_run() {
|
|||||||
on_ceiling: false,
|
on_ceiling: false,
|
||||||
on_wall: None,
|
on_wall: None,
|
||||||
touch_entity: None,
|
touch_entity: None,
|
||||||
in_fluid: false,
|
in_fluid: None,
|
||||||
},
|
},
|
||||||
&PreviousEntityState {
|
&PreviousEntityState {
|
||||||
event: SfxEvent::Idle,
|
event: SfxEvent::Idle,
|
||||||
@ -220,7 +220,7 @@ fn maps_glider_open() {
|
|||||||
on_ceiling: false,
|
on_ceiling: false,
|
||||||
on_wall: None,
|
on_wall: None,
|
||||||
touch_entity: None,
|
touch_entity: None,
|
||||||
in_fluid: false,
|
in_fluid: None,
|
||||||
},
|
},
|
||||||
&PreviousEntityState {
|
&PreviousEntityState {
|
||||||
event: SfxEvent::Jump,
|
event: SfxEvent::Jump,
|
||||||
@ -242,7 +242,7 @@ fn maps_glide() {
|
|||||||
on_ceiling: false,
|
on_ceiling: false,
|
||||||
on_wall: None,
|
on_wall: None,
|
||||||
touch_entity: None,
|
touch_entity: None,
|
||||||
in_fluid: false,
|
in_fluid: None,
|
||||||
},
|
},
|
||||||
&PreviousEntityState {
|
&PreviousEntityState {
|
||||||
event: SfxEvent::Glide,
|
event: SfxEvent::Glide,
|
||||||
@ -264,7 +264,7 @@ fn maps_glider_close_when_closing_mid_flight() {
|
|||||||
on_ceiling: false,
|
on_ceiling: false,
|
||||||
on_wall: None,
|
on_wall: None,
|
||||||
touch_entity: None,
|
touch_entity: None,
|
||||||
in_fluid: false,
|
in_fluid: None,
|
||||||
},
|
},
|
||||||
&PreviousEntityState {
|
&PreviousEntityState {
|
||||||
event: SfxEvent::Glide,
|
event: SfxEvent::Glide,
|
||||||
@ -287,7 +287,7 @@ fn maps_glider_close_when_landing() {
|
|||||||
on_ceiling: false,
|
on_ceiling: false,
|
||||||
on_wall: None,
|
on_wall: None,
|
||||||
touch_entity: None,
|
touch_entity: None,
|
||||||
in_fluid: false,
|
in_fluid: None,
|
||||||
},
|
},
|
||||||
&PreviousEntityState {
|
&PreviousEntityState {
|
||||||
event: SfxEvent::Glide,
|
event: SfxEvent::Glide,
|
||||||
@ -308,7 +308,7 @@ fn maps_quadrupeds_running() {
|
|||||||
on_ceiling: false,
|
on_ceiling: false,
|
||||||
on_wall: None,
|
on_wall: None,
|
||||||
touch_entity: None,
|
touch_entity: None,
|
||||||
in_fluid: false,
|
in_fluid: None,
|
||||||
},
|
},
|
||||||
Vec3::new(0.5, 0.8, 0.0),
|
Vec3::new(0.5, 0.8, 0.0),
|
||||||
);
|
);
|
||||||
|
@ -28,7 +28,7 @@ fn main() {
|
|||||||
let pos = focus + Vec2::new(i as i32, j as i32) * scale;
|
let pos = focus + Vec2::new(i as i32, j as i32) * scale;
|
||||||
|
|
||||||
let (alt, place) = sampler
|
let (alt, place) = sampler
|
||||||
.get(pos)
|
.get((pos, world.index()))
|
||||||
.map(|sample| {
|
.map(|sample| {
|
||||||
(
|
(
|
||||||
sample.alt.sub(64.0).add(gain).mul(0.7).max(0.0).min(255.0) as u8,
|
sample.alt.sub(64.0).add(gain).mul(0.7).max(0.0).min(255.0) as u8,
|
||||||
|
@ -85,7 +85,7 @@ fn main() {
|
|||||||
lakes,
|
lakes,
|
||||||
oceans,
|
oceans,
|
||||||
quads,
|
quads,
|
||||||
} = config.generate(sampler, |pos, (r, g, b, a)| {
|
} = config.generate(sampler, world.index(), |pos, (r, g, b, a)| {
|
||||||
let i = pos.x;
|
let i = pos.x;
|
||||||
let j = pos.y;
|
let j = pos.y;
|
||||||
buf[j * W + i] = u32::from_le_bytes([b, g, r, a]);
|
buf[j * W + i] = u32::from_le_bytes([b, g, r, a]);
|
||||||
@ -104,7 +104,7 @@ fn main() {
|
|||||||
..config
|
..config
|
||||||
};
|
};
|
||||||
let mut buf = vec![0u8; 4 * len];
|
let mut buf = vec![0u8; 4 * len];
|
||||||
config.generate(sampler, |pos, (r, g, b, a)| {
|
config.generate(sampler, world.index(), |pos, (r, g, b, a)| {
|
||||||
let i = pos.x;
|
let i = pos.x;
|
||||||
let j = pos.y;
|
let j = pos.y;
|
||||||
(&mut buf[(j * x + i) * 4..]).write(&[r, g, b, a]).unwrap();
|
(&mut buf[(j * x + i) * 4..]).write(&[r, g, b, a]).unwrap();
|
||||||
|
@ -48,10 +48,7 @@ impl<'a> BlockGen<'a> {
|
|||||||
close_cliffs.iter().fold(
|
close_cliffs.iter().fold(
|
||||||
0.0f32,
|
0.0f32,
|
||||||
|max_height, (cliff_pos, seed)| match Self::sample_column(
|
|max_height, (cliff_pos, seed)| match Self::sample_column(
|
||||||
column_gen,
|
column_gen, cache, *cliff_pos, index,
|
||||||
cache,
|
|
||||||
*cliff_pos,
|
|
||||||
index,
|
|
||||||
) {
|
) {
|
||||||
Some(cliff_sample) if cliff_sample.is_cliffs && cliff_sample.spawn_rate > 0.5 => {
|
Some(cliff_sample) if cliff_sample.is_cliffs && cliff_sample.spawn_rate > 0.5 => {
|
||||||
let cliff_pos3d = Vec3::from(*cliff_pos);
|
let cliff_pos3d = Vec3::from(*cliff_pos);
|
||||||
@ -314,10 +311,10 @@ impl<'a> BlockGen<'a> {
|
|||||||
|
|
||||||
// Some(Block::new(
|
// Some(Block::new(
|
||||||
// if on_cliff && (height * 1271.0).fract() < 0.015 {
|
// if on_cliff && (height * 1271.0).fract() < 0.015 {
|
||||||
// treasures[(height * 731.3) as usize % treasures.len()]
|
// treasures[(height * 731.3) as usize %
|
||||||
// } else if (height * 1271.0).fract() < 0.1 {
|
// treasures.len()] } else if (height *
|
||||||
// flowers[(height * 0.2) as usize % flowers.len()]
|
// 1271.0).fract() < 0.1 { flowers[(height *
|
||||||
// } else {
|
// 0.2) as usize % flowers.len()] } else {
|
||||||
// grasses[(height * 103.3) as usize % grasses.len()]
|
// grasses[(height * 103.3) as usize % grasses.len()]
|
||||||
// },
|
// },
|
||||||
// Rgb::broadcast(0),
|
// Rgb::broadcast(0),
|
||||||
@ -343,10 +340,10 @@ impl<'a> BlockGen<'a> {
|
|||||||
|
|
||||||
// Some(Block::new(
|
// Some(Block::new(
|
||||||
// if (height * 1271.0).fract() < 0.5 {
|
// if (height * 1271.0).fract() < 0.5 {
|
||||||
// large_cacti[(height * 0.2) as usize % large_cacti.len()]
|
// large_cacti[(height * 0.2) as usize %
|
||||||
// } else {
|
// large_cacti.len()] } else {
|
||||||
// small_cacti[(height * 0.3) as usize % small_cacti.len()]
|
// small_cacti[(height * 0.3) as usize %
|
||||||
// },
|
// small_cacti.len()] },
|
||||||
// Rgb::broadcast(0),
|
// Rgb::broadcast(0),
|
||||||
// ))
|
// ))
|
||||||
} else {
|
} else {
|
||||||
|
@ -715,9 +715,7 @@ fn find_site_loc(
|
|||||||
loc = ctx.sim.get(test_loc).and_then(|c| {
|
loc = ctx.sim.get(test_loc).and_then(|c| {
|
||||||
Some(
|
Some(
|
||||||
c.downhill?
|
c.downhill?
|
||||||
.map2(TerrainChunkSize::RECT_SIZE, |e, sz: u32| {
|
.map2(TerrainChunkSize::RECT_SIZE, |e, sz: u32| e / (sz as i32)),
|
||||||
e / (sz as i32)
|
|
||||||
}),
|
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -614,7 +614,7 @@ where
|
|||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
max_border_river
|
max_border_river
|
||||||
.river_kind
|
.river_kind
|
||||||
.and_then(|river_kind| {
|
.map(|river_kind| {
|
||||||
match river_kind {
|
match river_kind {
|
||||||
RiverKind::Ocean => {
|
RiverKind::Ocean => {
|
||||||
let (
|
let (
|
||||||
@ -648,7 +648,7 @@ where
|
|||||||
let river_dist = wposf.distance(river_pos);
|
let river_dist = wposf.distance(river_pos);
|
||||||
let _river_height_factor =
|
let _river_height_factor =
|
||||||
river_dist / (river_width * 0.5);
|
river_dist / (river_width * 0.5);
|
||||||
return Some((
|
return (
|
||||||
true,
|
true,
|
||||||
Some((river_dist - river_width * 0.5) as f32),
|
Some((river_dist - river_width * 0.5) as f32),
|
||||||
alt_for_river
|
alt_for_river
|
||||||
@ -656,10 +656,10 @@ where
|
|||||||
lake_water_alt - river_gouge,
|
lake_water_alt - river_gouge,
|
||||||
alt_for_river.max(lake_water_alt),
|
alt_for_river.max(lake_water_alt),
|
||||||
0.0,
|
0.0,
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Some((
|
(
|
||||||
river_scale_factor <= 1.0,
|
river_scale_factor <= 1.0,
|
||||||
Some(
|
Some(
|
||||||
(wposf.distance(river_pos) - river_width * 0.5)
|
(wposf.distance(river_pos) - river_width * 0.5)
|
||||||
@ -669,7 +669,7 @@ where
|
|||||||
downhill_water_alt,
|
downhill_water_alt,
|
||||||
alt_for_river,
|
alt_for_river,
|
||||||
river_scale_factor as f32,
|
river_scale_factor as f32,
|
||||||
))
|
)
|
||||||
},
|
},
|
||||||
RiverKind::Lake { .. } => {
|
RiverKind::Lake { .. } => {
|
||||||
let lake_dist = (max_border_river_pos.map(|e| e as f64)
|
let lake_dist = (max_border_river_pos.map(|e| e as f64)
|
||||||
@ -691,7 +691,7 @@ where
|
|||||||
|| in_bounds
|
|| in_bounds
|
||||||
{
|
{
|
||||||
let gouge_factor = 0.0;
|
let gouge_factor = 0.0;
|
||||||
return Some((
|
return (
|
||||||
in_bounds
|
in_bounds
|
||||||
|| downhill_water_alt
|
|| downhill_water_alt
|
||||||
.max(river_chunk.water_alt)
|
.max(river_chunk.water_alt)
|
||||||
@ -703,16 +703,16 @@ where
|
|||||||
alt_for_river,
|
alt_for_river,
|
||||||
river_scale_factor as f32
|
river_scale_factor as f32
|
||||||
* (1.0 - gouge_factor),
|
* (1.0 - gouge_factor),
|
||||||
));
|
);
|
||||||
} else {
|
} else {
|
||||||
return Some((
|
return (
|
||||||
false,
|
false,
|
||||||
Some(lake_dist as f32),
|
Some(lake_dist as f32),
|
||||||
alt_for_river,
|
alt_for_river,
|
||||||
downhill_water_alt,
|
downhill_water_alt,
|
||||||
alt_for_river,
|
alt_for_river,
|
||||||
river_scale_factor as f32,
|
river_scale_factor as f32,
|
||||||
));
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
let lake_dist = dist.y;
|
let lake_dist = dist.y;
|
||||||
@ -724,7 +724,7 @@ where
|
|||||||
river_t as f32,
|
river_t as f32,
|
||||||
);
|
);
|
||||||
if dist == Vec2::zero() {
|
if dist == Vec2::zero() {
|
||||||
return Some((
|
return (
|
||||||
true,
|
true,
|
||||||
Some(lake_dist as f32),
|
Some(lake_dist as f32),
|
||||||
alt_for_river
|
alt_for_river
|
||||||
@ -732,7 +732,7 @@ where
|
|||||||
lake_water_alt - river_gouge,
|
lake_water_alt - river_gouge,
|
||||||
alt_for_river.max(lake_water_alt),
|
alt_for_river.max(lake_water_alt),
|
||||||
0.0,
|
0.0,
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
if lake_dist <= TerrainChunkSize::RECT_SIZE.x as f64 * 1.0
|
if lake_dist <= TerrainChunkSize::RECT_SIZE.x as f64 * 1.0
|
||||||
|| in_bounds
|
|| in_bounds
|
||||||
@ -745,7 +745,7 @@ where
|
|||||||
let in_bounds_ = lake_dist
|
let in_bounds_ = lake_dist
|
||||||
<= TerrainChunkSize::RECT_SIZE.x as f64 * 0.5;
|
<= TerrainChunkSize::RECT_SIZE.x as f64 * 0.5;
|
||||||
if gouge_factor == 1.0 {
|
if gouge_factor == 1.0 {
|
||||||
return Some((
|
return (
|
||||||
true,
|
true,
|
||||||
Some(lake_dist as f32),
|
Some(lake_dist as f32),
|
||||||
alt.min(lake_water_alt - 1.0 - river_gouge),
|
alt.min(lake_water_alt - 1.0 - river_gouge),
|
||||||
@ -753,9 +753,9 @@ where
|
|||||||
- river_gouge,
|
- river_gouge,
|
||||||
alt.max(lake_water_alt),
|
alt.max(lake_water_alt),
|
||||||
0.0,
|
0.0,
|
||||||
));
|
);
|
||||||
} else {
|
} else {
|
||||||
return Some((
|
return (
|
||||||
true,
|
true,
|
||||||
None,
|
None,
|
||||||
alt_for_river,
|
alt_for_river,
|
||||||
@ -767,17 +767,17 @@ where
|
|||||||
alt_for_river,
|
alt_for_river,
|
||||||
river_scale_factor as f32
|
river_scale_factor as f32
|
||||||
* (1.0 - gouge_factor),
|
* (1.0 - gouge_factor),
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some((
|
(
|
||||||
river_scale_factor <= 1.0,
|
river_scale_factor <= 1.0,
|
||||||
Some(lake_dist as f32),
|
Some(lake_dist as f32),
|
||||||
alt_for_river,
|
alt_for_river,
|
||||||
downhill_water_alt,
|
downhill_water_alt,
|
||||||
alt_for_river,
|
alt_for_river,
|
||||||
river_scale_factor as f32,
|
river_scale_factor as f32,
|
||||||
))
|
)
|
||||||
},
|
},
|
||||||
RiverKind::River { .. } => {
|
RiverKind::River { .. } => {
|
||||||
let (_, _, river_width, (_, (river_pos, _), _)) =
|
let (_, _, river_width, (_, (river_pos, _), _)) =
|
||||||
@ -785,14 +785,14 @@ where
|
|||||||
let river_dist = wposf.distance(river_pos);
|
let river_dist = wposf.distance(river_pos);
|
||||||
|
|
||||||
// FIXME: Make water altitude accurate.
|
// FIXME: Make water altitude accurate.
|
||||||
Some((
|
(
|
||||||
river_scale_factor <= 1.0,
|
river_scale_factor <= 1.0,
|
||||||
Some((river_dist - river_width * 0.5) as f32),
|
Some((river_dist - river_width * 0.5) as f32),
|
||||||
alt_for_river,
|
alt_for_river,
|
||||||
downhill_water_alt,
|
downhill_water_alt,
|
||||||
alt_for_river,
|
alt_for_river,
|
||||||
river_scale_factor as f32,
|
river_scale_factor as f32,
|
||||||
))
|
)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -105,14 +105,14 @@ pub fn apply_scatter_to<'a>(
|
|||||||
.find_map(|(i, (bk, is_underwater, f))| {
|
.find_map(|(i, (bk, is_underwater, f))| {
|
||||||
let (density, patch) = f(chunk);
|
let (density, patch) = f(chunk);
|
||||||
let is_patch = patch
|
let is_patch = patch
|
||||||
.map(|(wavelen, threshold)| {
|
.map(|(wavelen, threshold)| {
|
||||||
index.noise.scatter_nz.get(
|
index.noise.scatter_nz.get(
|
||||||
wpos2d
|
wpos2d
|
||||||
.map(|e| e as f64 / wavelen as f64 + i as f64 * 43.0)
|
.map(|e| e as f64 / wavelen as f64 + i as f64 * 43.0)
|
||||||
.into_array(),
|
.into_array(),
|
||||||
) < threshold as f64
|
) < threshold as f64
|
||||||
})
|
})
|
||||||
.unwrap_or(false);
|
.unwrap_or(false);
|
||||||
if density <= 0.0
|
if density <= 0.0
|
||||||
|| is_patch
|
|| is_patch
|
||||||
|| !RandomField::new(i as u32)
|
|| !RandomField::new(i as u32)
|
||||||
|
@ -404,7 +404,7 @@ impl Floor {
|
|||||||
if area.contains_point(stair_rcenter.xy()) {
|
if area.contains_point(stair_rcenter.xy()) {
|
||||||
let offs = Vec2::new(rng.gen_range(-1.0, 1.0), rng.gen_range(-1.0, 1.0))
|
let offs = Vec2::new(rng.gen_range(-1.0, 1.0), rng.gen_range(-1.0, 1.0))
|
||||||
.try_normalized()
|
.try_normalized()
|
||||||
.unwrap_or(Vec2::unit_y())
|
.unwrap_or_else(Vec2::unit_y)
|
||||||
* FLOOR_SIZE.x as f32
|
* FLOOR_SIZE.x as f32
|
||||||
/ 2.0
|
/ 2.0
|
||||||
- 8.0;
|
- 8.0;
|
||||||
|
@ -12,6 +12,8 @@ pub trait Archetype {
|
|||||||
fn generate<R: Rng>(rng: &mut R) -> (Self, Skeleton<Self::Attr>)
|
fn generate<R: Rng>(rng: &mut R) -> (Self, Skeleton<Self::Attr>)
|
||||||
where
|
where
|
||||||
Self: Sized;
|
Self: Sized;
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn draw(
|
fn draw(
|
||||||
&self,
|
&self,
|
||||||
pos: Vec3<i32>,
|
pos: Vec3<i32>,
|
||||||
|
@ -232,7 +232,7 @@ impl Settlement {
|
|||||||
for _ in 0..PATH_COUNT {
|
for _ in 0..PATH_COUNT {
|
||||||
dir = (Vec2::new(rng.gen::<f32>() - 0.5, rng.gen::<f32>() - 0.5) * 2.0 - dir)
|
dir = (Vec2::new(rng.gen::<f32>() - 0.5, rng.gen::<f32>() - 0.5) * 2.0 - dir)
|
||||||
.try_normalized()
|
.try_normalized()
|
||||||
.unwrap_or(Vec2::zero());
|
.unwrap_or_else(Vec2::zero);
|
||||||
let origin = dir.map(|e| (e * 100.0) as i32);
|
let origin = dir.map(|e| (e * 100.0) as i32);
|
||||||
let origin = self
|
let origin = self
|
||||||
.land
|
.land
|
||||||
@ -662,7 +662,7 @@ impl Settlement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(Rgb::new(100, 105, 75).map2(Rgb::iota(), |e: u8, i: i32| {
|
Some(Rgb::new(100, 95, 65).map2(Rgb::iota(), |e: u8, i: i32| {
|
||||||
e.saturating_add(
|
e.saturating_add(
|
||||||
(self.noise.get(Vec3::new(wpos2d.x, wpos2d.y, i * 5)) % 1)
|
(self.noise.get(Vec3::new(wpos2d.x, wpos2d.y, i * 5)) % 1)
|
||||||
as u8,
|
as u8,
|
||||||
@ -746,9 +746,9 @@ impl Settlement {
|
|||||||
|
|
||||||
for z in -8 - diff..4 + diff {
|
for z in -8 - diff..4 + diff {
|
||||||
let pos = Vec3::new(offs.x, offs.y, surface_z + z);
|
let pos = Vec3::new(offs.x, offs.y, surface_z + z);
|
||||||
let block = vol.get(pos).ok().copied().unwrap_or(Block::empty());
|
let block = vol.get(pos).ok().copied().unwrap_or_else(Block::empty);
|
||||||
|
|
||||||
if block.is_empty() {
|
if block.kind() == BlockKind::Air {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,17 +24,17 @@ impl Sampler<'static> for RandomField {
|
|||||||
let mut a = self.seed;
|
let mut a = self.seed;
|
||||||
a = (a ^ 61) ^ (a >> 16);
|
a = (a ^ 61) ^ (a >> 16);
|
||||||
a = a.wrapping_add(a << 3);
|
a = a.wrapping_add(a << 3);
|
||||||
a = a ^ pos.x;
|
a ^= pos.x;
|
||||||
a = a ^ (a >> 4);
|
a ^= a >> 4;
|
||||||
a = a.wrapping_mul(0x27d4eb2d);
|
a = a.wrapping_mul(0x27d4eb2d);
|
||||||
a = a ^ (a >> 15);
|
a ^= a >> 15;
|
||||||
a = a ^ pos.y;
|
a ^= pos.y;
|
||||||
a = (a ^ 61) ^ (a >> 16);
|
a = (a ^ 61) ^ (a >> 16);
|
||||||
a = a.wrapping_add(a << 3);
|
a = a.wrapping_add(a << 3);
|
||||||
a = a ^ (a >> 4);
|
a ^= a >> 4;
|
||||||
a = a ^ pos.z;
|
a ^= pos.z;
|
||||||
a = a.wrapping_mul(0x27d4eb2d);
|
a = a.wrapping_mul(0x27d4eb2d);
|
||||||
a = a ^ (a >> 15);
|
a ^= a >> 15;
|
||||||
a
|
a
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user