Skip to content

Commit

Permalink
Add inputs for color types
Browse files Browse the repository at this point in the history
  • Loading branch information
Masterchef365 committed Mar 3, 2024
1 parent e8ad575 commit 78f3ae9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,10 +700,12 @@ fn node_interactions(particles: &mut [Particle], node: &Rc<Node>, cfg: &NodeInte
let inputs = [
(ExternInputId::new("neigh-radius".into()), Value::Scalar(cfg.neighbor_radius)),
(ExternInputId::new("pos-diff".into()), Value::Vec2(diff.to_array())),
(ExternInputId::new("neigh-type".into()), Value::Scalar(particles[neighbor].color as f32)),
(ExternInputId::new("our-type".into()), Value::Scalar(particles[i].color as f32)),
];
let params = ExternParameters { inputs: inputs.into_iter().collect() };

let Value::Vec4([fx, fy, e1, e2]) = evaluate_node(&node, &params).unwrap() else { panic!() };
let Value::Vec4([fx, fy, _, _]) = evaluate_node(&node, &params).unwrap() else { panic!() };
particles[i].vel += dt * Vec2::new(fx, fy);
}
}
Expand All @@ -714,6 +716,8 @@ pub fn nodegraph_fn_inputs() -> ParameterList {
let params = [
(ExternInputId::new("neigh-radius".to_string()), DataType::Scalar),
(ExternInputId::new("pos-diff".to_string()), DataType::Vec2),
(ExternInputId::new("neigh-type".into()), DataType::Scalar),
(ExternInputId::new("our-type".into()), DataType::Scalar),
]
.into_iter()
.collect();
Expand Down

0 comments on commit 78f3ae9

Please sign in to comment.