Skip to content

Commit 02a02db

Browse files
Fix groups with same name in same object
1 parent ace6408 commit 02a02db

4 files changed

Lines changed: 14 additions & 10 deletions

File tree

src/WebviewVisu.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ export class WebviewVisu implements vscode.Disposable {
150150
}
151151

152152
// Parse the text to find group names
153-
// Group keys are like "all_mesh.obj::SURFACE_1"; match against the short name only
153+
// Group keys are like "all_mesh.obj::SURFACE_1::type"; match against the short name only
154154
const readGroups =
155155
this.groups?.filter((groupName) => {
156-
const shortName = groupName.includes('::') ? groupName.split('::').pop()! : groupName;
156+
const shortName = groupName.includes('::') ? groupName.split('::')[2]! : groupName;
157157
const regex = new RegExp(`\\b${shortName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`);
158158
return regex.test(text);
159159
}) || [];

webviews/viewer/src/components/GroupButton.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
isFace: boolean;
1515
} = $props();
1616
17-
let highlight = $derived($highlightedGroups.get(`${objectKey}::${groupName}`));
17+
let highlight = $derived(
18+
$highlightedGroups.get(`${objectKey}::${groupName}::${isFace ? 'face' : 'node'}`)
19+
);
1820
let isHidden = $derived($sidebarHiddenGroups.get(objectKey)?.has(groupName) ?? false);
1921
2022
let bgStyle = $derived(
@@ -23,7 +25,9 @@
2325
let colorStyle = $derived(highlight ? 'var(--ui-highlight-text)' : 'var(--ui-text-primary)');
2426
2527
function handleClick() {
26-
VisibilityManager.Instance.setVisibility(`${objectKey}::${groupName}`);
28+
VisibilityManager.Instance.setVisibility(
29+
`${objectKey}::${groupName}::${isFace ? 'face' : 'node'}`
30+
);
2731
}
2832
</script>
2933

webviews/viewer/src/lib/data/CreateGroups.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class CreateGroups {
6969
const size = this.computeSize(actor);
7070

7171
for (const faceGroup of groupHierarchy[fileGroup].faces) {
72-
const faceGroupId = faceGroups.indexOf(`${fileGroup}::${faceGroup}`);
72+
const faceGroupId = faceGroups.indexOf(`${fileGroup}::${faceGroup}::face`);
7373
const {
7474
actor: faceActor,
7575
colorIndex: faceColorIndex,
@@ -86,11 +86,11 @@ export class CreateGroups {
8686
faceIsObj,
8787
faceCellCount
8888
);
89-
this.groups[`${fileGroup}::${faceGroup}`] = subGroup;
89+
this.groups[`${fileGroup}::${faceGroup}::face`] = subGroup;
9090
}
9191

9292
for (const nodeGroup of groupHierarchy[fileGroup].nodes) {
93-
const nodeGroupId = nodeGroups.indexOf(`${fileGroup}::${nodeGroup}`);
93+
const nodeGroupId = nodeGroups.indexOf(`${fileGroup}::${nodeGroup}::node`);
9494
const { actor: nodeActor, colorIndex: nodeColorIndex } =
9595
nodeActorCreator.create(nodeGroupId);
9696
const subGroup = new Group(
@@ -102,7 +102,7 @@ export class CreateGroups {
102102
nodeColorIndex,
103103
false
104104
);
105-
this.groups[`${fileGroup}::${nodeGroup}`] = subGroup;
105+
this.groups[`${fileGroup}::${nodeGroup}::node`] = subGroup;
106106
}
107107
}
108108

webviews/viewer/src/lib/data/ObjLoader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ export class ObjLoader {
6363
case 'g': {
6464
groupId++;
6565
const faceGroupName = ss[1] || `group${groupId}`;
66-
faceGroups.push(`${skinName}::${faceGroupName}`);
66+
faceGroups.push(`${skinName}::${faceGroupName}::face`);
6767
groupHierarchy[skinName].faces.push(faceGroupName);
6868
break;
6969
}
7070

7171
case 'ng': {
7272
nodeGroupId++;
7373
const nodeGroupName = ss[1] || `nodeGroup${nodeGroupId}`;
74-
nodeGroups.push(`${skinName}::${nodeGroupName}`);
74+
nodeGroups.push(`${skinName}::${nodeGroupName}::node`);
7575
groupHierarchy[skinName].nodes.push(nodeGroupName);
7676
break;
7777
}

0 commit comments

Comments
 (0)