EDIT: Turns out it's not the btTriangleMesh! That's fine. It's the tiny object that somehow has a huge hitbox the first frame. See my later posts for information and screenshots.
Hey guys,
I'm creating a btTriangleMesh like this:
Code: Select all
std::shared_ptr<btTriangleMesh> Mesh::get_bt_mesh(Scale scale) const {
std::shared_ptr<btTriangleMesh> triangle_mesh{new btTriangleMesh()};
COUT << indices.size() << std::endl;
for(unsigned int i = 0; i < indices.size(); i += 3){
auto const pv = [&](size_t const n){
return vertices[indices[i+n]].position.slice<0,3>() * scale * .95f;
};
auto const v = [&](size_t const i){
return convert<btVector3>(pv(i));
};
// CERR << pv(0) << std::endl
// << pv(1) << std::endl
// << pv(2) << std::endl;
triangle_mesh->addTriangle(v(0), v(1), v(2), false);
COUT << i << std::endl;
}
return triangle_mesh;
}
I'm using the btTriangleMesh as a collision shape like so:
Code: Select all
bt_mesh = mesh->get_bt_mesh(get_scale());
collision_shape = std::make_shared<btBvhTriangleMeshShape>(bt_mesh.get(), true);
physical_body->setCollisionShape(collision_shape.get());
As you can see in the debug draw, everything seems to be fine, but my objects are still colliding with it and I don't know why. Not *all* objects collide with it, it's in some specific places. I couldn't figure out a pattern though, but I think it's worth mentioning.
Thanks in advance,