Skip to content

Commit

Permalink
fix compose index error
Browse files Browse the repository at this point in the history
  • Loading branch information
pca006132 committed May 12, 2023
1 parent 1615b72 commit eb04b99
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 legAssembly = Manifold::Compose({Manifold::Cube({100, 140, 38})});
auto finalAssembly = Manifold::Compose(
{legAssembly, legAssembly.Translate({0, 300, 0}),
legAssembly.Mirror({1, 0, 0}).Translate({300, 0, 0}),
legAssembly.Mirror({1, 0, 0}).Translate({300, 300, 0})});
finalAssembly.GetMesh();
}

0 comments on commit eb04b99

Please sign in to comment.