- Added interaction helpers for cutout region validation and shape menu interaction. - Created main operator for converting image regions into cutout shapes, including AI artifact generation. - Introduced object creation logic for cutout shapes, handling depth and normal textures. - Defined cutout shape identifiers and node groups for various shape types. - Implemented depth texture writing and prediction artifact generation for MoGe-2. - Developed server jobs for generating cutout artifacts, depth planes, and refining image regions. - Added region refinement logic to enhance gesture masks using BEN2.
42 lines
2.3 KiB
Markdown
42 lines
2.3 KiB
Markdown
# 剪贴板图片
|
||
|
||
剪贴板图片从 `Ctrl/Cmd + V` 开始,把操作系统中的图片变成 Packed Blender Image,并放到当前编辑器支持的位置。
|
||
|
||
## 执行过程
|
||
|
||
```mermaid
|
||
flowchart TD
|
||
Paste["Ctrl/Cmd + V"] --> Priority{"刚执行过 Blender Copy?"}
|
||
Priority -- "是" --> Native["交回原生 Paste"]
|
||
Priority -- "否" --> Read["读取系统图片"]
|
||
Read --> Image["复用或创建 Packed Image"]
|
||
Image --> Target{"当前编辑器"}
|
||
Target --> View["Reference / Plane"]
|
||
Target --> Node["Image Node"]
|
||
Target --> Paint["Brush Texture"]
|
||
```
|
||
|
||
整条流程运行在 Blender 进程中,不使用 Job Server。快捷键会先尊重 Blender 自己的 Copy/Paste;只有系统剪贴板出现新的图片内容时,AnyImage 才接管粘贴。
|
||
|
||
## 节点说明
|
||
|
||
### 判断是否交给 Blender
|
||
|
||
`operators/clipboard_image/__init__.py` 注册 `TrackNativeCopy`、`PasteClipboardImage` 和 3D View、Node Editor 快捷键。`TrackNativeCopy` 记录 Blender Copy 时的系统剪贴板变化标记;粘贴时若标记没有变化,`PasteClipboardImage` 返回 `PASS_THROUGH`,让 Blender 继续处理对象或节点粘贴。
|
||
|
||
同一文件随后调用 `actions.target_for_context()` 判断当前编辑器是否支持图片落点。
|
||
|
||
### 读取系统图片
|
||
|
||
`clipboard.py` 负责平台差异。Windows 读取 DIB 或 DIBV5 并补成 BMP;macOS 和 Linux 调用系统提供的图片导出命令。无论来源平台,输出都收敛为图片字节和扩展名,后续步骤不再判断操作系统。
|
||
|
||
### 创建或复用 Packed Image
|
||
|
||
`actions.py` 对图片内容计算 SHA-256。相同内容已经粘贴过时会复用现有 Packed Image,否则创建新 Image 并 Pack 到当前 `.blend`,避免依赖临时剪贴板文件。
|
||
|
||
### 放到当前编辑器
|
||
|
||
落点仍在 `actions.py` 中完成:3D View 创建 Reference 或 Plane,Node Editor 创建与当前节点树匹配的 Image 节点,绘制模式把 Image 配置为当前画笔的 Texture。鼠标位置和视图位置也在这里换算。
|
||
|
||
Plane 路径调用 `convert_to_plane/mesh_plane.py` 创建基础网格,并使用 `convert_to_plane/nodes.py` 提供的 `O Mesh Plane` 节点组。`clipboard_image/__init__.py` 只负责入口和快捷键,具体 Blender 数据始终由 `actions.py` 创建。
|