mirror of
https://github.com/storytold/materialcraft.git
synced 2026-11-28 17:19:17 +01:00
Preserve assigned integer storage across pattern seed properties
This commit is contained in:
1 parent
964da5968f
commit
a4c792859c
12 files changed
+145
-7
No files matched your search
@@ -505,7 +505,9 @@ fn evaluate(context: &CookContext, base_level_only: &[bool], visit_limit: usize,
|
||||
tile: context.tile,
|
||||
variables: inputs,
|
||||
};
|
||||
let value = if node.kind == PatternNodeKind::Quadrant && id == "opacity" {
|
||||
let value = if id == "randomseed" {
|
||||
program.evaluate_pattern_seed(&evaluation, &mut state, random, variables.seed_integers(context.vars.assigned_integers()))?
|
||||
} else if node.kind == PatternNodeKind::Quadrant && id == "opacity" {
|
||||
program.evaluate_pattern_tint(&evaluation, &mut state, random)?
|
||||
} else {
|
||||
program.evaluate_with_random(&evaluation, &mut state, random)?
|
||||
|
||||
@@ -50,6 +50,14 @@ impl<'a> PatternVariables<'a> {
|
||||
Self { modes, drawing, published, bound_draw: false, locals: BTreeMap::new(), scopes: Vec::new() }
|
||||
}
|
||||
|
||||
pub(super) fn seed_integers<'b>(&'b self, assigned: &'b [String]) -> impl Iterator<Item = (&'b str, i32)> {
|
||||
let locals = self.locals.iter().filter_map(|(name, local)| local.depth.map(|_| name));
|
||||
assigned.iter().chain(locals).filter_map(|name| match self.drawing.get(name) {
|
||||
Some(Value::Int(value)) => Some((name.as_str(), *value)),
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn enter(&mut self, names: &BTreeMap<String, ValueType>, depth: u32, declared: &mut Vec<Declaration>) {
|
||||
for (name, kind) in names {
|
||||
let local = self.locals.entry(name.clone()).or_default();
|
||||
|
||||
Reference in new issue
Block a user