From 21f65d8a78d8dbba1608797a9d758bc1f93556f5 Mon Sep 17 00:00:00 2001 From: sam gateau Date: Wed, 5 Sep 2018 17:50:06 -0700 Subject: [PATCH] position are used correctly for evaluting bounds in the Mesh --- libraries/fbx/src/FBXReader_Mesh.cpp | 4 ++-- libraries/graphics/src/graphics/Geometry.cpp | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libraries/fbx/src/FBXReader_Mesh.cpp b/libraries/fbx/src/FBXReader_Mesh.cpp index bb95fb42f7..7b83e74ebc 100644 --- a/libraries/fbx/src/FBXReader_Mesh.cpp +++ b/libraries/fbx/src/FBXReader_Mesh.cpp @@ -781,7 +781,7 @@ void FBXReader::buildModelMesh(FBXMesh& extractedMesh, const QString& url) { attribChannel = 2; totalAttribBufferSize = totalVertsSize - positionsSize - normalsAndTangentsSize; - } else { + } /*else { auto posBuffer = std::make_shared(); posBuffer->setData(positionsSize, (const gpu::Byte*) vertBuffer->getData() + positionsOffset); vertexBufferStream->addBuffer(posBuffer, 0, positionElement.getSize()); @@ -794,7 +794,7 @@ void FBXReader::buildModelMesh(FBXMesh& extractedMesh, const QString& url) { attribChannel = 1; totalAttribBufferSize = totalVertsSize - positionsSize; - } + }*/ // Define the vertex format, compute the offset for each attributes as we append them to the vertex format gpu::Offset bufOffset = 0; diff --git a/libraries/graphics/src/graphics/Geometry.cpp b/libraries/graphics/src/graphics/Geometry.cpp index 2fbe3708fd..f71dcbe27d 100755 --- a/libraries/graphics/src/graphics/Geometry.cpp +++ b/libraries/graphics/src/graphics/Geometry.cpp @@ -120,7 +120,8 @@ Box Mesh::evalPartBound(int partNum) const { for (;index != endIndex; index++) { // skip primitive restart indices if ((*index) != PRIMITIVE_RESTART_INDEX) { - box += vertices[(*index)]; + // box += vertices[(*index)]; + box += _vertexBuffer.get(part._baseVertex + (*index)); } } } @@ -137,11 +138,12 @@ Box Mesh::evalPartsBound(int partStart, int partEnd) const { Box partBound; auto index = _indexBuffer.cbegin() + (*part)._startIndex; auto endIndex = index + (*part)._numIndices; - auto vertices = &_vertexBuffer.get((*part)._baseVertex); + //auto vertices = &_vertexBuffer.get((*part)._baseVertex); for (;index != endIndex; index++) { // skip primitive restart indices if ((*index) != (uint) PRIMITIVE_RESTART_INDEX) { - partBound += vertices[(*index)]; + //partBound += vertices[(*index)]; + partBound += _vertexBuffer.get((*part)._baseVertex + (*index)); } }