forked from StudioInfinity/dyna3
Render constraint lists dynamically
This commit is contained in:
parent
a3fce9d298
commit
fb292d8b5b
3 changed files with 28 additions and 25 deletions
|
|
@ -13,7 +13,7 @@ pub struct Element {
|
|||
pub label: String,
|
||||
pub color: [f32; 3],
|
||||
pub rep: DVector<f64>,
|
||||
pub constraints: BTreeSet<usize>,
|
||||
pub constraints: Signal<BTreeSet<usize>>,
|
||||
|
||||
// internal properties, not reflected in any view
|
||||
pub index: usize
|
||||
|
|
@ -87,7 +87,7 @@ impl Assembly {
|
|||
label: format!("Sphere {}", id_num),
|
||||
color: [0.75_f32, 0.75_f32, 0.75_f32],
|
||||
rep: DVector::<f64>::from_column_slice(&[0.0, 0.0, 0.0, 0.5, -0.5]),
|
||||
constraints: BTreeSet::default(),
|
||||
constraints: create_signal(BTreeSet::default()),
|
||||
index: 0
|
||||
}
|
||||
);
|
||||
|
|
@ -96,10 +96,11 @@ impl Assembly {
|
|||
pub fn insert_constraint(&self, constraint: Constraint) {
|
||||
let args = constraint.args;
|
||||
let key = self.constraints.update(|csts| csts.insert(constraint));
|
||||
self.elements.update(|elts| {
|
||||
elts[args.0].constraints.insert(key);
|
||||
elts[args.1].constraints.insert(key);
|
||||
});
|
||||
let arg_constraints = self.elements.with(
|
||||
|elts| (elts[args.0].constraints, elts[args.1].constraints)
|
||||
);
|
||||
arg_constraints.0.update(|csts| csts.insert(key));
|
||||
arg_constraints.1.update(|csts| csts.insert(key));
|
||||
}
|
||||
|
||||
// --- realization ---
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue