From 5a826d696a8438f9ea93a772211ae45c66b4bd50 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 19 May 2016 09:14:48 -0700 Subject: [PATCH] cleanup after code review --- libraries/physics/src/PhysicalEntitySimulation.cpp | 1 - libraries/physics/src/ShapeFactory.cpp | 10 ++++------ libraries/shared/src/ShapeInfo.h | 1 + 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/libraries/physics/src/PhysicalEntitySimulation.cpp b/libraries/physics/src/PhysicalEntitySimulation.cpp index 15296e15ab..3b271f6a81 100644 --- a/libraries/physics/src/PhysicalEntitySimulation.cpp +++ b/libraries/physics/src/PhysicalEntitySimulation.cpp @@ -218,7 +218,6 @@ void PhysicalEntitySimulation::getObjectsToAddToPhysics(VectorOfMotionStates& re ShapeInfo shapeInfo; entity->computeShapeInfo(shapeInfo); int numPoints = shapeInfo.getMaxNumPoints(); - const int MAX_HULL_POINTS = 42; if (numPoints > MAX_HULL_POINTS) { glm::vec3 p = entity->getPosition(); qWarning().nospace() << "convex hull with " << numPoints diff --git a/libraries/physics/src/ShapeFactory.cpp b/libraries/physics/src/ShapeFactory.cpp index 8641873540..8c1d44b273 100644 --- a/libraries/physics/src/ShapeFactory.cpp +++ b/libraries/physics/src/ShapeFactory.cpp @@ -66,18 +66,16 @@ btConvexHullShape* ShapeFactory::createConvexHull(const QVector& poin hull->addPoint(btVector3(correctedPoint[0], correctedPoint[1], correctedPoint[2]), false); } - const int MAX_HULL_POINTS = 42; if (points.size() > MAX_HULL_POINTS) { // create hull approximation - btShapeHull* shapeHull = new btShapeHull(hull); - shapeHull->buildHull(margin); + btShapeHull shapeHull(hull); + shapeHull.buildHull(margin); btConvexHullShape* newHull = new btConvexHullShape(); - const btVector3* newPoints = shapeHull->getVertexPointer(); - for (int i = 0; i < shapeHull->numVertices(); ++i) { + const btVector3* newPoints = shapeHull.getVertexPointer(); + for (int i = 0; i < shapeHull.numVertices(); ++i) { newHull->addPoint(newPoints[i], false); } delete hull; - delete shapeHull; hull = newHull; qDebug() << "reduced hull with" << points.size() << "points down to" << hull->getNumPoints(); // TODO: remove after testing } diff --git a/libraries/shared/src/ShapeInfo.h b/libraries/shared/src/ShapeInfo.h index 71fa12d5b5..7c76703b77 100644 --- a/libraries/shared/src/ShapeInfo.h +++ b/libraries/shared/src/ShapeInfo.h @@ -21,6 +21,7 @@ #include "DoubleHashKey.h" const float MIN_SHAPE_OFFSET = 0.001f; // offsets less than 1mm will be ignored +const int MAX_HULL_POINTS = 42; enum ShapeType { SHAPE_TYPE_NONE,