Update processing resolution to 504 and enhance depth model persistence in conversion dialog

This commit is contained in:
2026-08-03 16:51:08 +08:00
parent a503786c62
commit 69eaefa016
4 changed files with 35 additions and 5 deletions

View File

@@ -160,7 +160,7 @@ CC BY-NC 4.0,仅限非商业用途。
界面使用 DA3 API 的参数名、选项和默认值。GLB 专属设置仅在选择 `GLB` 时显示,
`gs_views_interval` 仅在选择 `PLY (3DGS)` 时显示:
- `process_res=1024`
- `process_res=504`
- `process_res_method="upper_bound_resize"`
- `use_ray_pose=False`
- `ref_view_strategy="saddle_balanced"`

View File

@@ -30,6 +30,9 @@ def image_depth_model_items(owner, context):
return model_enum_items(owner, context)
_last_depth_plane_model = "BASE"
def is_image_empty(candidate):
return bool(
candidate
@@ -775,8 +778,10 @@ class ConvertImageToDepthPlane(bpy.types.Operator):
return is_image_empty(context.object) and active_job() is None
def invoke(self, context, _event):
global _last_depth_plane_model
if not self.properties.is_property_set("snapform_model"):
self.snapform_model = "BASE"
self.snapform_model = _last_depth_plane_model
return context.window_manager.invoke_props_dialog(self, width=340)
def draw(self, context):
@@ -867,6 +872,8 @@ class ConvertImageToDepthPlane(bpy.types.Operator):
if delete_input:
source_path.unlink(missing_ok=True)
return {"CANCELLED"}
global _last_depth_plane_model
_last_depth_plane_model = self.snapform_model
return {"FINISHED"}

View File

@@ -39,7 +39,7 @@ class SnapFormSettings(bpy.types.PropertyGroup):
process_res: bpy.props.IntProperty(
name="Process Res",
description="DA3 base processing resolution",
default=1024,
default=504,
min=1,
soft_max=2048,
)

View File

@@ -74,6 +74,7 @@ class AddonTest(unittest.TestCase):
self.status_bar_draws.clear()
self.context_menu_draws.clear()
self.addon.operators._active_job = None
self.addon.image_depth._last_depth_plane_model = "BASE"
if hasattr(self.fake_bpy.types.Scene, "snapform_settings"):
del self.fake_bpy.types.Scene.snapform_settings
@@ -237,6 +238,23 @@ class AddonTest(unittest.TestCase):
inspect.getsource(operator),
)
def test_conversion_dialog_remembers_last_depth_model(self):
operator = self.addon.ConvertImageToDepthPlane()
operator.properties = SimpleNamespace(
is_property_set=lambda _name: False,
)
context = SimpleNamespace(
window_manager=SimpleNamespace(
invoke_props_dialog=lambda invoked, **_options: invoked,
),
)
self.addon.image_depth._last_depth_plane_model = "GIANT_1_1"
result = operator.invoke(context, None)
self.assertIs(result, operator)
self.assertEqual(operator.snapform_model, "GIANT_1_1")
def test_depth_conversion_progress_is_provider_neutral(self):
starting_source = inspect.getsource(
self.addon.RunJob._starting_message
@@ -266,7 +284,7 @@ class AddonTest(unittest.TestCase):
def test_packed_image_is_exported_without_unpacking(self):
operator = self.addon.ConvertImageToDepthPlane()
operator.snapform_depth_source = "ESTIMATE"
operator.snapform_model = "BASE"
operator.snapform_model = "GIANT_1_1"
operator.snapform_use_ray_pose = True
operator.snapform_process_res_factor = 0.5
operator.snapform_displacement_via = "MATERIAL"
@@ -303,11 +321,16 @@ class AddonTest(unittest.TestCase):
save_packed_image.assert_called_once_with(image, context.scene)
self.assertEqual(calls[0]["snapform_input_path"], str(packed_path))
self.assertEqual(calls[0]["snapform_process_res"], 960)
self.assertEqual(calls[0]["snapform_model_key"], "GIANT_1_1")
self.assertEqual(
calls[0]["snapform_displacement_via"],
"MATERIAL",
)
self.assertTrue(calls[0]["snapform_delete_input"])
self.assertEqual(
self.addon.image_depth._last_depth_plane_model,
"GIANT_1_1",
)
def test_packed_image_export_writes_a_png_copy(self):
class PackedImage:
@@ -458,7 +481,7 @@ class AddonTest(unittest.TestCase):
]
)
self.assertEqual(process_res["default"], 1024)
self.assertEqual(process_res["default"], 504)
self.assertEqual(process_res_method["default"], "upper_bound_resize")
def test_reconstruct_command_preserves_da3_parameter_names(self):