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
61 foreach (const MeshProxy* meshProxy, in) {61 foreach (const MeshProxy* meshProxy, in) {
62 MeshPointer mesh = meshProxy->getMeshPointer();62 MeshPointer mesh = meshProxy->getMeshPointer();
63 totalVertexCount += mesh->getNumVertices();63 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
65 totalIndexCount += mesh->getNumIndices();70 totalIndexCount += mesh->getNumIndices();
66 }71 }
67 72