mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
move temp and humidity out of array, introduce different smoke types
This commit is contained in:
parent
bf3eef6e1a
commit
3cc88f9b1d
@ -5,6 +5,7 @@ use crate::{
|
||||
pipelines::particle::ParticleMode, Instances, Light, Model, ParticleDrawer,
|
||||
ParticleInstance, ParticleVertex, Renderer,
|
||||
},
|
||||
scene::terrain::FireplaceType,
|
||||
};
|
||||
use common::{
|
||||
assets::{AssetExt, DotVoxAsset},
|
||||
@ -1249,7 +1250,7 @@ impl ParticleMgr {
|
||||
}
|
||||
// smoke is more complex as it comes with varying rate and color
|
||||
{
|
||||
struct FirePlaceProperties {
|
||||
struct SmokeProperties {
|
||||
position: Vec3<i32>,
|
||||
strength: f32,
|
||||
dry_chance: f32,
|
||||
@ -1268,28 +1269,39 @@ impl ParticleMgr {
|
||||
|
||||
terrain.get(chunk_pos).map(|chunk_data| {
|
||||
let blocks = &chunk_data.blocks_of_interest.smokers;
|
||||
let mut smoke_properties: Vec<FirePlaceProperties> = Vec::new();
|
||||
let mut smoke_properties: Vec<SmokeProperties> = Vec::new();
|
||||
let block_pos =
|
||||
Vec3::from(chunk_pos * TerrainChunk::RECT_SIZE.map(|e| e as i32));
|
||||
let mut sum = 0.0_f32;
|
||||
for smoker in blocks.iter() {
|
||||
let position = block_pos + smoker.position;
|
||||
let (strength, dry_chance) = {
|
||||
match smoker.kind {
|
||||
FireplaceType::House => {
|
||||
let prop = crate::scene::smoke_cycle::smoke_at_time(
|
||||
position,
|
||||
smoker.temperature,
|
||||
chunk_data.blocks_of_interest.temperature,
|
||||
time_of_day,
|
||||
);
|
||||
sum += prop.0;
|
||||
smoke_properties.push(FirePlaceProperties {
|
||||
position,
|
||||
strength: prop.0,
|
||||
dry_chance: if prop.1 {
|
||||
(
|
||||
prop.0,
|
||||
if prop.1 {
|
||||
// fire started, dark smoke
|
||||
0.8 - smoker.humidity
|
||||
0.8 - chunk_data.blocks_of_interest.humidity
|
||||
} else {
|
||||
// fire continues, light smoke
|
||||
1.2 - smoker.humidity
|
||||
1.2 - chunk_data.blocks_of_interest.humidity
|
||||
},
|
||||
)
|
||||
},
|
||||
FireplaceType::Workshop => (128.0, 1.0),
|
||||
}
|
||||
};
|
||||
sum += strength;
|
||||
smoke_properties.push(SmokeProperties {
|
||||
position,
|
||||
strength,
|
||||
dry_chance,
|
||||
});
|
||||
}
|
||||
let avg_particles = dt * sum as f32 * rate;
|
||||
|
@ -1,6 +1,6 @@
|
||||
mod watcher;
|
||||
|
||||
pub use self::watcher::{BlocksOfInterest, Interaction};
|
||||
pub use self::watcher::{BlocksOfInterest, FireplaceType, Interaction};
|
||||
|
||||
use crate::{
|
||||
mesh::{
|
||||
|
@ -12,20 +12,18 @@ pub enum Interaction {
|
||||
Mine,
|
||||
}
|
||||
|
||||
pub struct FireplaceProperties {
|
||||
pub position: Vec3<i32>,
|
||||
pub humidity: f32,
|
||||
pub temperature: f32,
|
||||
pub enum FireplaceType {
|
||||
House,
|
||||
Workshop, // this also includes witch hut
|
||||
}
|
||||
|
||||
impl FireplaceProperties {
|
||||
fn new(position: Vec3<i32>, humidity: f32, temperature: f32) -> Self {
|
||||
Self {
|
||||
position,
|
||||
humidity,
|
||||
temperature,
|
||||
}
|
||||
}
|
||||
pub struct SmokerProperties {
|
||||
pub position: Vec3<i32>,
|
||||
pub kind: FireplaceType,
|
||||
}
|
||||
|
||||
impl SmokerProperties {
|
||||
fn new(position: Vec3<i32>, kind: FireplaceType) -> Self { Self { position, kind } }
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
@ -36,7 +34,7 @@ pub struct BlocksOfInterest {
|
||||
pub slow_river: Vec<Vec3<i32>>,
|
||||
pub fast_river: Vec<Vec3<i32>>,
|
||||
pub fires: Vec<Vec3<i32>>,
|
||||
pub smokers: Vec<FireplaceProperties>,
|
||||
pub smokers: Vec<SmokerProperties>,
|
||||
pub beehives: Vec<Vec3<i32>>,
|
||||
pub reeds: Vec<Vec3<i32>>,
|
||||
pub fireflies: Vec<Vec3<i32>>,
|
||||
@ -52,6 +50,9 @@ pub struct BlocksOfInterest {
|
||||
// area for optimization
|
||||
pub interactables: Vec<(Vec3<i32>, Interaction)>,
|
||||
pub lights: Vec<(Vec3<i32>, u8)>,
|
||||
// needed for biome specific smoke variations
|
||||
pub temperature: f32,
|
||||
pub humidity: f32,
|
||||
}
|
||||
|
||||
impl BlocksOfInterest {
|
||||
@ -105,11 +106,7 @@ impl BlocksOfInterest {
|
||||
_ => match block.get_sprite() {
|
||||
Some(SpriteKind::Ember) => {
|
||||
fires.push(pos);
|
||||
smokers.push(FireplaceProperties::new(
|
||||
pos,
|
||||
chunk.meta().humidity(),
|
||||
chunk.meta().temp(),
|
||||
));
|
||||
smokers.push(SmokerProperties::new(pos, FireplaceType::House));
|
||||
},
|
||||
// Offset positions to account for block height.
|
||||
// TODO: Is this a good idea?
|
||||
@ -137,7 +134,7 @@ impl BlocksOfInterest {
|
||||
interactables.push((pos, Interaction::Craft(CraftingTab::All)))
|
||||
},
|
||||
Some(SpriteKind::SmokeDummy) => {
|
||||
smokers.push(FireplaceProperties::new(pos, 0.0, -1.0));
|
||||
smokers.push(SmokerProperties::new(pos, FireplaceType::Workshop));
|
||||
},
|
||||
Some(SpriteKind::Forge) => interactables
|
||||
.push((pos, Interaction::Craft(CraftingTab::ProcessedMaterial))),
|
||||
@ -195,6 +192,8 @@ impl BlocksOfInterest {
|
||||
frogs,
|
||||
interactables,
|
||||
lights,
|
||||
temperature: chunk.meta().temp(),
|
||||
humidity: chunk.meta().humidity(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user