| 145 | } |
| 146 | |
| 147 | void DBSlot::_updateFrame() { |
| 148 | const auto currentVerticesData = (_deformVertices != nullptr && _display == _meshDisplay) ? _deformVertices->verticesData : nullptr; |
| 149 | const auto currentTextureData = s_cast<DBTextureData*>(_textureData); |
| 150 | if (_displayIndex >= 0 && _display != nullptr && currentTextureData != nullptr) { |
| 151 | if (currentVerticesData != nullptr) // Mesh. |
| 152 | { |
| 153 | const auto data = currentVerticesData->data; |
| 154 | const auto intArray = data->intArray; |
| 155 | const auto floatArray = data->floatArray; |
| 156 | const unsigned vertexCount = intArray[currentVerticesData->offset + s_cast<unsigned>(db::BinaryOffset::MeshVertexCount)]; |
| 157 | const unsigned triangleCount = intArray[currentVerticesData->offset + s_cast<unsigned>(db::BinaryOffset::MeshTriangleCount)]; |
| 158 | int vertexOffset = intArray[currentVerticesData->offset + s_cast<unsigned>(db::BinaryOffset::MeshFloatOffset)]; |
| 159 | if (vertexOffset < 0) { |
| 160 | vertexOffset += 65536; // Fixed out of bouds bug. |
| 161 | } |
| 162 | const unsigned uvOffset = vertexOffset + vertexCount * 2; |
| 163 | const auto& region = currentTextureData->region; |
| 164 | Texture2D* texture = s_cast<DBTextureAtlasData*>(currentTextureData->parent)->getTexture(); |
| 165 | _node->_texture = texture; |
| 166 | _node->_points.resize(vertexCount); |
| 167 | _node->_vertices.resize(vertexCount); |
| 168 | _node->_indices.resize(triangleCount * 3); |
| 169 | for (std::size_t i = 0, l = vertexCount * 2; i < l; i += 2) { |
| 170 | const auto iH = i / 2; |
| 171 | const auto x = floatArray[vertexOffset + i]; |
| 172 | const auto y = floatArray[vertexOffset + i + 1]; |
| 173 | auto u = floatArray[uvOffset + i]; |
| 174 | auto v = floatArray[uvOffset + i + 1]; |
| 175 | _node->_points[iH] = {x, -y, 0.0f, 1.0f}; |
| 176 | SpriteVertex& vertex = _node->_vertices[iH]; |
| 177 | if (currentTextureData->rotated) { |
| 178 | vertex.u = (region.x + (1.0f - v) * region.width) / texture->getWidth(); |
| 179 | vertex.v = (region.y + u * region.height) / texture->getHeight(); |
| 180 | } else { |
| 181 | vertex.u = (region.x + u * region.width) / texture->getWidth(); |
| 182 | vertex.v = (region.y + v * region.height) / texture->getHeight(); |
| 183 | } |
| 184 | vertex.abgr = 0xffffffff; |
| 185 | } |
| 186 | for (std::size_t i = 0; i < triangleCount * 3; ++i) { |
| 187 | _node->_indices[i] = intArray[currentVerticesData->offset + s_cast<unsigned>(db::BinaryOffset::MeshVertexIndices) + i]; |
| 188 | } |
| 189 | _textureScale = 1.0f; |
| 190 | const auto isSkinned = currentVerticesData->weight != nullptr; |
| 191 | if (isSkinned) { |
| 192 | _identityTransform(); |
| 193 | } |
| 194 | } else { |
| 195 | _textureScale = currentTextureData->parent->scale * _armature->_armatureData->scale; |
| 196 | Texture2D* texture = s_cast<DBTextureAtlasData*>(currentTextureData->parent)->getTexture(); |
| 197 | _node->_texture = texture; |
| 198 | const auto& region = currentTextureData->region; |
| 199 | const bgfx::TextureInfo& info = texture->getInfo(); |
| 200 | auto& verts = _node->_vertices; |
| 201 | if (currentTextureData->rotated) _node->setAngle(90); |
| 202 | verts.resize(4); |
| 203 | { |
| 204 | float left = region.x / info.width; |
nothing calls this directly
no test coverage detected