History

Fixing the index Offset issue with instanced shapes from Geometry cache

samcake committed 11 years ago

Commit c75c31d1 parent 2b5742b4 files · +6 −36Browse files

Showing the changes to libraries/render-utils/src/GeometryCache.cpp (1 of 4 files). Show all

Unified · Split

libraries/render-utils/src/GeometryCache.cpp+5−4
@@ -59,7 +59,8 @@ static gpu::Stream::FormatPointer INSTANCED_SOLID_STREAM_FORMAT; · 58 unmodified lines
5959
6060 static const uint SHAPE_VERTEX_STRIDE = sizeof(glm::vec3) * 2; // vertices and normals
6161 static const uint SHAPE_NORMALS_OFFSET = sizeof(glm::vec3);
62−
62+static const gpu::Type SHAPE_INDEX_TYPE = gpu::UINT16;
63+static const uint SHAPE_INDEX_SIZE = sizeof(gpu::uint16);
6364
6465 void GeometryCache::ShapeData::setupVertices(gpu::BufferPointer& vertexBuffer, const VertexVector& vertices) {
6566 vertexBuffer->append(vertices);
@@ -73,13 +74,13 @@ void GeometryCache::ShapeData::setupVertices(gpu::BufferPointer& vertexBuffer, c · 7 unmodified lines
7374 void GeometryCache::ShapeData::setupIndices(gpu::BufferPointer& indexBuffer, const IndexVector& indices, const IndexVector& wireIndices) {
7475 _indices = indexBuffer;
7576 if (!indices.empty()) {
76− _indexOffset = indexBuffer->getSize();
77+ _indexOffset = indexBuffer->getSize() / SHAPE_INDEX_SIZE;
7778 _indexCount = indices.size();
7879 indexBuffer->append(indices);
7980 }
8081
8182 if (!wireIndices.empty()) {
82− _wireIndexOffset = indexBuffer->getSize();
83+ _wireIndexOffset = indexBuffer->getSize() / SHAPE_INDEX_SIZE;
8384 _wireIndexCount = wireIndices.size();
8485 indexBuffer->append(wireIndices);
8586 }
@@ -88,7 +89,7 @@ void GeometryCache::ShapeData::setupIndices(gpu::BufferPointer& indexBuffer, con · 2 unmodified lines
8889 void GeometryCache::ShapeData::setupBatch(gpu::Batch& batch) const {
8990 batch.setInputBuffer(gpu::Stream::POSITION, _positionView);
9091 batch.setInputBuffer(gpu::Stream::NORMAL, _normalView);
91− batch.setIndexBuffer(gpu::UINT16, _indices, 0);
92+ batch.setIndexBuffer(SHAPE_INDEX_TYPE, _indices, 0);
9293 }
9394
9495 void GeometryCache::ShapeData::draw(gpu::Batch& batch) const {