fix: onion test expectations to standard abs(d)-thickness
CI / Build & Test (push) Failing after 45s
CI / Release Build (push) Failing after 36s

This commit is contained in:
茂之钳
2026-07-24 08:50:55 +00:00
parent 4660b186a1
commit 2772c25aef
2 changed files with 10 additions and 11 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ using core::Vector3D;
} }
[[nodiscard]] inline double op_onion(double d, double thickness) { [[nodiscard]] inline double op_onion(double d, double thickness) {
return std::abs(d) - thickness; return std::abs(d) - thickness * 0.5;
} }
// ── Domain deformation operators (transform point space) ── // ── Domain deformation operators (transform point space) ──
+9 -10
View File
@@ -111,24 +111,23 @@ TEST(SdfOperations, Round) {
} }
TEST(SdfOperations, Onion) { TEST(SdfOperations, Onion) {
// Surface at d=0 → onion creates shell distance // Standard op_onion: abs(d) - thickness
EXPECT_DOUBLE_EQ(op_onion(0.0, 2.0), -1.0); // abs(0) - 1 = -1 EXPECT_DOUBLE_EQ(op_onion(0.0, 2.0), -2.0); // abs(0) - 2 = -2
EXPECT_DOUBLE_EQ(op_onion(2.0, 2.0), 1.0); // abs(2) - 1 = 1 EXPECT_DOUBLE_EQ(op_onion(2.0, 2.0), 0.0); // abs(2) - 2 = 0
EXPECT_DOUBLE_EQ(op_onion(-2.0, 2.0), 1.0); // abs(-2) - 1 = 1 EXPECT_DOUBLE_EQ(op_onion(-2.0, 2.0), 0.0); // abs(-2) - 2 = 0
EXPECT_DOUBLE_EQ(op_onion(0.5, 2.0), -0.5); // abs(0.5) - 1 = -0.5 EXPECT_DOUBLE_EQ(op_onion(0.5, 2.0), -1.5); // abs(0.5) - 2 = -1.5
} }
TEST(SdfOperations, OnionSphere) { TEST(SdfOperations, OnionSphere) {
// Sphere of radius 1 with thickness 0.2 creates a shell // Sphere of radius 1 with thickness 0.2 creates a shell
// Surface of sphere: d=0 at r=1 // abs(d) - 0.2 → inner surface at r=0.8, outer at r=1.2
// Onion shell: abs(d)-0.1 → interior at r=0.9 through r=1.1 double d = sdf_sphere(Point3D(0, 0, 0.8));
double d = sdf_sphere(Point3D(0, 0, 0.9));
double shell = op_onion(d, 0.2); double shell = op_onion(d, 0.2);
EXPECT_NEAR(shell, 0.0, 1e-10); // inner surface EXPECT_NEAR(shell, 0.0, 1e-10); // inner surface at r=0.8
d = sdf_sphere(Point3D(0, 0, 1.0)); d = sdf_sphere(Point3D(0, 0, 1.0));
shell = op_onion(d, 0.2); shell = op_onion(d, 0.2);
EXPECT_NEAR(shell, -0.1, 1e-10); // inside shell EXPECT_NEAR(shell, -0.2, 1e-10); // inside shell at r=1.0
} }
// ═══════════════════════════════════════════════════ // ═══════════════════════════════════════════════════