Refactor depth reference handling and cleanup

- Unified reference depth calculation to use a single implementation in common/depth.py.
- Removed server-side reference depth computation and adjusted depth.json to only include image_size and intrinsics.
- Updated depth texture handling to ignore transparent, invalid, and non-positive pixels when calculating reference depth.
- Changed reference depth calculation to use the 95th percentile of valid depth values.
- Adjusted depth direction fitting to return a flat direction when no samples are available.
- Removed cleanup threshold parameters from Cutout and related nodes, simplifying the interface.
- Updated tests to verify new reference depth logic and ensure compatibility with existing functionality.
This commit is contained in:
2026-09-15 22:50:16 +08:00
parent 94130ff38f
commit 2dfa9b2add
37 changed files with 665 additions and 639 deletions

View File

@@ -118,25 +118,30 @@ def test_operator_length_property_accepts_world_units():
bpy.utils.unregister_class(CutoutLengthTestOperator)
def test_effective_length_report_and_geometry_share_value():
def test_effective_length_report_and_geometry_build_share_value():
report = Mock()
context = SimpleNamespace(scene=SimpleNamespace(unit_settings=SimpleNamespace(system="METRIC", scale_length=0.01)))
source = object()
content = np.ones((10, 10))
with patch.object(operators, "effective_cutout_edge_length", return_value=20), \
patch.object(operators, "build_base_shape") as build, \
patch.object(operators, "create_shape_object") as create, \
patch.object(operators.bpy.ops.ed, "undo_push", return_value={"FINISHED"}):
operators.create_cutout_shape(
context,
object(),
source,
"FLAT",
10,
np.ones((10, 10)),
content,
(0, 0, 10, 10),
boundary_padding=0.0,
color_image=object(),
report=report,
)
assert build.call_args.args[2] == 20
assert create.call_args.args[3] == 20
assert create.call_args.args[0] is context
assert create.call_args.args[1] is source
assert create.call_args.args[2] == "FLAT"
assert create.call_args.args[3] is content
assert report.call_args.args[0] == {"INFO"}
assert "20 cm" in report.call_args.args[1]