Merge pull request #8155 from AndrewMeadows/cap-static-mesh-vertex-count

Cap static mesh vertex count
This commit is contained in:
Sam Gondelman 2016-06-30 11:09:49 -07:00 committed by GitHub
commit fcb7652c8f
2 changed files with 14 additions and 4 deletions

View file

@ -696,6 +696,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) {
QVector<glm::mat4> 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();

View file

@ -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) {