// Calculates the tile's dimensions from the texture and texture coordinates. void DecoratorTiled::Tile::CalculateDimensions(Element* element, const Texture& texture) { RenderInterface* render_interface = element->GetRenderInterface(); TileDataMap::iterator data_iterator = data.find(render_interface); if (data_iterator == data.end()) { TileData new_data; Vector2i texture_dimensions = texture.GetDimensions(render_interface); for (int i = 0; i < 2; i++) { new_data.texcoords[i] = texcoords[i]; if (texcoords_absolute[i][0] && texture_dimensions.x > 0) new_data.texcoords[i].x /= texture_dimensions.x; if (texcoords_absolute[i][1] && texture_dimensions.y > 0) new_data.texcoords[i].y /= texture_dimensions.y; } new_data.dimensions.x = Math::AbsoluteValue((new_data.texcoords[1].x * texture_dimensions.x) - (new_data.texcoords[0].x * texture_dimensions.x)); new_data.dimensions.y = Math::AbsoluteValue((new_data.texcoords[1].y * texture_dimensions.y) - (new_data.texcoords[0].y * texture_dimensions.y)); data[render_interface] = new_data; } }