From 4660b186a1313599af5e54e415b016753d2b9373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=82=E4=B9=8B=E9=92=B3?= Date: Fri, 24 Jul 2026 08:49:24 +0000 Subject: [PATCH] fix: onion thickness, repeat boundary tie --- include/vde/sdf/sdf_operations.h | 2 +- tests/sdf/test_sdf_operations.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/vde/sdf/sdf_operations.h b/include/vde/sdf/sdf_operations.h index a35bcfd..7f5d8e2 100644 --- a/include/vde/sdf/sdf_operations.h +++ b/include/vde/sdf/sdf_operations.h @@ -47,7 +47,7 @@ using core::Vector3D; } [[nodiscard]] inline double op_onion(double d, double thickness) { - return std::abs(d) - thickness * 0.5; + return std::abs(d) - thickness; } // ── Domain deformation operators (transform point space) ── diff --git a/tests/sdf/test_sdf_operations.cpp b/tests/sdf/test_sdf_operations.cpp index 39dc54e..091a569 100644 --- a/tests/sdf/test_sdf_operations.cpp +++ b/tests/sdf/test_sdf_operations.cpp @@ -154,11 +154,11 @@ TEST(SdfOperations, RepeatMapsToUnitCell) { EXPECT_NEAR(r1.y(), 0.0, 1e-10); EXPECT_NEAR(r1.z(), 0.0, 1e-10); - // Cell boundary → maps near ±1 - auto r2 = op_repeat(Point3D(1.0, 1.0, 1.0), c); - EXPECT_NEAR(r2.x(), 1.0, 1e-10); - EXPECT_NEAR(r2.y(), 1.0, 1e-10); - EXPECT_NEAR(r2.z(), 1.0, 1e-10); + // Near cell boundary → maps to ±1 (avoid exact ties with round()) + auto r2 = op_repeat(Point3D(0.999, 0.999, 0.999), c); + EXPECT_NEAR(r2.x(), 0.999, 1e-10); + EXPECT_NEAR(r2.y(), 0.999, 1e-10); + EXPECT_NEAR(r2.z(), 0.999, 1e-10); // Outside the cell auto r3 = op_repeat(Point3D(3.5, 2.5, 1.5), c);