History

fix handling of normals. don't crash when extracting a mesh from a polyvox with no 'on' voxels

Seth Alves committed 9 years ago

Commit b876d221 parent 35c38b85 files · +32 −20Browse files

Showing the changes to libraries/script-engine/src/ModelScriptingInterface.cpp (1 of 5 files). Show all

Unified · Split

libraries/script-engine/src/ModelScriptingInterface.cpp+6−1
@@ -61,7 +61,12 @@ QScriptValue ModelScriptingInterface::appendMeshes(MeshProxyList in) { · 60 unmodified lines
6161 foreach (const MeshProxy* meshProxy, in) {
6262 MeshPointer mesh = meshProxy->getMeshPointer();
6363 totalVertexCount += mesh->getNumVertices();
64− totalAttributeCount += mesh->getNumAttributes();
64+
65+ int attributeTypeNormal = gpu::Stream::InputSlot::NORMAL; // libraries/gpu/src/gpu/Stream.h
66+ const gpu::BufferView& normalsBufferView = mesh->getAttributeBuffer(attributeTypeNormal);
67+ gpu::BufferView::Index numNormals = (gpu::BufferView::Index)normalsBufferView.getNumElements();
68+ totalAttributeCount += numNormals;
69+
6570 totalIndexCount += mesh->getNumIndices();
6671 }
6772