! * \brief Updates the data of the sprite * * \param instanceData Data of the instance */
| 161 | * \param instanceData Data of the instance |
| 162 | */ |
| 163 | void Sprite::UpdateData(InstanceData* instanceData) const |
| 164 | { |
| 165 | instanceData->data.resize(4 * sizeof(VertexStruct_XYZ_Color_UV)); |
| 166 | VertexStruct_XYZ_Color_UV* vertices = reinterpret_cast<VertexStruct_XYZ_Color_UV*>(instanceData->data.data()); |
| 167 | |
| 168 | SparsePtr<Color> colorPtr(&vertices[0].color, sizeof(VertexStruct_XYZ_Color_UV)); |
| 169 | SparsePtr<Vector3f> posPtr(&vertices[0].position, sizeof(VertexStruct_XYZ_Color_UV)); |
| 170 | SparsePtr<Vector2f> texCoordPtr(&vertices[0].uv, sizeof(VertexStruct_XYZ_Color_UV)); |
| 171 | |
| 172 | Vector3f origin(m_origin.x, -m_origin.y, m_origin.z); |
| 173 | |
| 174 | *colorPtr++ = m_color * m_cornerColor[RectCorner_LeftTop]; |
| 175 | *posPtr++ = instanceData->transformMatrix.Transform(Vector3f(-origin)); |
| 176 | *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftTop); |
| 177 | |
| 178 | *colorPtr++ = m_color * m_cornerColor[RectCorner_RightTop]; |
| 179 | *posPtr++ = instanceData->transformMatrix.Transform(m_size.x*Vector3f::Right() - origin); |
| 180 | *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightTop); |
| 181 | |
| 182 | *colorPtr++ = m_color * m_cornerColor[RectCorner_LeftBottom]; |
| 183 | *posPtr++ = instanceData->transformMatrix.Transform(m_size.y*Vector3f::Down() - origin); |
| 184 | *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftBottom); |
| 185 | |
| 186 | *colorPtr++ = m_color * m_cornerColor[RectCorner_RightBottom]; |
| 187 | *posPtr++ = instanceData->transformMatrix.Transform(m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down() - origin); |
| 188 | *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightBottom); |
| 189 | } |
| 190 | |
| 191 | /*! |
| 192 | * \brief Initializes the sprite library |
no test coverage detected