Godot Version
Godot 4.5.1 Stable Mono
Question
Hello. I’m working on a strategy map game and I wanted to use a colored map for efficient map state look-up (games like Victoria 3 and Europa Universalis 5 use the same method). However what I encountered is that if I take the base Godot Color class/struct in C# the precision isn’t consistent or the Dictionary and HashSet data structures don’t use correct functions to evaluate the individual colors.
HashSet<Color> colorSet = []
Image image = generateMapImage(data, colorSet){...} // Generates an image from the data where every cell is saved in a json and each cell is assigned a unique color that is then put into the color set.
ImageTexture imageTexture = ImageTexture(image)
mapImageTextureRect.SetTexture(ImageTexture)
...
// Getting the color on mouse press
Color pixelColor = mapImageTextureRect.GetTexture().GetImage().GetPixel(mouseX, mouseY) // This retrieves close but not quite the same color - I understand this is probably due to floating point precision but it's important for later
colorSet.contains(pixelColor) // Always returns false because the even if the color is close enough due to the imprecision it evaluates as not the same.
My question is: Is this intended function or should I file a bug report for the Color class ?