Skip to content

Commit

Permalink
fix compose index error (elalish#430)
Browse files Browse the repository at this point in the history
* fix compose index error

elalish#425 (comment)

* simplify test case
  • Loading branch information
pca006132 authored May 12, 2023
1 parent db25439 commit 2b30a1a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/manifold/src/csg_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,13 @@ Manifold::Impl CsgLeafNode::Compose(
combined.halfedge_.begin() + edgeIndices[i],
UpdateHalfedge({vertIndices[i], edgeIndices[i], triIndices[i]}));
const bool invert = glm::determinant(glm::mat3(node->transform_)) < 0;
for_each_n(
policy,
zip(combined.halfedgeTangent_.begin(), countAt(edgeIndices[i])),
node->pImpl_->halfedgeTangent_.size(),
TransformTangents{glm::mat3(node->transform_), invert,
node->pImpl_->halfedgeTangent_.cptrD(),
node->pImpl_->halfedge_.cptrD()});
for_each_n(policy,
zip(combined.halfedgeTangent_.begin() + edgeIndices[i],
countAt(0)),
node->pImpl_->halfedgeTangent_.size(),
TransformTangents{glm::mat3(node->transform_), invert,
node->pImpl_->halfedgeTangent_.cptrD(),
node->pImpl_->halfedge_.cptrD()});
if (invert)
for_each_n(policy,
zip(combined.meshRelation_.triRef.begin(),
Expand Down
9 changes: 9 additions & 0 deletions test/manifold_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1088,3 +1088,12 @@ TEST(Manifold, Invalid) {
EXPECT_EQ(Manifold::Extrude(empty_circ, 10.).Status(), invalid);
EXPECT_EQ(Manifold::Revolve(empty_sq).Status(), invalid);
}

TEST(Manifold, MultiCompose) {
auto part = Manifold::Compose({Manifold::Cube({10, 10, 10})});
auto finalAssembly =
Manifold::Compose({part, part.Translate({0, 10, 0}),
part.Mirror({1, 0, 0}).Translate({10, 0, 0}),
part.Mirror({1, 0, 0}).Translate({10, 10, 0})});
EXPECT_FLOAT_EQ(finalAssembly.GetProperties().volume, 4000);
}

0 comments on commit 2b30a1a

Please sign in to comment.