mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 11:37:58 +02:00
Merge pull request #1 from AndrewMeadows/cyclohexane
optimizations when creating convex hull shapes
This commit is contained in:
commit
f90211e830
1 changed files with 12 additions and 8 deletions
|
@ -136,28 +136,32 @@ btCollisionShape* ShapeInfoUtil::createShapeFromInfo(const ShapeInfo& info) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SHAPE_TYPE_CONVEX_HULL: {
|
case SHAPE_TYPE_CONVEX_HULL: {
|
||||||
shape = new btConvexHullShape();
|
auto hull = new btConvexHullShape();
|
||||||
const QVector<QVector<glm::vec3>>& points = info.getPoints();
|
const QVector<QVector<glm::vec3>>& points = info.getPoints();
|
||||||
foreach (glm::vec3 point, points[0]) {
|
foreach (glm::vec3 point, points[0]) {
|
||||||
btVector3 btPoint(point[0], point[1], point[2]);
|
btVector3 btPoint(point[0], point[1], point[2]);
|
||||||
static_cast<btConvexHullShape*>(shape)->addPoint(btPoint);
|
hull->addPoint(btPoint, false);
|
||||||
}
|
}
|
||||||
|
hull->recalcLocalAabb();
|
||||||
|
shape = hull;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SHAPE_TYPE_COMPOUND: {
|
case SHAPE_TYPE_COMPOUND: {
|
||||||
shape = new btCompoundShape();
|
auto compound = new btCompoundShape();
|
||||||
const QVector<QVector<glm::vec3>>& points = info.getPoints();
|
const QVector<QVector<glm::vec3>>& points = info.getPoints();
|
||||||
|
|
||||||
foreach (QVector<glm::vec3> hullPoints, info.getPoints()) {
|
btTransform trans;
|
||||||
|
trans.setIdentity();
|
||||||
|
foreach (QVector<glm::vec3> hullPoints, points) {
|
||||||
auto hull = new btConvexHullShape();
|
auto hull = new btConvexHullShape();
|
||||||
foreach (glm::vec3 point, hullPoints) {
|
foreach (glm::vec3 point, hullPoints) {
|
||||||
btVector3 btPoint(point[0], point[1], point[2]);
|
btVector3 btPoint(point[0], point[1], point[2]);
|
||||||
hull->addPoint(btPoint);
|
hull->addPoint(btPoint, false);
|
||||||
}
|
}
|
||||||
btTransform trans;
|
hull->recalcLocalAabb();
|
||||||
trans.setIdentity();
|
compound->addChildShape (trans, hull);
|
||||||
static_cast<btCompoundShape*>(shape)->addChildShape (trans, hull);
|
|
||||||
}
|
}
|
||||||
|
shape = compound;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue