Add tests and implement boundary smoothing and cutout functionality
- Introduced tests for boundary smoothing in `test_boundary_smoothing.py`, verifying that smoothing reduces stair-step artifacts while preserving boundary integrity. - Added tests for cutout boundary behavior in `test_cutout_boundary.py`, ensuring proper handling of boundary triangles and normal blending. - Created `test_temporary_attributes.py` to check the cleanup of temporary attributes across depth modifier branches, ensuring no warnings are raised. - Implemented point culling functionality in `test_validity.py`, confirming that invalid points are removed without affecting adjacent geometry. - Developed boundary smoothing logic in `boundary_smoothing.py`, allowing for depth smoothing while maintaining edge integrity. - Added cutout boundary management in `cutout_boundary.py`, including functions for removing boundary triangles and tapering thickness profiles. - Implemented validity checks in `validity.py` to ensure proper deletion of invalid vertices and associated wire edges.
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
schema: spec-driven
|
||||
created: 2026-09-10
|
||||
38
openspec/changes/update-pasted-brush-preview/design.md
Normal file
38
openspec/changes/update-pasted-brush-preview/design.md
Normal file
@@ -0,0 +1,38 @@
|
||||
## Context
|
||||
|
||||
`set_tool_texture()` 先取得可编辑笔刷,再绑定图片纹理、设置 STENCIL 和颜色。外部库笔刷通过 `asset_save_as` 创建并激活本地副本;已有可编辑笔刷直接复用。剪贴板图片已打包,加载时的临时文件随即删除。
|
||||
|
||||
## Goals
|
||||
|
||||
在 Texture Paint 粘贴流程中,让当前笔刷预览与绑定图片一致,保持图片比例,并随当前文件保存。
|
||||
|
||||
## Decisions
|
||||
|
||||
### 在纹理绑定成功后更新本地笔刷预览
|
||||
|
||||
更新入口保留在 `clipboard_image/actions.py`,以 `PAINT_TEXTURE` 判断模式,使用 `_ensure_editable_brush()` 返回的笔刷。所有 Blender 数据操作在 Operator 主线程阶段完成。
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
A[取得已打包的粘贴图片] --> B[取得可编辑笔刷]
|
||||
B --> C[绑定纹理并设置 STENCIL]
|
||||
C --> D{Texture Paint 模式}
|
||||
D -->|是| E[从图片导出临时预览文件]
|
||||
E --> F[为当前笔刷加载自定义预览]
|
||||
F --> G[清理临时文件并刷新界面]
|
||||
D -->|否| G
|
||||
```
|
||||
|
||||
### 使用 Blender 自定义预览加载能力
|
||||
|
||||
复用 `common` 中适合的图片导出函数,生成临时 PNG,通过覆盖上下文的 `id` 指向目标笔刷,调用 `bpy.ops.ed.lib_id_load_custom_preview`。由 Blender 生成缩略图,保持比例与透明区域。预览加载完成后清理临时文件,预览数据由笔刷保存。
|
||||
|
||||
### 单独处理预览更新失败
|
||||
|
||||
预览更新与已有纹理绑定异常处理分开。加载失败时保留已绑定纹理和可用笔刷,通过现有 Operator 报告渠道提示预览更新失败。临时文件在成功与失败路径均清理。
|
||||
|
||||
## Risks / Trade-offs
|
||||
|
||||
- 自定义预览 Operator 的上下文和界面缓存可能影响可见效果 → 在项目支持的 Blender 版本中验证当前笔刷选择器、资产架与切换笔刷后的显示。
|
||||
- 图片导出可能影响色彩或源数据 → 复用图片导出能力,验证透明图和非正方形图,确保源图片像素、尺寸及打包状态保持。
|
||||
- 预览保存行为需真实 Blender 验证 → 保存并重新打开 `.blend`,确认本地笔刷预览在临时文件清理后仍可显示。
|
||||
24
openspec/changes/update-pasted-brush-preview/proposal.md
Normal file
24
openspec/changes/update-pasted-brush-preview/proposal.md
Normal file
@@ -0,0 +1,24 @@
|
||||
## Why
|
||||
|
||||
Texture Paint 模式粘贴图片后,笔刷已使用该图片作为纹理,但图标仍显示原有预览,难以直接识别绘制内容。将笔刷图标同步为粘贴图片,让选择笔刷时的视觉提示与实际纹理一致。
|
||||
|
||||
## What Changes
|
||||
|
||||
- Texture Paint 模式绑定粘贴图片后,同步更新当前可编辑笔刷的自定义预览。
|
||||
- 预览保持图片比例,支持已打包的剪贴板图片及重复粘贴更新。
|
||||
- 验证预览即时刷新,以及保存并重新打开文件后的保留效果。
|
||||
|
||||
## Capabilities
|
||||
|
||||
### New Capabilities
|
||||
|
||||
- `pasted-brush-preview`: Texture Paint 粘贴图片与笔刷预览同步。
|
||||
|
||||
### Modified Capabilities
|
||||
|
||||
## Impact
|
||||
|
||||
- `src/anyimage/operators/clipboard_image/actions.py`:笔刷纹理绑定与预览更新。
|
||||
- `src/anyimage/common/image.py`:复用现有图片读取或导出能力。
|
||||
- `tests/anyimage/operators/test_clipboard_image.py`:增加预览行为覆盖。
|
||||
- 使用 Blender 自定义预览 API,沿用现有依赖。
|
||||
@@ -0,0 +1,41 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Texture Paint 粘贴同步笔刷预览
|
||||
|
||||
系统 SHALL 在 Texture Paint 模式成功绑定粘贴图片后,将当前可编辑笔刷的自定义预览更新为该图片,并刷新相关界面。
|
||||
|
||||
#### Scenario: 外部库笔刷首次粘贴
|
||||
- **WHEN** 当前笔刷来自外部库,用户在 Texture Paint 模式粘贴图片
|
||||
- **THEN** 创建并激活的本地笔刷副本使用该图片作为纹理和自定义预览
|
||||
|
||||
#### Scenario: 已有笔刷重复粘贴
|
||||
- **WHEN** 用户向当前可编辑笔刷粘贴另一张图片
|
||||
- **THEN** 同一笔刷的纹理和预览同步更新为新图片
|
||||
|
||||
#### Scenario: 其他绘制模式粘贴
|
||||
- **WHEN** 用户在 Sculpt 或 Vertex Paint 模式粘贴图片
|
||||
- **THEN** 系统沿用该模式现有纹理绑定行为并保留笔刷原预览
|
||||
|
||||
### Requirement: 预览使用已打包图片并保留显示效果
|
||||
|
||||
系统 SHALL 支持从已打包的剪贴板图片生成预览,保持图片宽高比和透明区域;源图片像素、尺寸及打包状态 MUST 保持。
|
||||
|
||||
#### Scenario: 非正方形透明图片
|
||||
- **WHEN** 用户粘贴已打包且原临时文件已删除的非正方形透明图片
|
||||
- **THEN** 笔刷预览展示完整图片,保持比例和透明区域,源图片数据保持
|
||||
|
||||
### Requirement: 预览随文件保存
|
||||
|
||||
笔刷自定义预览 SHALL 随当前 `.blend` 文件保存,在预览临时文件清理后仍可恢复。
|
||||
|
||||
#### Scenario: 保存后重新打开
|
||||
- **WHEN** 用户成功更新笔刷预览,保存并重新打开 `.blend` 文件
|
||||
- **THEN** 对应本地笔刷仍显示该图片预览
|
||||
|
||||
### Requirement: 预览失败保留可用纹理
|
||||
|
||||
预览更新失败时系统 SHALL 保留已绑定纹理并提示预览更新失败;预览临时文件 MUST 在成功或失败后清理。
|
||||
|
||||
#### Scenario: Blender 拒绝加载预览
|
||||
- **WHEN** 纹理已绑定但自定义预览加载失败
|
||||
- **THEN** 笔刷仍可使用粘贴纹理绘制,用户收到预览失败提示,临时文件被清理
|
||||
13
openspec/changes/update-pasted-brush-preview/tasks.md
Normal file
13
openspec/changes/update-pasted-brush-preview/tasks.md
Normal file
@@ -0,0 +1,13 @@
|
||||
## 1. 笔刷预览更新
|
||||
|
||||
- [x] 1.1 在项目支持的 Blender 中验证以笔刷为上下文加载自定义预览的 API、图片比例及保存行为。
|
||||
- [x] 1.2 复用 common 图片导出能力,从已打包图片生成临时预览并更新笔刷,保证临时文件清理及源图片数据保持。
|
||||
- [x] 1.3 在 Texture Paint 纹理绑定成功后接入预览更新和界面刷新,独立处理预览失败提示并保留已绑定纹理。
|
||||
|
||||
## 2. 验证
|
||||
|
||||
- [x] 2.1 更新剪贴板测试,覆盖本地副本、已有笔刷重复粘贴、模式范围、预览失败和临时文件清理,运行相关测试。
|
||||
- [ ] 2.2 在真实 Blender 中验证非正方形透明图片、笔刷选择器与资产架刷新、切换笔刷及保存重开后的预览,并检查源图片数据保持。
|
||||
- [x] 2.3 检查最终差异与旧引用,确认改动集中于笔刷预览和相关测试。
|
||||
|
||||
验证记录:55 项测试、15 个子场景通过;Blender 4.5.10 后台验证了非正方形透明图片、源数据保持及保存重开后的预览。2.2 尚待界面目视检查笔刷选择器、资产架与切换笔刷后的显示,当前会话未提供 Blender 界面控制工具。测试使用 `uv run --no-sync`,因为本地 BlendJob wheel 与锁文件哈希不一致。
|
||||
Reference in New Issue
Block a user