Author Topic: Trouble with colorpicking in 3.9.0  (Read 2038 times)

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Trouble with colorpicking in 3.9.0
« 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 )
« Last Edit: 23 November 2013, 01:44:14 by titi »
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

tomreyn

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 2,764
    • View Profile
    • MegaGlest - the free and open source cross platform 3D real-time strategy game
Re: Trouble with colorpicking in 3.9.0
« Reply #1 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.
atibox: Ryzen 1800X (8 cores @3.6GHz), 32 GB RAM, MSI Radeon RX 580 Gaming X 8G, PCI subsystem ID [1462:3417], (Radeon RX 580 chipset, POLARIS10) @3440x1440; latest stable Ubuntu release, (open source) radeon (amdgpu) / mesa video driver
atibox (old): Core2Quad Q9400 (4 cores @2.66GHz), 8 GB RAM, XFX HD-467X-DDF2, PCI subsystem ID [1682:2931], (Radeon HD 4670, RV730 XT) @1680x1050; latest stable Ubuntu release, (open source) radeon / mesa video driver
notebook: HP envy13d020ng
internet access: VDSL2+

· · · How YOU can contribute to MG · Latest development snapshot · How to build yourself · Megapack techtree · Currently hosted MG games · · ·

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Trouble with colorpicking in 3.9.0
« Reply #2 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.

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: Trouble with colorpicking in 3.9.0
« Reply #3 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.
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: Trouble with colorpicking in 3.9.0
« Reply #4 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.
« Last Edit: 24 November 2013, 04:45:04 by softcoder »

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Trouble with colorpicking in 3.9.0
« Reply #5 on: 24 November 2013, 20:38:52 »
Looks good to me; the new map of used colours should definitely ensure no collisions.

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: Trouble with colorpicking in 3.9.0
« Reply #6 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.
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Trouble with colorpicking in 3.9.0
« Reply #7 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?)

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: Trouble with colorpicking in 3.9.0
« Reply #8 on: 25 November 2013, 17:01:38 »
Show a screenshot to explain what you are talking about.

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: Trouble with colorpicking in 3.9.0
« Reply #9 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.
« Last Edit: 25 November 2013, 23:01:16 by titi »
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Trouble with colorpicking in 3.9.0
« Reply #10 on: 25 November 2013, 18:42:15 »
Not only do the colours look duplicate, but the z-order of the units seems wrong too:



When we've moved to git I'll take a stab at working out why and where.

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Trouble with colorpicking in 3.9.0
« Reply #11 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...

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Trouble with colorpicking in 3.9.0
« Reply #12 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.

 

anything