From fd19c634491409c5ef62c3d14ff3e09515cdd46d Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 21 May 2015 14:26:40 -0700 Subject: [PATCH] fix bug in mesh --- .../src/RenderablePolyVoxEntityItem.cpp | 27 +++++++++++++------ libraries/model/src/model/Geometry.h | 2 +- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp index 0d710a5188..9decd37cb2 100644 --- a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp @@ -97,24 +97,35 @@ void RenderablePolyVoxEntityItem::getModel() { mesh->setVertexBuffer(gpu::BufferView(vertexBufferPtr, 0, vertexBufferPtr->getSize() - sizeof(float) * 3, - sizeof(float) * 3, - // sizeof(PolyVox::PositionMaterialNormal), - gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::RAW))); + sizeof(PolyVox::PositionMaterialNormal), + gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::RAW) + )); mesh->addAttribute(gpu::Stream::NORMAL, gpu::BufferView(vertexBufferPtr, sizeof(float) * 3, vertexBufferPtr->getSize() - sizeof(float) * 3, - sizeof(float) * 7, - // sizeof(PolyVox::PositionMaterialNormal), - gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::RAW))); + sizeof(PolyVox::PositionMaterialNormal), + gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::RAW) + )); qDebug() << "-------------XXXXXXXXXXXXXXXXXXXX-------------------"; qDebug() << "---- vecIndices.size() =" << vecIndices.size(); + qDebug() << "---- sizeof(vecIndices[0]) =" << sizeof(vecIndices[0]); qDebug() << "---- vecVertices.size() =" << vecVertices.size(); - // [DEBUG] [05/19 20:46:38] ---- vecIndices.size() = 101556 - // [DEBUG] [05/19 20:46:38] ---- vecVertices.size() = 67704 + qDebug() << "---- sizeof(vecVertices[0]) =" << sizeof(vecVertices[0]); + qDebug() << "---- sizeof(uint32_t) =" << sizeof(uint32_t); + qDebug() << "---- sizeof(float) =" << sizeof(float); + qDebug() << "---- sizeof(PolyVox::PositionMaterialNormal) =" << sizeof(PolyVox::PositionMaterialNormal); + // -------------XXXXXXXXXXXXXXXXXXXX------------------- + // ---- vecIndices.size() = 25524 + // ---- sizeof(vecIndices[0]) = 4 + // ---- vecVertices.size() = 17016 + // ---- sizeof(vecVertices[0]) = 28 + // ---- sizeof(uint32_t) = 4 + // ---- sizeof(float) = 4 + // ---- sizeof(PolyVox::PositionMaterialNormal) = 28 _modelGeometry.setMesh(meshPtr); _needsModelReload = false; diff --git a/libraries/model/src/model/Geometry.h b/libraries/model/src/model/Geometry.h index 0416018e62..95f1c3bce7 100755 --- a/libraries/model/src/model/Geometry.h +++ b/libraries/model/src/model/Geometry.h @@ -47,7 +47,7 @@ public: void setVertexBuffer(const BufferView& buffer); const BufferView& getVertexBuffer() const { return _vertexBuffer; } uint getNumVertices() const { return _vertexBuffer.getNumElements(); } - bool hasVertexData() const { return !_vertexBuffer._buffer; } + bool hasVertexData() const { return _vertexBuffer._buffer.get() != nullptr; } // Attribute Buffers int getNumAttributes() const { return _attributeBuffers.size(); }