- Introduced a new design for selection rasterization that decouples the selection geometry from the image content, ensuring that the SelectionMask is independent of the source image's alpha and color. - Updated the `rasterize_selection_path` function to only accept selection paths and image dimensions, removing parameters related to source alpha and alpha thresholds. - Implemented a new approach for handling selection paths using non-zero winding fill, ensuring overlapping areas are preserved. - Enhanced performance by utilizing a scanline algorithm for rasterization, significantly reducing processing time for high-resolution images. - Updated internal documentation and added comprehensive tests to validate the new behavior and performance improvements. - Ensured backward compatibility by maintaining existing interfaces where necessary while introducing breaking changes in the selection processing logic.
2.1 KiB
剪贴板图片
剪贴板图片从 Ctrl/Cmd + V 开始,把操作系统中的图片变成 Packed Blender Image,并放到当前编辑器支持的位置。
执行过程
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 自己的 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 创建中心原点基础网格,并从节点资产加载 O Mesh Plane。actions.py 创建图像材质并放入 Mesh 第 0 个材质槽,节点组只生成几何。