Files
AnyImage/tests/anyimage/test_image_menu.py
nan 591e62085a feat(cutout): implement boundary padding for cutout textures
- Introduced a new `Boundary Padding` preference in the Cutout Tool with a default of 2 px and a configurable range of 1-4 px.
- Updated the Cutout client to establish inward mapping from the final Mask, sampling in a fixed direction and processing independent material RGBA and Depth.
- Enhanced the handling of RGBA and Depth during cutout operations, ensuring proper mapping and preservation of source data.
- Added tests to validate the new boundary padding functionality and its integration with existing cutout processes.

feat(geometry): remove overall mesh smoothing from geometry nodes

- Removed the `Smooth` input from several geometry node groups to eliminate unnecessary overall mesh smoothing.
- Retained `Smooth Weight` for depth nodes while removing it from Cutout and Relief Plane nodes.
- Ensured that boundary, normal, and fill smoothing behaviors remain intact and consistent.
- Updated tests and documentation to reflect the changes in node interfaces and behaviors.

feat(normals): scale tangent normals with depth

- Reused the existing `o_normal_reduction` attribute to adjust Tangent Normal strength based on the geometry's `Depth Scale`.
- Ensured that Tangent Normal strength is consistent with the geometry depth, preserving full strength for materials that do not provide the attribute.
- Updated tests to verify the correct behavior of normal strength adjustments in both Tangent and Object Space.
2026-09-15 00:40:24 +08:00

99 lines
3.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from types import SimpleNamespace
from unittest.mock import patch
from tests.support.blender import BlenderTestCase
class ImageMenuTest(BlenderTestCase):
def test_image_menu_keeps_ai_features_clickable_and_offers_models(self):
calls, labels = self.draw_menu(
{
"environment_ready": True,
"missing_models": ("BEN2_BASE",),
"ready": False,
}
)
self.assertEqual(
calls,
[
("anyimage.convert_to_plane", True),
("anyimage.convert_to_depth_plane", True),
("anyimage.convert_to_relief_plane", True),
("anyimage.convert_to_panorama", True),
("separator", True),
("anyimage.remove_image_background", True),
("anyimage.upscale_image", True),
("separator", True),
("anyimage.setup_ai_environment", True),
],
)
self.assertEqual(
labels["anyimage.setup_ai_environment"],
"Download Required Models…",
)
self.assertEqual(
labels["anyimage.upscale_image"],
"Upscale (1280 × 960)",
)
calls, _labels = self.draw_menu(
{"environment_ready": True, "missing_models": (), "ready": True}
)
self.assertIn(("anyimage.open_ai_environment_settings", True), calls)
self.assertNotIn(("anyimage.setup_ai_environment", True), calls)
def draw_menu(self, status):
calls = []
labels = {}
class Layout:
operator_context = ""
enabled = True
def operator(self, identifier, **options):
calls.append((identifier, self.enabled))
labels[identifier] = options.get("text")
return SimpleNamespace()
def separator(self):
calls.append(("separator", self.enabled))
menu = self.anyimage.AnyImageImageMenu()
menu.layout = Layout()
with patch("anyimage.properties.ai_status", return_value=status):
menu.draw(
SimpleNamespace(
object=SimpleNamespace(
type="EMPTY",
empty_display_type="IMAGE",
data=SimpleNamespace(size=(640, 480)),
)
)
)
return calls, labels
def test_image_operators_stay_clickable_until_server_is_busy(self):
context = SimpleNamespace(
object=SimpleNamespace(type="EMPTY", empty_display_type="IMAGE", data=SimpleNamespace()),
)
operators = (
self.convert_to_plane.ConvertToDepthPlane,
self.convert_to_plane.ConvertToReliefPlane,
self.remove_background.RemoveImageBackground,
)
for busy, expected in ((False, True), (True, False)):
with (
self.subTest(busy=busy),
patch.object(
self.anyimage.runtime,
"server_busy",
return_value=busy,
),
):
for operator in operators:
with self.subTest(operator=operator.__name__):
self.assertEqual(operator.poll(context), expected)