Showing the changes to libraries/render-utils/src/Model.cpp (1 of 6 files). Show all
Unified · Split
| @@ -754,6 +754,16 @@ public: · 753 unmodified lines | ||
| 754 | 754 | int meshIndex; |
| 755 | 755 | int partIndex; |
| 756 | 756 | int _shapeID; |
| 757 | + | |
| 758 | + render::Item::Bound getBound() const { | |
| 759 | + if (_isBoundInvalid) { | |
| 760 | + model->getPartBounds(meshIndex, partIndex); | |
| 761 | + _isBoundInvalid = false; | |
| 762 | + } | |
| 763 | + return _bound; | |
| 764 | + } | |
| 765 | + mutable render::Item::Bound _bound; | |
| 766 | + mutable bool _isBoundInvalid = true; | |
| 757 | 767 | }; |
| 758 | 768 | |
| 759 | 769 | namespace render { |
| @@ -780,7 +790,7 @@ namespace render { · 20 unmodified lines | ||
| 780 | 790 | |
| 781 | 791 | template <> const Item::Bound payloadGetBound(const MeshPartPayload::Pointer& payload) { |
| 782 | 792 | if (payload) { |
| 783 | − return payload->model->getPartBounds(payload->meshIndex, payload->partIndex); | |
| 793 | + return payload->getBound(); // model->getPartBounds(payload->meshIndex, payload->partIndex); | |
| 784 | 794 | } |
| 785 | 795 | return render::Item::Bound(); |
| 786 | 796 | } |
| @@ -1486,6 +1496,9 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, int shape · 699 unmodified lines | ||
| 1486 | 1496 | const FBXMesh& mesh = geometry.meshes.at(meshIndex); |
| 1487 | 1497 | const MeshState& state = _meshStates.at(meshIndex); |
| 1488 | 1498 | |
| 1499 | + auto drawMesh = networkMesh._mesh; | |
| 1500 | + | |
| 1501 | + | |
| 1489 | 1502 | auto drawMaterialKey = material->getKey(); |
| 1490 | 1503 | bool translucentMesh = drawMaterialKey.isTransparent() || drawMaterialKey.isTransparentMap(); |
| 1491 | 1504 | |
| @@ -1541,7 +1554,9 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, int shape · 49 unmodified lines | ||
| 1541 | 1554 | return; // FIXME! |
| 1542 | 1555 | } |
| 1543 | 1556 | |
| 1544 | − batch.setIndexBuffer(gpu::UINT32, (networkMesh._indexBuffer), 0); | |
| 1557 | + // Assign index buffer: | |
| 1558 | + batch.setIndexBuffer(gpu::UINT32, (drawMesh->getIndexBuffer()._buffer), 0); | |
| 1559 | + // batch.setIndexBuffer(gpu::UINT32, (networkMesh._indexBuffer), 0); | |
| 1545 | 1560 | int vertexCount = mesh.vertices.size(); |
| 1546 | 1561 | if (vertexCount == 0) { |
| 1547 | 1562 | // sanity check |
| @@ -1574,10 +1589,21 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, int shape · 26 unmodified lines | ||
| 1574 | 1589 | batch.setModelTransform(_transforms[0]); |
| 1575 | 1590 | |
| 1576 | 1591 | if (mesh.blendshapes.isEmpty()) { |
| 1577 | − batch.setInputFormat(networkMesh._vertexFormat); | |
| 1578 | − batch.setInputStream(0, *networkMesh._vertexStream); | |
| 1592 | + batch.setInputFormat((drawMesh->getVertexFormat())); | |
| 1593 | + auto inputStream = drawMesh->makeBufferStream(); | |
| 1594 | + | |
| 1595 | + batch.setInputStream(0, inputStream); | |
| 1596 | + | |
| 1597 | + // batch.setInputFormat(networkMesh._vertexFormat); | |
| 1598 | + // batch.setInputStream(0, *networkMesh._vertexStream); | |
| 1579 | 1599 | } else { |
| 1600 | + /* batch.setInputFormat((drawMesh->getVertexFormat())); | |
| 1601 | + auto inputStream = drawMesh->makeBufferStream(); | |
| 1602 | + | |
| 1603 | + batch.setInputStream(0, inputStream); | |
| 1604 | + */ | |
| 1580 | 1605 | batch.setInputFormat(networkMesh._vertexFormat); |
| 1606 | + | |
| 1581 | 1607 | batch.setInputBuffer(0, _blendedVertexBuffers[meshIndex], 0, sizeof(glm::vec3)); |
| 1582 | 1608 | batch.setInputBuffer(1, _blendedVertexBuffers[meshIndex], vertexCount * sizeof(glm::vec3), sizeof(glm::vec3)); |
| 1583 | 1609 | batch.setInputStream(2, *networkMesh._vertexStream); |
| @@ -1702,9 +1728,12 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, int shape · 118 unmodified lines | ||
| 1702 | 1728 | } |
| 1703 | 1729 | } |
| 1704 | 1730 | |
| 1705 | − batch.setIndexBuffer(gpu::UINT32, part.getMergedTriangles(), 0); | |
| 1706 | − batch.drawIndexed(gpu::TRIANGLES, part.mergedTrianglesIndicesCount, 0); | |
| 1731 | + auto& drawPart = drawMesh->getPartBuffer().get<model::Mesh::Part>(); | |
| 1732 | + batch.drawIndexed(model::Mesh::topologyToPrimitive(drawPart._topology), drawPart._numIndices, drawPart._startIndex); | |
| 1707 | 1733 | |
| 1734 | +/* batch.setIndexBuffer(gpu::UINT32, part.getMergedTriangles(), 0); | |
| 1735 | + batch.drawIndexed(gpu::TRIANGLES, part.mergedTrianglesIndicesCount, 0); | |
| 1736 | + */ | |
| 1708 | 1737 | if (args) { |
| 1709 | 1738 | const int INDICES_PER_TRIANGLE = 3; |
| 1710 | 1739 | args->_details._trianglesRendered += part.mergedTrianglesIndicesCount / INDICES_PER_TRIANGLE; |