From d89548312e5b24eca97883be0479f762e79899b3 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 11 Feb 2015 08:44:10 -0800 Subject: [PATCH] manipulate the extents for SHAPE_TYPE_SPHERE The conversion from ShapeInfo to btShape MUST be reversable! Otherwise we leak shapes in the ShapeManager class. --- libraries/shared/src/ShapeInfo.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/libraries/shared/src/ShapeInfo.cpp b/libraries/shared/src/ShapeInfo.cpp index db7f8702eb..8b2a3e3a73 100644 --- a/libraries/shared/src/ShapeInfo.cpp +++ b/libraries/shared/src/ShapeInfo.cpp @@ -24,7 +24,22 @@ void ShapeInfo::clear() { void ShapeInfo::setParams(ShapeType type, const glm::vec3& halfExtents, QVector* 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; }