mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 23:40:11 +02:00
Merge pull request #8998 from AndrewMeadows/ellipsoids-sorta
use ConvexHull shape for irregular "spheres"
This commit is contained in:
commit
9a774553ae
2 changed files with 14 additions and 10 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);
|
||||||
|
@ -119,8 +114,7 @@ float ShapeInfo::computeVolume() const {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SHAPE_TYPE_SPHERE: {
|
case SHAPE_TYPE_SPHERE: {
|
||||||
float radius = _halfExtents.x;
|
volume = 4.0f * PI * _halfExtents.x * _halfExtents.y * _halfExtents.z / 3.0f;
|
||||||
volume = 4.0f * PI * radius * radius * radius / 3.0f;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SHAPE_TYPE_CYLINDER_Y: {
|
case SHAPE_TYPE_CYLINDER_Y: {
|
||||||
|
|
Loading…
Reference in a new issue