Skip to content
This repository has been archived by the owner on Nov 13, 2017. It is now read-only.

fixing adding tables to the collision world #578

Open
wants to merge 1 commit into
base: indigo-devel
Choose a base branch
from
Open
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 perception/semantic_world/src/semantic_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ bool SemanticWorld::addTablesToCollisionWorld()
std::vector<unsigned int> triangles((vertices.size() - 2)* 3);
for (unsigned int j = 0 ; j < convex_hull.size() ; ++j)
vertices[j] = Eigen::Vector3d(convex_hull[j].x, convex_hull[j].y, convex_hull[j].z);
for (unsigned int j = 1; j < triangles.size() - 1; ++j)
for (unsigned int j = 0; j < vertices.size() - 2; ++j)
{
unsigned int i3 = j * 3;
triangles[i3++] = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a new bug here. Consider what happens when j == 0. triangles[0] = 0, triangles[1] = 0, and triangles[2] = 1. So the first triangle is always a line. Then because of the loop ending just before vertices.size() - 2, the last (needed) triangle is missing.

I think the correct code should look like you have it, with lines 132 and 133 changed to read:

triangles[i3++] = j+1;
triangles[i3] = j+2;

Expand Down