viewport_lib/runtime/systems/
selection.rs1use crate::runtime::context::RuntimeFrameContext;
4use crate::runtime::output::RuntimeOutput;
5use crate::runtime::output::SelectionOp;
6
7pub struct SelectionSystem;
14
15impl Default for SelectionSystem {
16 fn default() -> Self {
17 Self
18 }
19}
20
21impl SelectionSystem {
22 pub fn new() -> Self {
24 Self
25 }
26
27 pub(crate) fn step(&self, frame: &RuntimeFrameContext, output: &mut RuntimeOutput) {
28 if !frame.clicked {
29 return;
30 }
31 match &frame.pick_hit {
32 Some(hit) => {
33 if frame.shift_held {
34 output.selection_ops.push(SelectionOp::Toggle(hit.id));
35 } else {
36 output.selection_ops.push(SelectionOp::SelectOne(hit.id));
37 }
38 }
39 None => {
40 if !frame.shift_held {
41 output.selection_ops.push(SelectionOp::Clear);
42 }
43 }
44 }
45 }
46}