Skip to content
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

Trimesh now recalculates aabb on rescale #327

Closed
wants to merge 4 commits into from
Closed
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
18 changes: 18 additions & 0 deletions src/shape/trimesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,24 @@ impl<N: RealField> TriMesh<N> {
for pt in &mut self.points {
pt.coords.component_mul_assign(scale)
}
//Recalculate aabb, method taken from constructor
let mut leaves = Vec::with_capacity(self.faces.len());
for (i, face) in self.faces.iter().enumerate() {
let triangle = Triangle::new(
self.points[face.indices[0]],
self.points[face.indices[1]],
self.points[face.indices[2]],
);
let bv = triangle.local_aabb();
leaves.push((i, bv.clone()));
}
self.bvt = BVT::new_balanced(leaves);

//don't know if neccessary here
// Set face.bvt_leaf
for (i, leaf) in self.bvt.leaves().iter().enumerate() {
self.faces[*leaf.data()].bvt_leaf = i;
}
}

/// Applies a non-uniform scale to this triangle mesh.
Expand Down