8000 Improve smoothing of flat faces by elalish · Pull Request #821 · elalish/manifold · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improve smoothing of flat faces #821

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"program": "${workspaceFolder}/build/test/manifold_test",
"args": [
"--gtest_break_on_failure",
"--gtest_filter=SDF.SineSurface"
"--gtest_filter=Smooth.RefineQuads"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/build/test",
Expand Down
4 changes: 2 additions & 2 deletions bindings/wasm/examples/worker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ suite('Examples', () => {
test('Scallop', async () => {
const result = await runExample('Scallop');
expect(result.genus).to.equal(0, 'Genus');
expect(result.volume).to.be.closeTo(41400, 100, 'Volume');
expect(result.surfaceArea).to.be.closeTo(7770, 10, 'Surface Area');
expect(result.volume).to.be.closeTo(40900, 100, 'Volume');
expect(result.surfaceArea).to.be.closeTo(7740, 10, 'Surface Area');
});

test('Torus Knot', async () => {
Expand Down
2 changes: 2 additions & 0 deletions src/manifold/src/impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,13 @@ struct Manifold::Impl {
const std::vector<Smoothness>&) const;
Vec<bool> FlatFaces() const;
Vec<int> VertFlatFace(const Vec<bool>&) const;
Vec<int> VertHalfedge() const;
std::vector<Smoothness> SharpenEdges(float minSharpAngle,
float minSmoothness) const;
void SharpenTangent(int halfedge, float smoothness);
void SetNormals(int normalIdx, float minSharpAngle);
void LinearizeFlatTangents();
void DistributeTangents(const Vec<bool>& fixedHalfedges);
void CreateTangents(int normalIdx);
void CreateTangents(std::vector<Smoothness>);
void Refine(std::function<int(glm::vec3)>);
Expand Down
13 changes: 12 additions & 1 deletion src/manifold/src/manifold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,18 @@ Manifold Manifold::SmoothByNormals(int normalIdx) const {
Manifold Manifold::SmoothOut(float minSharpAngle, float minSmoothness) const {
auto pImpl = std::make_shared<Impl>(*GetCsgLeafNode().GetImpl());
if (!IsEmpty()) {
pImpl->CreateTangents(pImpl->SharpenEdges(minSharpAngle, minSmoothness));
if (minSmoothness == 0) {
const int numProp = pImpl->meshRelation_.numProp;
Vec<float> properties = pImpl->meshRelation_.properties;
Vec<glm::ivec3> triProperties = pImpl->meshRelation_.triProperties;
pImpl->SetNormals(0, minSharpAngle);
pImpl->CreateTangents(0);
pImpl->meshRelation_.numProp = 0;
pImpl->meshRelation_.properties.swap(properties);
pImpl->meshRelation_.triProperties.swap(triProperties);
} else {
pImpl->CreateTangents(pImpl->SharpenEdges(minSharpAngle, minSmoothness));
}
}
return Manifold(std::make_shared<CsgLeafNode>(pImpl));
}
Expand Down
Loading
Loading
0