MegaGlest Forum

MegaGlest => Bug reports => Topic started by: titi on 23 November 2013, 00:25:31

Title: Trouble with colorpicking in 3.9.0
Post by: titi on 23 November 2013, 00:25:31
Hi yesterday I had two games where I got selection trouble using colorpicking. In both cases I was not able to select a unit. whenever I tried to select the unit another unit was selected.

In the case I show now the unit I wanted to select was one of my genies. Whenever I tried to select it A tent of my indian partner was selected. I decided to take a screenshot of this situation. To do so I opened a selection rectangle around the genie and I pressed "E" key to get a screenshot. This turned out to be a cool debug feature also it was not our intention :D . I got a screenshot were the full scene was rendered in the way colorpicking would be rendered ( but I only got one screenshot also I pressed e 3 times ).

the screenshot:
(click to show/hide)

I tried this taking a screenshot with open selection rectangle again today and i got the same result, so this is really a nice way to look at/debug the colorpicking. Also this is a bug, I really want to keep this "feature"

now for the bug regarding colorpicking:
As you can see from this screenshot the both objects have the same selection color! This should never happen and causes the trouble we see from time to time using colorpicking selection method.
The genie was my unit, the tent was a partners one:
(click to show/hide)

( update: second screenshot was wrong )
Title: Re: Trouble with colorpicking in 3.9.0
Post by: tomreyn on 23 November 2013, 02:30:16
For what it's worth, I concur in that the two objects in the screenshots Titi posted are the same color (based on Gimp's color picker):

That's RGB 185 65 2 and HTML #b94102

Which looks like this.
Title: Re: Trouble with colorpicking in 3.9.0
Post by: will on 23 November 2013, 08:42:22
Its always tricky to take colour samples if its jpg.  I'm on a phone and can't are if its jpg or PNG.

But generally, colour picking ought to assume a 16 bit buffer and pick distanced colours.  And an assert step could validate no two objects get the same colour.
Title: Re: Trouble with colorpicking in 3.9.0
Post by: titi on 23 November 2013, 12:21:09
yes, jpeg is not perfect, but it already shows the problem. As I said I was surprised that this kind of screenshot was taken.
Title: Re: Trouble with colorpicking in 3.9.0
Post by: softcoder on 24 November 2013, 03:58:33
Feel free to review the class: BaseColorPickEntity in model.cpp to see if you can find something wrong with the color assignment. I cannot find anything wrong.

Thanks

*UPDATE: I committed some code to hopefully make this impossible to happen again. Let me know if you are able to reproduce this using svn head.
Title: Re: Trouble with colorpicking in 3.9.0
Post by: will on 24 November 2013, 20:38:52
Looks good to me; the new map of used colours should definitely ensure no collisions.
Title: Re: Trouble with colorpicking in 3.9.0
Post by: titi on 24 November 2013, 23:58:30
@softcoder: I already reviewed this place several times and all i can say is it looks good to me. I see no problems :-/.  Lets hope your last change will catch the problem.
Title: Re: Trouble with colorpicking in 3.9.0
Post by: will on 25 November 2013, 10:55:08
(Is it just me or does it look like we have a z-order problem with the units clustered together too?)
Title: Re: Trouble with colorpicking in 3.9.0
Post by: softcoder on 25 November 2013, 17:01:38
Show a screenshot to explain what you are talking about.
Title: Re: Trouble with colorpicking in 3.9.0
Post by: titi on 25 November 2013, 17:39:36
Will we have such a problem, but thats offtopic and not a bug. Open thread in main megaglest forum  please.
Title: Re: Trouble with colorpicking in 3.9.0
Post by: will on 25 November 2013, 18:42:15
Not only do the colours look duplicate, but the z-order of the units seems wrong too:

(http://i.imgur.com/bRJa2gO.png)

When we've moved to git I'll take a stab at working out why and where.
Title: Re: Trouble with colorpicking in 3.9.0
Post by: will on 27 November 2013, 15:43:44
Titi had an excellent debug line that saves colour picking tgas.  I could easily see units with the same colour, but the uniqueness checks were not being triggered.

I replaced the code with a random sequence instead.  I did not try and optimise the code though.  In github you'll see our first pull request for your code review...
Title: Re: Trouble with colorpicking in 3.9.0
Post by: will on 29 November 2013, 01:36:08
Pull request https://github.com/MegaGlest/megaglest-source/pull/2/files

Additionally, this contains a potential optimisation for low-end CPU users; you can disable animation interpolation from the command-line or from the INI:

Code: [Select]
--disable-vertex-interpolation=true
I'd be curious to know if this has any impact on performance.

It does also save a small amount of RAM.