mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:47:30 +02:00
sphere shapeType for models means 'sphere'
This commit is contained in:
parent
5223f872c1
commit
10b3e7fc67
3 changed files with 15 additions and 3 deletions
|
@ -163,7 +163,7 @@ void ShapeEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBit
|
|||
// This value specifes how the shape should be treated by physics calculations.
|
||||
// For now, all polys will act as spheres
|
||||
ShapeType ShapeEntityItem::getShapeType() const {
|
||||
return (_shape == entity::Shape::Cube) ? SHAPE_TYPE_BOX : SHAPE_TYPE_SPHERE;
|
||||
return (_shape == entity::Shape::Cube) ? SHAPE_TYPE_BOX : SHAPE_TYPE_ELLIPSOID;
|
||||
}
|
||||
|
||||
void ShapeEntityItem::setColor(const rgbColor& value) {
|
||||
|
|
|
@ -256,9 +256,20 @@ const btCollisionShape* ShapeFactory::createShapeFromInfo(const ShapeInfo& info)
|
|||
}
|
||||
break;
|
||||
case SHAPE_TYPE_SPHERE: {
|
||||
glm::vec3 halfExtents = info.getHalfExtents();
|
||||
float radius = glm::max(halfExtents.x, glm::max(halfExtents.y, halfExtents.z));
|
||||
shape = new btSphereShape(radius);
|
||||
}
|
||||
break;
|
||||
case SHAPE_TYPE_ELLIPSOID: {
|
||||
glm::vec3 halfExtents = info.getHalfExtents();
|
||||
float radius = halfExtents.x;
|
||||
if (radius == halfExtents.y && radius == halfExtents.z) {
|
||||
const float MIN_RADIUS = 0.001f;
|
||||
const float MIN_RELATIVE_SPHERICAL_ERROR = 0.001f;
|
||||
if (radius > MIN_RADIUS
|
||||
&& fabs(radius - halfExtents.y) / radius < MIN_RELATIVE_SPHERICAL_ERROR
|
||||
&& fabs(radius - halfExtents.z) / radius < MIN_RELATIVE_SPHERICAL_ERROR) {
|
||||
// close enough to true sphere
|
||||
shape = new btSphereShape(radius);
|
||||
} else {
|
||||
ShapeInfo::PointList points;
|
||||
|
|
|
@ -45,7 +45,8 @@ enum ShapeType {
|
|||
SHAPE_TYPE_COMPOUND,
|
||||
SHAPE_TYPE_SIMPLE_HULL,
|
||||
SHAPE_TYPE_SIMPLE_COMPOUND,
|
||||
SHAPE_TYPE_STATIC_MESH
|
||||
SHAPE_TYPE_STATIC_MESH,
|
||||
SHAPE_TYPE_ELLIPSOID
|
||||
};
|
||||
|
||||
class ShapeInfo {
|
||||
|
|
Loading…
Reference in a new issue