mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 03:44:26 +02:00
use convexHull for ellipsoidal "spheres"
This commit is contained in:
parent
4b1034a5e6
commit
0d2cec290d
2 changed files with 13 additions and 8 deletions
libraries
|
@ -256,8 +256,18 @@ const btCollisionShape* ShapeFactory::createShapeFromInfo(const ShapeInfo& info)
|
|||
}
|
||||
break;
|
||||
case SHAPE_TYPE_SPHERE: {
|
||||
float radius = info.getHalfExtents().x;
|
||||
shape = new btSphereShape(radius);
|
||||
glm::vec3 halfExtents = info.getHalfExtents();
|
||||
float radius = halfExtents.x;
|
||||
if (radius == halfExtents.y && radius == halfExtents.z) {
|
||||
shape = new btSphereShape(radius);
|
||||
} else {
|
||||
ShapeInfo::PointList points;
|
||||
points.reserve(NUM_UNIT_SPHERE_DIRECTIONS);
|
||||
for (uint32_t i = 0; i < NUM_UNIT_SPHERE_DIRECTIONS; ++i) {
|
||||
points.push_back(bulletToGLM(_unitSphereDirections[i]) * halfExtents);
|
||||
}
|
||||
shape = createConvexHull(points);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SHAPE_TYPE_CAPSULE_Y: {
|
||||
|
|
|
@ -33,13 +33,8 @@ void ShapeInfo::setParams(ShapeType type, const glm::vec3& halfExtents, QString
|
|||
_halfExtents = glm::vec3(0.0f);
|
||||
break;
|
||||
case SHAPE_TYPE_BOX:
|
||||
case SHAPE_TYPE_SPHERE:
|
||||
break;
|
||||
case SHAPE_TYPE_SPHERE: {
|
||||
// sphere radius is max of halfExtents
|
||||
float radius = glm::max(glm::max(halfExtents.x, halfExtents.y), halfExtents.z);
|
||||
_halfExtents = glm::vec3(radius);
|
||||
break;
|
||||
}
|
||||
case SHAPE_TYPE_COMPOUND:
|
||||
case SHAPE_TYPE_STATIC_MESH:
|
||||
_url = QUrl(url);
|
||||
|
|
Loading…
Reference in a new issue