forked from 1b-agent/opencadstudio-upstream
TRIM / EXTEND: a large cutting-edge selection no longer stalls each pick
In Standard mode the chosen edges sat in a Vec, and every trim rebuilt the boundary by asking it about each object of the drawing: edges × objects per click, seconds once a crossing window picked thousands of edges. Look them up in a set. TRIM's edge-selection hover also searched all objects for every picked edge on each mouse move; it uses the command's handle index like EXTEND. Refs #1867 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
15a9051bb2
commit
4aa4b72d17
1 file changed
+10
-8
@@ -2734,10 +2734,13 @@ impl TrimCommand {
|
|||||||
self.geos = if self.edge_set.is_empty() {
|
self.geos = if self.edge_set.is_empty() {
|
||||||
build_geos(&self.all_entities)
|
build_geos(&self.all_entities)
|
||||||
} else {
|
} else {
|
||||||
|
// A set, not the Vec: every trim rebuilds this, and a selection
|
||||||
|
// of thousands of edges made it edges × objects per click (#1867).
|
||||||
|
let edges: std::collections::HashSet<Handle> = self.edge_set.iter().copied().collect();
|
||||||
let picked: Vec<EntityType> = self
|
let picked: Vec<EntityType> = self
|
||||||
.all_entities
|
.all_entities
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|e| self.edge_set.contains(&e.common().handle))
|
.filter(|e| edges.contains(&e.common().handle))
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect();
|
.collect();
|
||||||
build_geos(&picked)
|
build_geos(&picked)
|
||||||
@@ -3005,15 +3008,11 @@ impl CadCommand for TrimCommand {
|
|||||||
let mut out: Vec<WireModel> = self
|
let mut out: Vec<WireModel> = self
|
||||||
.edge_set
|
.edge_set
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|h| self.all_entities.iter().find(|e| e.common().handle == *h))
|
.filter_map(|h| self.entity_index.get(&self.all_entities, *h))
|
||||||
.map(|e| WireModel::solid("edge_sel".into(), entity_pts(e), OPT_YELLOW, false))
|
.map(|e| WireModel::solid("edge_sel".into(), entity_pts(e), OPT_YELLOW, false))
|
||||||
.collect();
|
.collect();
|
||||||
if !handle.is_null() && !self.edge_set.contains(&handle) {
|
if !handle.is_null() && !self.edge_set.contains(&handle) {
|
||||||
if let Some(e) = self
|
if let Some(e) = self.entity_index.get(&self.all_entities, handle) {
|
||||||
.all_entities
|
|
||||||
.iter()
|
|
||||||
.find(|e| e.common().handle == handle)
|
|
||||||
{
|
|
||||||
let mut c = OPT_YELLOW;
|
let mut c = OPT_YELLOW;
|
||||||
c[3] = 0.45;
|
c[3] = 0.45;
|
||||||
out.push(WireModel::solid(
|
out.push(WireModel::solid(
|
||||||
@@ -3480,10 +3479,13 @@ impl ExtendCommand {
|
|||||||
self.geos = if self.edge_set.is_empty() {
|
self.geos = if self.edge_set.is_empty() {
|
||||||
build_geos(&self.all_entities)
|
build_geos(&self.all_entities)
|
||||||
} else {
|
} else {
|
||||||
|
// A set, not the Vec: every trim rebuilds this, and a selection
|
||||||
|
// of thousands of edges made it edges × objects per click (#1867).
|
||||||
|
let edges: std::collections::HashSet<Handle> = self.edge_set.iter().copied().collect();
|
||||||
let picked: Vec<EntityType> = self
|
let picked: Vec<EntityType> = self
|
||||||
.all_entities
|
.all_entities
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|e| self.edge_set.contains(&e.common().handle))
|
.filter(|e| edges.contains(&e.common().handle))
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect();
|
.collect();
|
||||||
build_geos(&picked)
|
build_geos(&picked)
|
||||||
|
|||||||
Reference in new issue
Block a user