History

fix crash for convex hull of co-planar points

Andrew Meadows committed 11 years ago

Commit bf3ff8d1 parent f86c0641 file · +12 −3Browse files

Showing the changes to libraries/physics/src/ShapeFactory.cpp (1 of 1 file). Show all

Unified · Split

libraries/physics/src/ShapeFactory.cpp+12−3
@@ -43,9 +43,18 @@ btConvexHullShape* ShapeFactory::createConvexHull(const QVector<glm::vec3>& poin · 42 unmodified lines
4343
4444 const float MIN_MARGIN = 0.01f;
4545 glm::vec3 diagonal = maxCorner - minCorner;
46− float minDimension = glm::min(diagonal[0], diagonal[1]);
47− minDimension = glm::min(minDimension, diagonal[2]);
48− margin = glm::min(glm::max(0.5f * minDimension, MIN_MARGIN), margin);
46+ float smallestDimension = glm::min(diagonal[0], diagonal[1]);
47+ smallestDimension = glm::min(smallestDimension, diagonal[2]);
48+ const float MIN_DIMENSION = 2.0f * MIN_MARGIN + 0.001f;
49+ if (smallestDimension < MIN_DIMENSION) {
50+ for (int i = 0; i < 3; ++i) {
51+ if (diagonal[i] < MIN_DIMENSION) {
52+ diagonal[i] = MIN_DIMENSION;
53+ }
54+ }
55+ smallestDimension = MIN_DIMENSION;
56+ }
57+ margin = glm::min(glm::max(0.5f * smallestDimension, MIN_MARGIN), margin);
4958 hull->setMargin(margin);
5059
5160 // add the points, correcting for margin

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t