| 7 | } |
| 8 | |
| 9 | void RendererWGPU::drawBoxImpl(const glm::vec3& worldSize) { |
| 10 | if (worldSize != lineLayer_.cachedBoxSize) { |
| 11 | lineLayer_.cachedBoxSize = worldSize; |
| 12 | const float x1 = lineLayer_.cachedBoxSize.x; |
| 13 | const float y1 = lineLayer_.cachedBoxSize.y; |
| 14 | const float z1 = lineLayer_.cachedBoxSize.z; |
| 15 | lineLayer_.boxVertices = { |
| 16 | 0, y1, 0, x1, y1, 0, x1, y1, 0, x1, y1, z1, x1, y1, z1, 0, y1, z1, 0, y1, z1, 0, y1, 0, |
| 17 | 0, 0, 0, x1, 0, 0, x1, 0, 0, x1, 0, z1, x1, 0, z1, 0, 0, z1, 0, 0, z1, 0, 0, 0, |
| 18 | 0, 0, 0, 0, y1, 0, x1, 0, 0, x1, y1, 0, x1, 0, z1, x1, y1, z1, 0, 0, z1, 0, y1, z1, |
| 19 | }; |
| 20 | WGPUContext::instance().queue()->writeBuffer(*lineLayer_.boxVb, 0, lineLayer_.boxVertices.data(), sizeof(lineLayer_.boxVertices)); |
| 21 | } |
| 22 | |
| 23 | currentPass->setPipeline(*pipelines_.box); |
| 24 | currentPass->setBindGroup(0, *lineLayer_.bindGroups[lineUniformSlotIndex_ - 1], 0, nullptr); |
| 25 | currentPass->setVertexBuffer(0, *lineLayer_.boxVb, 0, sizeof(lineLayer_.boxVertices)); |
| 26 | currentPass->draw(24, 1, 0, 0); |
| 27 | } |
| 28 | |
| 29 | void RendererWGPU::setLineColor(const glm::vec4& color) { |
| 30 | if (lineUniformSlotIndex_ >= kLineUniformSlotCount) { |