forked from StudioInfinity/dyna3
Display: highlight selected elements
This commit is contained in:
parent
a60624884a
commit
96afad0c97
2 changed files with 20 additions and 8 deletions
|
@ -199,10 +199,12 @@ pub fn Display() -> View {
|
|||
let color_locs = get_uniform_array_locations::<SPHERE_MAX>(
|
||||
&ctx, &program, "color_list", None
|
||||
);
|
||||
let highlight_locs = get_uniform_array_locations::<SPHERE_MAX>(
|
||||
&ctx, &program, "highlight_list", None
|
||||
);
|
||||
let resolution_loc = ctx.get_uniform_location(&program, "resolution");
|
||||
let shortdim_loc = ctx.get_uniform_location(&program, "shortdim");
|
||||
let opacity_loc = ctx.get_uniform_location(&program, "opacity");
|
||||
let highlight_loc = ctx.get_uniform_location(&program, "highlight");
|
||||
let layer_threshold_loc = ctx.get_uniform_location(&program, "layer_threshold");
|
||||
let debug_mode_loc = ctx.get_uniform_location(&program, "debug_mode");
|
||||
|
||||
|
@ -289,13 +291,16 @@ pub fn Display() -> View {
|
|||
let elements = state.assembly.elements.get_clone();
|
||||
let element_iter = (&elements).into_iter();
|
||||
let reps_world: Vec<_> = element_iter.clone().map(|elt| &assembly_to_world * &elt.rep).collect();
|
||||
let colors: Vec<_> = element_iter.map(|elt|
|
||||
let colors: Vec<_> = element_iter.clone().map(|elt|
|
||||
if elt.selected.get() {
|
||||
elt.color.map(|ch| 0.5 + 0.5*ch)
|
||||
elt.color.map(|ch| 0.2 + 0.8*ch)
|
||||
} else {
|
||||
elt.color
|
||||
}
|
||||
).collect();
|
||||
let highlights: Vec<_> = element_iter.map(|elt|
|
||||
if elt.selected.get() { 1.0_f32 } else { HIGHLIGHT }
|
||||
).collect();
|
||||
|
||||
// set the resolution
|
||||
let width = canvas.width() as f32;
|
||||
|
@ -319,11 +324,14 @@ pub fn Display() -> View {
|
|||
color_locs[n].as_ref(),
|
||||
&colors[n]
|
||||
);
|
||||
ctx.uniform1f(
|
||||
highlight_locs[n].as_ref(),
|
||||
highlights[n]
|
||||
);
|
||||
}
|
||||
|
||||
// pass the display parameters
|
||||
ctx.uniform1f(opacity_loc.as_ref(), OPACITY);
|
||||
ctx.uniform1f(highlight_loc.as_ref(), HIGHLIGHT);
|
||||
ctx.uniform1i(layer_threshold_loc.as_ref(), LAYER_THRESHOLD);
|
||||
ctx.uniform1i(debug_mode_loc.as_ref(), DEBUG_MODE);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue