From 5659d57ac3f6271bfae79cf395c9f815ff229ba5 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 6 Jul 2016 13:00:57 -0700 Subject: [PATCH] fix shape generation for SIMPLE_COMPOUND --- .../src/RenderableModelEntityItem.cpp | 10 +++++----- libraries/shared/src/ShapeInfo.cpp | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index 840eace27e..7eb7d87566 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -608,7 +608,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) { // should never fall in here when collision model not fully loaded // hence we assert that all geometries exist and are loaded - assert(_model->isLoaded() && _model->isCollisionLoaded()); + assert(_model && _model->isLoaded() && _model->isCollisionLoaded()); const FBXGeometry& collisionGeometry = _model->getCollisionFBXGeometry(); ShapeInfo::PointCollection& pointCollection = info.getPointCollection(); @@ -696,15 +696,15 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) { updateModelBounds(); // should never fall in here when model not fully loaded - assert(_model->isLoaded()); + assert(_model && _model->isLoaded()); // compute meshPart local transforms QVector localTransforms; - const FBXGeometry& geometry = _model->getFBXGeometry(); - int numberOfMeshes = geometry.meshes.size(); + const FBXGeometry& fbxGeometry = _model->getFBXGeometry(); + int numberOfMeshes = fbxGeometry.meshes.size(); int totalNumVertices = 0; for (int i = 0; i < numberOfMeshes; i++) { - const FBXMesh& mesh = geometry.meshes.at(i); + const FBXMesh& mesh = fbxGeometry.meshes.at(i); if (mesh.clusters.size() > 0) { const FBXCluster& cluster = mesh.clusters.at(0); auto jointMatrix = _model->getRig()->getJointTransform(cluster.jointIndex); diff --git a/libraries/shared/src/ShapeInfo.cpp b/libraries/shared/src/ShapeInfo.cpp index e0f4cc18b2..424c2bfa22 100644 --- a/libraries/shared/src/ShapeInfo.cpp +++ b/libraries/shared/src/ShapeInfo.cpp @@ -83,12 +83,19 @@ void ShapeInfo::setOffset(const glm::vec3& offset) { } uint32_t ShapeInfo::getNumSubShapes() const { - if (_type == SHAPE_TYPE_NONE) { - return 0; - } else if (_type == SHAPE_TYPE_COMPOUND) { - return _pointCollection.size(); + switch (_type) { + case SHAPE_TYPE_NONE: + return 0; + case SHAPE_TYPE_COMPOUND: + case SHAPE_TYPE_SIMPLE_COMPOUND: + return _pointCollection.size(); + case SHAPE_TYPE_SIMPLE_HULL: + case SHAPE_TYPE_STATIC_MESH: + assert(_pointCollection.size() == 1); + // yes fall through to default + default: + return 1; } - return 1; } int ShapeInfo::getLargestSubshapePointCount() const {