manipulate the extents for SHAPE_TYPE_SPHERE

The conversion from ShapeInfo to btShape MUST be reversable!
Otherwise we leak shapes in the ShapeManager class.
This commit is contained in:
Andrew Meadows 2015-02-11 08:44:10 -08:00
parent f4a4c9786c
commit d89548312e

View file

@ -24,7 +24,22 @@ void ShapeInfo::clear() {
void ShapeInfo::setParams(ShapeType type, const glm::vec3& halfExtents, QVector<glm::vec3>* data) {
_type = type;
_halfExtents = halfExtents;
switch(type) {
case SHAPE_TYPE_NONE:
_halfExtents = glm::vec3(0.0f);
break;
case SHAPE_TYPE_BOX:
_halfExtents = halfExtents;
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;
}
default:
_halfExtents = halfExtents;
}
_externalData = data;
}