Optimize selection presentation refresh by using affected IDs for targeted updates

This commit is contained in:
2026-04-27 00:10:20 +02:00
parent 397a19b40e
commit 66489ee8c7

View File

@@ -6966,30 +6966,56 @@ export class ViewportHost {
this.whiteboxHoverLabelChangeHandler?.(label); this.whiteboxHoverLabelChangeHandler?.(label);
} }
private refreshSelectionPresentation() { private refreshSelectionPresentation(affectedIds: AffectedSelectionIds) {
if (this.currentDocument === null) { if (this.currentDocument === null) {
return; return;
} }
this.refreshBrushPresentation(); this.refreshBrushPresentationForIds(affectedIds.brushIds);
this.refreshTerrainPresentation();
this.rebuildPaths(this.currentDocument, this.currentSelection); for (const terrainId of affectedIds.terrainIds) {
this.rebuildEntityMarkers(this.currentDocument, this.currentSelection); this.refreshTerrainPresentationForId(terrainId);
this.rebuildModelInstances(this.currentDocument, this.currentSelection); }
for (const pathId of affectedIds.pathIds) {
this.syncPathRenderObjectForId(pathId);
}
for (const entityId of affectedIds.entityIds) {
this.rebuildEntityMarkerForId(entityId);
}
for (const modelInstanceId of affectedIds.modelInstanceIds) {
this.refreshModelInstanceSelectionPresentationForId(modelInstanceId);
}
this.applyTransformPreview(); this.applyTransformPreview();
this.syncTransformGizmo(); this.syncTransformGizmo();
this.syncTerrainBrushPreview(); this.syncTerrainBrushPreview();
} }
private setHoveredSelection(selection: EditorSelection) { private setHoveredSelection(selection: EditorSelection) {
if (areEditorSelectionsEqual(this.hoveredSelection, selection)) { const previousSelection = this.hoveredSelection;
if (areEditorSelectionsEqual(previousSelection, selection)) {
return; return;
} }
this.hoveredSelection = selection; this.hoveredSelection = selection;
this.refreshBrushPresentation(); const affectedIds = collectAffectedSelectionIds(
this.refreshTerrainPresentation(); previousSelection,
this.refreshPathPresentation(); selection
);
this.refreshBrushPresentationForIds(affectedIds.brushIds);
for (const terrainId of affectedIds.terrainIds) {
this.refreshTerrainPresentationForId(terrainId);
}
for (const pathId of affectedIds.pathIds) {
this.refreshPathPresentationForId(pathId);
}
this.emitWhiteboxHoverLabelChange(); this.emitWhiteboxHoverLabelChange();
} }