diff --git a/blender-5.2.0/source/blender/web_engine/web_engine_api.cpp b/blender-5.2.0/source/blender/web_engine/web_engine_api.cpp index d87adbed3..14a225b71 100644 --- a/blender-5.2.0/source/blender/web_engine/web_engine_api.cpp +++ b/blender-5.2.0/source/blender/web_engine/web_engine_api.cpp @@ -2434,8 +2434,10 @@ std::string refresh_error; } const std::string object_id = command.value("objectId", ""); std::string main_error; - if (!web_engine_blend_main_delete_object( - engine->authoritative_main, object_id.c_str(), main_error) || + if (!web_engine_blend_main_delete_object(engine->authoritative_main, + object_id.c_str(), + command.value("hierarchy", false), + main_error) || !refresh_scene_from_main(*engine, snapshot, "", main_error)) { rollback_edit_or_throw(*engine, previous_state, main_error); diff --git a/blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp b/blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp index b528bb3e4..a657fa511 100644 --- a/blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp +++ b/blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp @@ -15222,6 +15222,7 @@ bool web_engine_blend_main_delete_non_mesh_data(WebBlendMainState *state, bool web_engine_blend_main_delete_object(WebBlendMainState *state, const char *object_id, + bool hierarchy, std::string &error) { Object *object = find_object(state, object_id); @@ -15233,6 +15234,29 @@ bool web_engine_blend_main_delete_object(WebBlendMainState *state, error = "LINKED_DATA_MUTATION_BLOCKED: linked objects cannot be deleted"; return false; } + if (!hierarchy) { + BKE_id_delete(state->main, &object->id); + BKE_view_layer_synced_ensure(*state->main, state->scene, state->view_layer); + return true; + } + /* Desktop OUTLINER_OT_delete with hierarchy=True removes the object and every + * descendant found through the parent chains (outliner_tools.cc + * outliner_batch_delete_object_hierarchy_tag / outliner_batch_delete_object_hierarchy). */ + std::vector victims; + for (Object &candidate : state->main->objects) { + bool descendant = false; + for (Object *parent = candidate.parent; parent != nullptr && !descendant; + parent = parent->parent) { + descendant = parent == object; + } + if (!descendant) continue; + if (candidate.id.lib != nullptr) { + error = "LINKED_DATA_MUTATION_BLOCKED: linked objects cannot be deleted"; + return false; + } + victims.push_back(&candidate.id); + } + for (ID *victim : victims) BKE_id_delete(state->main, victim); BKE_id_delete(state->main, &object->id); BKE_view_layer_synced_ensure(*state->main, state->scene, state->view_layer); return true; diff --git a/blender-5.2.0/source/blender/web_engine/web_engine_main_state.h b/blender-5.2.0/source/blender/web_engine/web_engine_main_state.h index abb93ad4c..ecb1ca988 100644 --- a/blender-5.2.0/source/blender/web_engine/web_engine_main_state.h +++ b/blender-5.2.0/source/blender/web_engine/web_engine_main_state.h @@ -352,6 +352,7 @@ bool web_engine_blend_main_duplicate_object(WebBlendMainState *state, std::string &error); bool web_engine_blend_main_delete_object(WebBlendMainState *state, const char *object_id, + bool hierarchy, std::string &error); bool web_engine_blend_main_set_transform(WebBlendMainState *state, const char *object_id, diff --git a/tools/web/check-outliner-headed.mjs b/tools/web/check-outliner-headed.mjs index f63a6a7e1..1a0406a93 100644 --- a/tools/web/check-outliner-headed.mjs +++ b/tools/web/check-outliner-headed.mjs @@ -19,7 +19,7 @@ import path from "node:path"; import { fileURLToPath } from "node:url"; const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../.."); -const EXPECTED_CASES = ["outliner-tree-baseline-web", "outliner-tools-baseline-web", "outliner-mirror-baseline-web", "outliner-metrics-web", "outliner-display-mode-web", "outliner-filter-web", "outliner-restrict-web", "outliner-select-keys-web", "outliner-delete-web", "outliner-box-select-web", "outliner-id-operation-web", "outliner-id-clipboard-web", "outliner-collection-delete-web", "outliner-mode-dot-web", "outliner-rename-bone-web", "outliner-eyedropper-web", "outliner-fake-user-purge-web", "outliner-asset-ops-web", "outliner-liboverride-web", "outliner-make-local-web", "outliner-select-hierarchy-web"]; +const EXPECTED_CASES = ["outliner-tree-baseline-web", "outliner-tools-baseline-web", "outliner-mirror-baseline-web", "outliner-metrics-web", "outliner-display-mode-web", "outliner-filter-web", "outliner-restrict-web", "outliner-select-keys-web", "outliner-delete-web", "outliner-box-select-web", "outliner-id-operation-web", "outliner-id-clipboard-web", "outliner-collection-delete-web", "outliner-mode-dot-web", "outliner-rename-bone-web", "outliner-eyedropper-web", "outliner-fake-user-purge-web", "outliner-asset-ops-web", "outliner-liboverride-web", "outliner-make-local-web", "outliner-select-hierarchy-web", "outliner-delete-hierarchy-web"]; /* Desktop Layout geometry the metrics case must reproduce (batch 2: UI sizes). */ const GEOMETRY_GOLDEN = path.join(REPO_ROOT, "tests/golden/OUTLINER-DESKTOP-METRICS/outliner-metrics.json"); const errors = []; diff --git a/tools/web/run-outliner-headed.mjs b/tools/web/run-outliner-headed.mjs index 8e91b98ff..f960b68e3 100644 --- a/tools/web/run-outliner-headed.mjs +++ b/tools/web/run-outliner-headed.mjs @@ -52,6 +52,7 @@ const KNOWN_CASES = [ { id: "outliner-liboverride-web", title: /\[outliner-liboverride-web\]/ }, { id: "outliner-make-local-web", title: /\[outliner-make-local-web\]/ }, { id: "outliner-select-hierarchy-web", title: /\[outliner-select-hierarchy-web\]/ }, + { id: "outliner-delete-hierarchy-web", title: /\[outliner-delete-hierarchy-web\]/ }, ]; function usage() { diff --git a/web/app/public/vendor/blender/web_engine.wasm b/web/app/public/vendor/blender/web_engine.wasm index 41b33eb7c..9fbe52af4 100644 Binary files a/web/app/public/vendor/blender/web_engine.wasm and b/web/app/public/vendor/blender/web_engine.wasm differ diff --git a/web/app/public/wasm-module-manifest.json b/web/app/public/wasm-module-manifest.json index a46dae03b..4a7c9a090 100644 --- a/web/app/public/wasm-module-manifest.json +++ b/web/app/public/wasm-module-manifest.json @@ -10,7 +10,7 @@ "single": { "fileName": "web_engine.wasm", "url": "/vendor/blender/web_engine.wasm", - "sha256": "65dc918e83e2eeaee196555176c7bd7603f929f42afc4abebc749c72862450f6" + "sha256": "078f0da9f760ba7f223396a63049a6d1722791a266d06e68d233e530b96fa11f" }, "pthread": { "fileName": "web_engine.wasm", @@ -27,7 +27,7 @@ "single": { "fileName": "web_engine.wasm", "url": "/vendor/blender/web_engine.wasm", - "sha256": "65dc918e83e2eeaee196555176c7bd7603f929f42afc4abebc749c72862450f6" + "sha256": "078f0da9f760ba7f223396a63049a6d1722791a266d06e68d233e530b96fa11f" }, "pthread": { "fileName": "web_engine.wasm", @@ -44,7 +44,7 @@ "single": { "fileName": "web_engine.wasm", "url": "/vendor/blender/web_engine.wasm", - "sha256": "65dc918e83e2eeaee196555176c7bd7603f929f42afc4abebc749c72862450f6" + "sha256": "078f0da9f760ba7f223396a63049a6d1722791a266d06e68d233e530b96fa11f" }, "pthread": { "fileName": "web_engine.wasm", @@ -61,7 +61,7 @@ "single": { "fileName": "web_engine.wasm", "url": "/vendor/blender/web_engine.wasm", - "sha256": "65dc918e83e2eeaee196555176c7bd7603f929f42afc4abebc749c72862450f6" + "sha256": "078f0da9f760ba7f223396a63049a6d1722791a266d06e68d233e530b96fa11f" }, "pthread": { "fileName": "web_engine.wasm", diff --git a/web/app/src/app/App.tsx b/web/app/src/app/App.tsx index 889b45046..f67848cd0 100644 --- a/web/app/src/app/App.tsx +++ b/web/app/src/app/App.tsx @@ -2528,7 +2528,7 @@ function Outliner({ snapshot, areaId, onSelect, onToggleVisibility, onRefresh, o onToggleVisibility: (id: string, visible: boolean) => void; onRefresh?: () => void; onSelectAll?: (operation: 'SELECT' | 'DESELECT' | 'INVERT' | 'TOGGLE') => void; - onDeleteObject?: (objectId: string) => void; + onDeleteObject?: (objectId: string, hierarchy?: boolean) => void; onDeleteCollection?: (collectionId: string, hierarchy: boolean) => void; areaId?: string; onToggleExpand?: (rowId: string, toggleAll: boolean, areaId: string) => void; @@ -2833,7 +2833,7 @@ function Outliner({ snapshot, areaId, onSelect, onToggleVisibility, onRefresh, o {/* Desktop SpaceOutliner display_mode selector (View Layer, Blender File, …). */} {onSetDisplayMode && tree?.displayModes?.length ? : null} { setMenuRow(null); setDataMenu(!dataMenu); }} - onClose={() => setDataMenu(false)} items={[{label: '复制', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !workspace?.writable, reason: '把所选数据块复制到内部剪贴板(桌面 OUTLINER_OT_id_copy)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COPY', nativeArea.id); }}, {label: '粘贴', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !workspace?.writable, reason: '从内部剪贴板粘贴数据块(桌面 OUTLINER_OT_id_paste)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'PASTE', nativeArea.id); }}, {label: '重命名 (F2)', disabled: treeRenameBusy || remapBusy || !onRemap || !workspace?.writable || !menuTarget || !renameTarget(menuTarget), reason: '重命名受支持的本地数据块', action: () => { if (menuTarget) beginTreeRename(menuTarget); }}, {label: '删除 (X)', disabled: treeRenameBusy || remapBusy || !onDeleteObject || !menuTarget?.objectId, reason: '删除所选对象(桌面 OUTLINER_OT_delete)', action: () => { if (menuTarget?.objectId) onDeleteObject?.(menuTarget.objectId); }}, {label: '删除集合', disabled: treeRenameBusy || remapBusy || !canDeleteCollection, reason: '删除所选集合,内容保留并移到主集合(桌面 outliner.delete)', action: () => { if (menuCollection) onDeleteCollection?.(menuCollection.id, false); }}, {label: '删除层级', disabled: treeRenameBusy || remapBusy || !canDeleteCollection, reason: '删除所选集合及其全部内容(桌面 outliner.delete hierarchy)', action: () => { if (menuCollection) onDeleteCollection?.(menuCollection.id, true); }},{label: '取消链接', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.objectId || menuTarget.remapId), reason: '把所选数据块从其父级取消链接(桌面 OUTLINER_OT_id_operation UNLINK)', action: () => { if (menuTarget) if (nativeArea) onIdOperation?.(menuTarget.id, 'UNLINK', nativeArea.id); }}, {label: '设为单用户 (Make Single User)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.objectId || menuTarget.remapId), reason: '把多用户的 ID 数据块设为单用户(桌面 OUTLINER_OT_id_operation SINGLE)', action: () => { if (menuTarget) if (nativeArea) onIdOperation?.(menuTarget.id, 'SINGLE', nativeArea.id); }}, /* Desktop's object menu entry (space_outliner.py outliner.object_operation + onClose={() => setDataMenu(false)} items={[{label: '复制', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !workspace?.writable, reason: '把所选数据块复制到内部剪贴板(桌面 OUTLINER_OT_id_copy)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COPY', nativeArea.id); }}, {label: '粘贴', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !workspace?.writable, reason: '从内部剪贴板粘贴数据块(桌面 OUTLINER_OT_id_paste)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'PASTE', nativeArea.id); }}, {label: '重命名 (F2)', disabled: treeRenameBusy || remapBusy || !onRemap || !workspace?.writable || !menuTarget || !renameTarget(menuTarget), reason: '重命名受支持的本地数据块', action: () => { if (menuTarget) beginTreeRename(menuTarget); }}, {label: '删除 (X)', disabled: treeRenameBusy || remapBusy || !onDeleteObject || !menuTarget?.objectId, reason: '删除所选对象(桌面 OUTLINER_OT_delete)', action: () => { if (menuTarget?.objectId) onDeleteObject?.(menuTarget.objectId); }}, {label: '删除层级 (Delete Hierarchy)', disabled: treeRenameBusy || remapBusy || !onDeleteObject || !menuTarget?.objectId, reason: '删除所选对象及其全部子级(桌面 OUTLINER_OT_delete hierarchy=True)', action: () => { if (menuTarget?.objectId) onDeleteObject?.(menuTarget.objectId, true); }}, {label: '删除集合', disabled: treeRenameBusy || remapBusy || !canDeleteCollection, reason: '删除所选集合,内容保留并移到主集合(桌面 outliner.delete)', action: () => { if (menuCollection) onDeleteCollection?.(menuCollection.id, false); }}, {label: '删除层级', disabled: treeRenameBusy || remapBusy || !canDeleteCollection, reason: '删除所选集合及其全部内容(桌面 outliner.delete hierarchy)', action: () => { if (menuCollection) onDeleteCollection?.(menuCollection.id, true); }},{label: '取消链接', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.objectId || menuTarget.remapId), reason: '把所选数据块从其父级取消链接(桌面 OUTLINER_OT_id_operation UNLINK)', action: () => { if (menuTarget) if (nativeArea) onIdOperation?.(menuTarget.id, 'UNLINK', nativeArea.id); }}, {label: '设为单用户 (Make Single User)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.objectId || menuTarget.remapId), reason: '把多用户的 ID 数据块设为单用户(桌面 OUTLINER_OT_id_operation SINGLE)', action: () => { if (menuTarget) if (nativeArea) onIdOperation?.(menuTarget.id, 'SINGLE', nativeArea.id); }}, /* Desktop's object menu entry (space_outliner.py outliner.object_operation * SELECT_HIERARCHY): select the row and every child underneath it. */ {label: '选择层级 (Select Hierarchy)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget?.objectId || !workspace?.writable, reason: '选择所选对象及其全部子级(桌面 OUTLINER_OT_object_operation type=SELECT_HIERARCHY)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'SELECT_HIERARCHY', nativeArea.id); }}, /* Desktop's libdata operations entry (space_outliner.py id_operation LOCAL); @@ -10491,7 +10491,7 @@ else: onSelect={(id,additive,range)=>selectObject(id,additive,range,area.id)} onRefresh={()=>refreshOutliner(area.id)} onSelectAll={operation=>selectAllOutliner(operation,area.id)} onToggleVisibility={(id,visible)=>void applyEditCommand({type:'setObjectVisibility',objectId:id,visible})} - onDeleteObject={(id)=>void applyEditCommand({type:'deleteObject',objectId:id})} onDeleteCollection={(collectionId, hierarchy) => void applyEditCommand({ type: "deleteCollection", collectionId, hierarchy })} + onDeleteObject={(id,hierarchy)=>void applyEditCommand({type:'deleteObject',objectId:id,hierarchy})} onDeleteCollection={(collectionId, hierarchy) => void applyEditCommand({ type: "deleteCollection", collectionId, hierarchy })} onSelectBox={(firstRowId,lastRowId,mode,id)=>setOutlinerSelectBox(firstRowId,lastRowId,mode,id)} onIdOperation={(firstRowId,operation,id)=>setOutlinerIdOperation(firstRowId,operation,id)} onModeToggle={(rowId,extend,id)=>setOutlinerModeToggle(rowId,extend,id)}/>; if(area.editor==='VIEW_3D')return { const client=webClientRef.current;if(!client||!nativeWorkspace)return false; @@ -10669,7 +10669,7 @@ else: case "3D Viewport": return void applyEditCommand({ type: "setObjectTransform", objectId, translation, rotationEuler, scale })} onDiagnostic={recordDiagnostic} mode={uiState.context.mode} onMeshEdit={runMeshEdit} onMeshSelectionMode={setMeshSelectionMode} onSelectAllMeshElements={selectAllMeshElements} onAddPrimitive={(primitive) => void applyEditCommand(coreSceneCommands.createPrimitive(primitive))} onFocusSculptProperties={() => focusProperty('[data-testid="sculpt-editor"]')} onVoxelRemesh={(voxelSize) => void invokeNativeOperator('object.voxel_remesh', { voxel_size: voxelSize })} />; case "Outliner": - return applyEditCommand(command, undefined, feedback)} onReparent={(ids, parentId, keepTransform) => void applyEditCommand({ type: 'setParents', objectIds: ids, parentId, keepTransform })} onMoveToCollection={(ids, collectionId, keepExistingLinks) => { for (const id of ids) void applyEditCommand({ type: 'moveObjectToCollection', objectId: id, collectionId, keepExistingLinks }); }} onMoveCollection={(collectionId, parentCollectionId) => void applyEditCommand(coreSceneCommands.moveCollection(collectionId, parentCollectionId))} onSelect={selectObject} onRefresh={refreshOutliner} onSelectAll={selectAllOutliner} onToggleVisibility={(id, visible) => void applyEditCommand({ type: "setObjectVisibility", objectId: id, visible })} onDeleteObject={(id) => void applyEditCommand({ type: "deleteObject", objectId: id })} onDeleteCollection={(collectionId, hierarchy) => void applyEditCommand({ type: "deleteCollection", collectionId, hierarchy })} onSelectBox={(firstRowId,lastRowId,mode,id)=>setOutlinerSelectBox(firstRowId,lastRowId,mode,id)} onIdOperation={(firstRowId,operation,id)=>setOutlinerIdOperation(firstRowId,operation,id)} onModeToggle={(rowId,extend,id)=>setOutlinerModeToggle(rowId,extend,id)} />; + return applyEditCommand(command, undefined, feedback)} onReparent={(ids, parentId, keepTransform) => void applyEditCommand({ type: 'setParents', objectIds: ids, parentId, keepTransform })} onMoveToCollection={(ids, collectionId, keepExistingLinks) => { for (const id of ids) void applyEditCommand({ type: 'moveObjectToCollection', objectId: id, collectionId, keepExistingLinks }); }} onMoveCollection={(collectionId, parentCollectionId) => void applyEditCommand(coreSceneCommands.moveCollection(collectionId, parentCollectionId))} onSelect={selectObject} onRefresh={refreshOutliner} onSelectAll={selectAllOutliner} onToggleVisibility={(id, visible) => void applyEditCommand({ type: "setObjectVisibility", objectId: id, visible })} onDeleteObject={(id, hierarchy) => void applyEditCommand({ type: "deleteObject", objectId: id, hierarchy })} onDeleteCollection={(collectionId, hierarchy) => void applyEditCommand({ type: "deleteCollection", collectionId, hierarchy })} onSelectBox={(firstRowId,lastRowId,mode,id)=>setOutlinerSelectBox(firstRowId,lastRowId,mode,id)} onIdOperation={(firstRowId,operation,id)=>setOutlinerIdOperation(firstRowId,operation,id)} onModeToggle={(rowId,extend,id)=>setOutlinerModeToggle(rowId,extend,id)} />; case "Properties": return queueLocalDesktopOperator("fluid." + operation, {}, true, objectId, "OBJECT") : undefined} pointCacheBusy={headerBusy || Boolean(localInvokePending) || localInvokeActive || nativeModalActive || projectActionLocked} onPointCacheOperation={localOnly ? operation => queueLocalDesktopOperator(operation === "BAKE_ALL" ? "ptcache.bake_all" : "ptcache.free_bake_all", operation === "BAKE_ALL" ? { bake: true } : {}, true) : undefined} selectedEdgeIndices={meshSelection.mode === "EDGE" ? [...meshSelection.indices] : []} nonMeshGeometryBuffers={nonMeshGeometryBuffers} client={webClientRef.current} snapshot={snapshot} uiMode={uiState.context.mode} onSetMode={(mode) => dispatchUI({type:'setMode', mode})} editorWorkflow={editorWorkflow} onExecutePython={executePythonAndApply} objectCameraId={objectCameraId} onObjectCameraChange={setObjectCameraId} onSimulatePhysics={simulatePhysicsRange} physicsSimulationRange={snapshot?.scenes[0]?.renderSettings ? { start: snapshot.scenes[0].renderSettings.frameStart, end: snapshot.scenes[0].renderSettings.frameEnd } : undefined} onImportSequencerMedia={importSequencerMedia} onRestoreSequencerMedia={restoreSequencerMedia} selectedFaceIndices={meshSelection.mode === "FACE" ? [...meshSelection.indices] : []} selectedVertexIndices={meshSelection.mode === "VERT" ? [...meshSelection.indices] : []} greasePencilSelection={greasePencilSelection} onGreasePencilCanvasPointSelect={(point, mode, baseSelectionRevision) => { commitGreasePencilSelection("CANVAS_2D", mode === "ADD" ? "TOGGLE" : mode, [point], baseSelectionRevision, point); }} onCommand={(command) => applyEditCommand(command)} onImportImage={(file) => void importImage(file)} onImportVFont={(file) => void importVFont(file)} onRequestAsset={(assetId) => { const client = webClientRef.current; if (!client) return; void client.requestAsset(assetId).then((asset) => setEngineStatus(`Asset: ${asset.assetId} (${asset.status})`)).catch((error: unknown) => setEngineStatus(recordDiagnostic("ENGINE", "PBR_ASSET_INVALID", error, { assetId }))); }} onAppendLibraryObject={async (source, request) => { const client = webClientRef.current; if (!client) return; const appendProjectId = projectIdRef.current; const isCurrent = () => client === webClientRef.current && appendProjectId === projectIdRef.current; @@ -10836,9 +10836,9 @@ else: {localOnly ? fileInputRef.current?.click()} onSearch={() => dispatchUI({ type: "toggleOperatorSearch", open: true })} /> : workspace === "Geometry Nodes" ? : null} {scriptingMounted.current ? !projectActionMutexRef.current.owner} onDraftChanged={dirty=>{if(dirty)textDraftAreas.current.add('web-tools-text');else textDraftAreas.current.delete('web-tools-text');textDraftDirty.current=textDraftAreas.current.size>0;}} onNativeRun={localOnly?undefined:(name,source)=>void runNativeWorkflow({kind:'PYTHON',context:nativeContext(),python:{source,textName:name,console:false}})} onPythonRun={pythonSession?(name,source)=>pythonSession.run(source,name,false):undefined} pythonBusy={pythonState?.status==='running'||pythonState?.status==='stopping'}/> - {pythonSession?:} fileInputRef.current?.click()} onSearch={() => dispatchUI({ type: "toggleOperatorSearch", open: true })} /> applyEditCommand(command, undefined, feedback)} onReparent={(ids, parentId, keepTransform) => void applyEditCommand({ type: 'setParents', objectIds: ids, parentId, keepTransform })} onMoveToCollection={(ids, collectionId, keepExistingLinks) => { for (const id of ids) void applyEditCommand({ type: 'moveObjectToCollection', objectId: id, collectionId, keepExistingLinks }); }} onMoveCollection={(collectionId, parentCollectionId) => void applyEditCommand(coreSceneCommands.moveCollection(collectionId, parentCollectionId))} onSelect={selectObject} onRefresh={refreshOutliner} onSelectAll={selectAllOutliner} onToggleVisibility={(id, visible) => void applyEditCommand({ type: "setObjectVisibility", objectId: id, visible })} onDeleteObject={(id) => void applyEditCommand({ type: "deleteObject", objectId: id })} onDeleteCollection={(collectionId, hierarchy) => void applyEditCommand({ type: "deleteCollection", collectionId, hierarchy })} onSelectBox={(firstRowId,lastRowId,mode,id)=>setOutlinerSelectBox(firstRowId,lastRowId,mode,id)} onIdOperation={(firstRowId,operation,id)=>setOutlinerIdOperation(firstRowId,operation,id)} onModeToggle={(rowId,extend,id)=>setOutlinerModeToggle(rowId,extend,id)} /> : null} + {pythonSession?:} fileInputRef.current?.click()} onSearch={() => dispatchUI({ type: "toggleOperatorSearch", open: true })} /> applyEditCommand(command, undefined, feedback)} onReparent={(ids, parentId, keepTransform) => void applyEditCommand({ type: 'setParents', objectIds: ids, parentId, keepTransform })} onMoveToCollection={(ids, collectionId, keepExistingLinks) => { for (const id of ids) void applyEditCommand({ type: 'moveObjectToCollection', objectId: id, collectionId, keepExistingLinks }); }} onMoveCollection={(collectionId, parentCollectionId) => void applyEditCommand(coreSceneCommands.moveCollection(collectionId, parentCollectionId))} onSelect={selectObject} onRefresh={refreshOutliner} onSelectAll={selectAllOutliner} onToggleVisibility={(id, visible) => void applyEditCommand({ type: "setObjectVisibility", objectId: id, visible })} onDeleteObject={(id, hierarchy) => void applyEditCommand({ type: "deleteObject", objectId: id, hierarchy })} onDeleteCollection={(collectionId, hierarchy) => void applyEditCommand({ type: "deleteCollection", collectionId, hierarchy })} onSelectBox={(firstRowId,lastRowId,mode,id)=>setOutlinerSelectBox(firstRowId,lastRowId,mode,id)} onIdOperation={(firstRowId,operation,id)=>setOutlinerIdOperation(firstRowId,operation,id)} onModeToggle={(rowId,extend,id)=>setOutlinerModeToggle(rowId,extend,id)} /> : null} setCameraLocks(current=>({...current,"viewport-area":locked}))} onSelect={selectObject} onBoxSelect={selectObjectsInBox} onElementBoxSelect={selectMeshElementsInBox} onElementSelect={selectMeshElement} onGreasePencilPointSelect={selectGreasePencilPoint} onGreasePencilMarqueeSelect={selectGreasePencilMarquee} onTransform={transformActive} transformSettings={viewportTransformSettings} elementGizmo={elementGizmoFrame} onGizmoDrag={onGizmoDrag}onSetObjectTransform={(objectId, translation, rotationEuler, scale) => void applyEditCommand({ type: "setObjectTransform", objectId, translation, rotationEuler, scale })} onDiagnostic={recordDiagnostic} mode={uiState.context.mode} onMeshEdit={runMeshEdit} onMeshSelectionMode={setMeshSelectionMode} onSelectAllMeshElements={selectAllMeshElements} onAddPrimitive={(primitive) => void applyEditCommand(coreSceneCommands.createPrimitive(primitive))} onFocusSculptProperties={() => focusProperty('[data-testid="sculpt-editor"]')} onVoxelRemesh={(voxelSize) => void invokeNativeOperator('object.voxel_remesh', { voxel_size: voxelSize })} /> - applyEditCommand(command, undefined, feedback)} onReparent={(ids, parentId, keepTransform) => void applyEditCommand({ type: 'setParents', objectIds: ids, parentId, keepTransform })} onMoveToCollection={(ids, collectionId, keepExistingLinks) => { for (const id of ids) void applyEditCommand({ type: 'moveObjectToCollection', objectId: id, collectionId, keepExistingLinks }); }} onMoveCollection={(collectionId, parentCollectionId) => void applyEditCommand(coreSceneCommands.moveCollection(collectionId, parentCollectionId))} onSelect={selectObject} onRefresh={refreshOutliner} onSelectAll={selectAllOutliner} onToggleVisibility={(id, visible) => void applyEditCommand({ type: "setObjectVisibility", objectId: id, visible })} onDeleteObject={(id) => void applyEditCommand({ type: "deleteObject", objectId: id })} onDeleteCollection={(collectionId, hierarchy) => void applyEditCommand({ type: "deleteCollection", collectionId, hierarchy })} onSelectBox={(firstRowId,lastRowId,mode,id)=>setOutlinerSelectBox(firstRowId,lastRowId,mode,id)} onIdOperation={(firstRowId,operation,id)=>setOutlinerIdOperation(firstRowId,operation,id)} onModeToggle={(rowId,extend,id)=>setOutlinerModeToggle(rowId,extend,id)} /> + applyEditCommand(command, undefined, feedback)} onReparent={(ids, parentId, keepTransform) => void applyEditCommand({ type: 'setParents', objectIds: ids, parentId, keepTransform })} onMoveToCollection={(ids, collectionId, keepExistingLinks) => { for (const id of ids) void applyEditCommand({ type: 'moveObjectToCollection', objectId: id, collectionId, keepExistingLinks }); }} onMoveCollection={(collectionId, parentCollectionId) => void applyEditCommand(coreSceneCommands.moveCollection(collectionId, parentCollectionId))} onSelect={selectObject} onRefresh={refreshOutliner} onSelectAll={selectAllOutliner} onToggleVisibility={(id, visible) => void applyEditCommand({ type: "setObjectVisibility", objectId: id, visible })} onDeleteObject={(id, hierarchy) => void applyEditCommand({ type: "deleteObject", objectId: id, hierarchy })} onDeleteCollection={(collectionId, hierarchy) => void applyEditCommand({ type: "deleteCollection", collectionId, hierarchy })} onSelectBox={(firstRowId,lastRowId,mode,id)=>setOutlinerSelectBox(firstRowId,lastRowId,mode,id)} onIdOperation={(firstRowId,operation,id)=>setOutlinerIdOperation(firstRowId,operation,id)} onModeToggle={(rowId,extend,id)=>setOutlinerModeToggle(rowId,extend,id)} /> queueLocalDesktopOperator("fluid." + operation, {}, true, objectId, "OBJECT") : undefined} pointCacheBusy={headerBusy || Boolean(localInvokePending) || localInvokeActive || nativeModalActive || projectActionLocked} onPointCacheOperation={localOnly ? operation => queueLocalDesktopOperator(operation === "BAKE_ALL" ? "ptcache.bake_all" : "ptcache.free_bake_all", operation === "BAKE_ALL" ? { bake: true } : {}, true) : undefined} selectedEdgeIndices={meshSelection.mode === "EDGE" ? [...meshSelection.indices] : []} nonMeshGeometryBuffers={nonMeshGeometryBuffers} client={webClientRef.current} snapshot={snapshot} uiMode={uiState.context.mode} onSetMode={(mode) => dispatchUI({type:'setMode', mode})} editorWorkflow={editorWorkflow} onExecutePython={executePythonAndApply} objectCameraId={objectCameraId} onObjectCameraChange={setObjectCameraId} onSimulatePhysics={simulatePhysicsRange} physicsSimulationRange={snapshot?.scenes[0]?.renderSettings ? { start: snapshot.scenes[0].renderSettings.frameStart, end: snapshot.scenes[0].renderSettings.frameEnd } : undefined} onImportSequencerMedia={importSequencerMedia} onRestoreSequencerMedia={restoreSequencerMedia} selectedFaceIndices={meshSelection.mode === "FACE" ? [...meshSelection.indices] : []} selectedVertexIndices={meshSelection.mode === "VERT" ? [...meshSelection.indices] : []} greasePencilSelection={greasePencilSelection} onGreasePencilCanvasPointSelect={(point, mode, baseSelectionRevision) => { commitGreasePencilSelection("CANVAS_2D", mode === "ADD" ? "TOGGLE" : mode, [point], baseSelectionRevision, point); }} onCommand={(command) => applyEditCommand(command)} onImportImage={(file) => void importImage(file)} onImportVFont={(file) => void importVFont(file)} onRequestAsset={(assetId) => { const client = webClientRef.current; if (!client) return; void client.requestAsset(assetId).then((asset) => setEngineStatus(`Asset: ${asset.assetId} (${asset.status})`)).catch((error: unknown) => setEngineStatus(recordDiagnostic("ENGINE", "PBR_ASSET_INVALID", error, { assetId }))); }} onAppendLibraryObject={async (source, request) => { const client = webClientRef.current; if (!client) return; const appendProjectId = projectIdRef.current; const isCurrent = () => client === webClientRef.current && appendProjectId === projectIdRef.current; try { const result = await client.appendLibraryObject(source, request); if (!isCurrent()) return; const logicalRevision = Math.max(projectRevisionRef.current + 1, result.snapshot.revision); projectRevisionRef.current = logicalRevision; const ownsRevision = () => isCurrent() && projectRevisionRef.current === logicalRevision; setSnapshot(result.snapshot); setSelectedObjectIds(selectionFromSnapshot(result.snapshot)); setGeometryBuffers(result.geometryBuffers); setNonMeshGeometryBuffers(result.nonMeshGeometryBuffers ?? []); setFrame(result.snapshot.frame.current); setPreview(null); setLodLevels(null); setDirtyState(current => { const accepted = acceptMainTransaction(current, logicalRevision); return accepted.ok ? accepted.state : current; }); diff --git a/web/app/src/vendor/blender/web_engine.wasm b/web/app/src/vendor/blender/web_engine.wasm index 41b33eb7c..9fbe52af4 100644 Binary files a/web/app/src/vendor/blender/web_engine.wasm and b/web/app/src/vendor/blender/web_engine.wasm differ diff --git a/web/protocol/web-engine.ts b/web/protocol/web-engine.ts index 07aa3f563..4150ac693 100644 --- a/web/protocol/web-engine.ts +++ b/web/protocol/web-engine.ts @@ -133,7 +133,7 @@ export type WebEngineEditCommand = | { type: "previewDecimateMesh"; meshId: string; profile: SimplifyProfile } | { type: "createPrimitive"; primitive: MeshPrimitive; name?: string; location: [number, number, number] } | { type: "duplicateObject"; objectId: string; offset?: [number, number, number]; linked?: boolean } - | { type: "deleteObject"; objectId: string } + | { type: "deleteObject"; objectId: string; hierarchy?: boolean } | { type: "setObjectTransform"; objectId: string; translation: [number, number, number]; rotationEuler: [number, number, number]; scale: [number, number, number] } | { type: "setArmatureBones"; objectId: string; bones: Array<{ name: string; parentName: string | null; head: [number, number, number]; tail: [number, number, number]; roll: number; connected?: boolean }> } | { type: "setPoseBoneTransform"; objectId: string; boneName: string; translation: [number, number, number]; rotationEuler: [number, number, number]; scale: [number, number, number] } diff --git a/web/tests/e2e/outliner-headed-production.spec.ts b/web/tests/e2e/outliner-headed-production.spec.ts index 43730881f..39aad5ae6 100644 --- a/web/tests/e2e/outliner-headed-production.spec.ts +++ b/web/tests/e2e/outliner-headed-production.spec.ts @@ -845,4 +845,37 @@ test.describe("Outliner headed baseline", () => { .evaluateAll(rows => rows.map(row => row.getAttribute("aria-label"))), { timeout: 30_000 }) .toEqual(expect.arrayContaining(["RootRig", "InspectionCamera", "Mount", "KeyLight", "Payload"])); }); + + test("[outliner-delete-hierarchy-web] the Data menu deletes the object and every child underneath it", async ({ page }) => { + test.setTimeout(180_000); + await page.goto("/?ui=web"); + await page.locator('[data-testid="blend-file-input"]').setInputFiles(HIERARCHY_SCENE); + await expect(page.locator(".blender-app")).toHaveAttribute("data-project-id", /.+/, { timeout: 60_000 }); + await expect(page.getByText(/Engine: SceneIR/).first()).toBeVisible({ timeout: 60_000 }); + const webTools = page.locator('[data-testid="native-web-tools-toggle"]'); + if (await webTools.count()) await webTools.click(); + await expect(page.locator(".outliner-tree").first()).toBeVisible({ timeout: 20_000 }); + + /* Children rows only render once their parent is open. */ + for (let pass = 0; pass < 3; pass++) { + for (const name of ["Scene Collection", "RootRig", "Mount"]) { + const toggle = page.getByRole("button", { name: `展开 ${name}`, exact: true }).first(); + if (await toggle.count()) await toggle.click(); + } + } + const rootRow = page.locator('.tree-row[aria-label="RootRig"]').first(); + await expect(rootRow).toBeVisible({ timeout: 30_000 }); + await expect(page.locator('.tree-row[aria-label="NewParent"]').first()).toBeVisible({ timeout: 20_000 }); + + /* Desktop OUTLINER_OT_delete with hierarchy=True removes the object and every + * descendant through the parent chains (outliner_batch_delete_object_hierarchy). */ + await rootRow.locator(".tree-node-name").first().click({ button: "right" }); + const deleteHierarchy = page.getByRole("menuitem", { name: "删除层级 (Delete Hierarchy)", exact: true }); + await expect(deleteHierarchy).toBeEnabled(); + await deleteHierarchy.click(); + for (const name of ["RootRig", "InspectionCamera", "Mount", "KeyLight", "Payload"]) { + await expect(page.locator(`.tree-row[aria-label="${name}"]`)).toHaveCount(0, { timeout: 30_000 }); + } + await expect(page.locator('.tree-row[aria-label="NewParent"]').first()).toBeVisible({ timeout: 20_000 }); + }); });