mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-06 23:07:15 +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
|
@ -256,8 +256,18 @@ const btCollisionShape* ShapeFactory::createShapeFromInfo(const ShapeInfo& info)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SHAPE_TYPE_SPHERE: {
|
case SHAPE_TYPE_SPHERE: {
|
||||||
float radius = info.getHalfExtents().x;
|
glm::vec3 halfExtents = info.getHalfExtents();
|
||||||
shape = new btSphereShape(radius);
|
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;
|
break;
|
||||||
case SHAPE_TYPE_CAPSULE_Y: {
|
case SHAPE_TYPE_CAPSULE_Y: {
|
||||||
|
|
|
@ -33,13 +33,8 @@ void ShapeInfo::setParams(ShapeType type, const glm::vec3& halfExtents, QString
|
||||||
_halfExtents = glm::vec3(0.0f);
|
_halfExtents = glm::vec3(0.0f);
|
||||||
break;
|
break;
|
||||||
case SHAPE_TYPE_BOX:
|
case SHAPE_TYPE_BOX:
|
||||||
|
case SHAPE_TYPE_SPHERE:
|
||||||
break;
|
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_COMPOUND:
|
||||||
case SHAPE_TYPE_STATIC_MESH:
|
case SHAPE_TYPE_STATIC_MESH:
|
||||||
_url = QUrl(url);
|
_url = QUrl(url);
|
||||||
|
|
Loading…
Reference in a new issue