From e538625fe07a062988351c35b77cdf07cbc01b69 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 28 Jun 2016 16:35:32 -0700 Subject: [PATCH 1/2] fix warning about convex hull vertex count cap --- libraries/physics/src/PhysicalEntitySimulation.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libraries/physics/src/PhysicalEntitySimulation.cpp b/libraries/physics/src/PhysicalEntitySimulation.cpp index cdf33a6edb..9714059e7c 100644 --- a/libraries/physics/src/PhysicalEntitySimulation.cpp +++ b/libraries/physics/src/PhysicalEntitySimulation.cpp @@ -218,10 +218,12 @@ void PhysicalEntitySimulation::getObjectsToAddToPhysics(VectorOfMotionStates& re ShapeInfo shapeInfo; entity->computeShapeInfo(shapeInfo); int numPoints = shapeInfo.getLargestSubshapePointCount(); - if (numPoints > MAX_HULL_POINTS) { - qWarning() << "convex hull with" << numPoints - << "points for entity" << entity->getName() - << "at" << entity->getPosition() << " will be reduced"; + if (shapeInfo.getType() == SHAPE_TYPE_COMPOUND) { + if (numPoints > MAX_HULL_POINTS) { + qWarning() << "convex hull with" << numPoints + << "points for entity" << entity->getName() + << "at" << entity->getPosition() << " will be reduced"; + } } btCollisionShape* shape = ObjectMotionState::getShapeManager()->getShape(shapeInfo); if (shape) { From 74781c078638fbddd9a0fe5c5cbb6960a91526e9 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 28 Jun 2016 16:36:10 -0700 Subject: [PATCH 2/2] boxify static meshes with too many vertices --- .../entities-renderer/src/RenderableModelEntityItem.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index 366e365107..43fea75eac 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -696,6 +696,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) { QVector localTransforms; const FBXGeometry& geometry = _model->getFBXGeometry(); int numberOfMeshes = geometry.meshes.size(); + int totalNumVertices = 0; for (int i = 0; i < numberOfMeshes; i++) { const FBXMesh& mesh = geometry.meshes.at(i); if (mesh.clusters.size() > 0) { @@ -706,6 +707,13 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) { glm::mat4 identity; localTransforms.push_back(identity); } + totalNumVertices += mesh.vertices.size(); + } + const int MAX_VERTICES_PER_STATIC_MESH = 1e6; + if (totalNumVertices > MAX_VERTICES_PER_STATIC_MESH) { + qWarning() << "model" << getModelURL() << "has too many vertices" << totalNumVertices << "and will collide as a box."; + info.setParams(SHAPE_TYPE_BOX, 0.5f * dimensions); + return; } updateModelBounds();