fix warp simplification (#416)

* fixed warp simplification

* fix test
This commit is contained in:
Emmett Lalish
2023-04-20 11:52:47 -07:00
committed by GitHub
parent 97317888bc
commit ba042ee8db
2 changed files with 17 additions and 0 deletions
+2
View File
@@ -549,6 +549,8 @@ Manifold Manifold::Warp(std::function<void(glm::vec3&)> warpFunc) const {
pImpl->faceNormal_.resize(0); // force recalculation of triNormal
pImpl->CalculateNormals();
pImpl->SetPrecision();
pImpl->CreateFaces();
pImpl->SimplifyTopology();
return Manifold(std::make_shared<CsgLeafNode>(pImpl));
}
+15
View File
@@ -215,6 +215,21 @@ TEST(Manifold, Revolve2) {
EXPECT_NEAR(prop.surfaceArea, 96.0f * glm::pi<float>(), 1.0f);
}
TEST(Manifold, Warp) {
CrossSection square = CrossSection::Square({1, 1});
Manifold shape = Manifold::Extrude(square, 2, 10).Warp([](glm::vec3& v) {
v.x += v.z * v.z;
});
auto propBefore = shape.GetProperties();
Manifold simplified = Manifold::Compose({shape});
auto propAfter = simplified.GetProperties();
EXPECT_NEAR(propBefore.volume, propAfter.volume, 0.0001);
EXPECT_NEAR(propBefore.surfaceArea, propAfter.surfaceArea, 0.0001);
EXPECT_NEAR(propBefore.volume, 2, 0.0001);
}
TEST(Manifold, Smooth) {
Manifold tet = Manifold::Tetrahedron();
Manifold smooth = Manifold::Smooth(tet.GetMesh());