gama-platform / gama.old

Main repository for developing the 1.x versions of GAMA
GNU General Public License v3.0
303 stars 99 forks source link

[opengl] problem with layers of flat objects #3857

Closed lesquoyb closed 1 year ago

lesquoyb commented 1 year ago

Describe the bug When displaying layers of flat objects one on top of the others, there are very often display problems arising. The parameter that add a small increment on z-coordinate seems to be useless. Here is an example model:

/**
* Name: order
* Based on the internal empty template. 
* Author: baptiste
* Tags: 
*/

model order

/* Insert your model definition here */

global {

    init {
        create dummy;
    }
}

species dummy {
    aspect default {
        draw rectangle(10, 20) color:#blue;
        draw "coucou" color:#black;

    }
}

experiment t {
    output {
        display t type:3d {
            species dummy;

        }
    }
}

And just by zooming in/out we have that kind of displays: image

In that case, it's ugly but still understandable. But in some models the order is just completely messed up which makes them hard to understand. For example take the model Generalized Lotka-Volterra (Toy model).gaml and force the first display to be 3d, here is what you get: image while in 2d it looks like this: image While it's probably not the only problem with that model, the order in which the items are displayed is a part of it

To Reproduce Steps to reproduce the behavior:

  1. create an aspect with 2 surfaces one after the other
  2. use that aspect in a 3d display
  3. See error

Expected behavior layers are stacked in the order they are created, like in 2d display

Desktop (please complete the following information):

AlexisDrogoul commented 1 year ago

The issue here is not linked to the layers but to draw, as you are instructing OpenGL to draw two objects at exactly the same position, which he cant really do correctly. This cant be solved without an explicit translation in z in draw (e.g. draw "coucou" color:#black at: location + {0,0,0.1};). However, I understand the need to have more automated things, so I have added the possibility to define (in the preferences) the increment to add between two drawings and also two layers and I take it into account between layers as well. This normally fixes the problem you mention here that could occur between layers.
Monosnap 2023-09-01 19-39-03

So, to summarise, if you write :

        draw rectangle(10, 20) color:#blue;
        draw "coucou" color:#black;

This will never be solvable automatically (i.e. unless you explicitly translate the second draw)

But if you write :

        display t type:3d {
            species dummy { draw rectangle(10, 20) color:#blue; }
            species dummy { draw "coucou" color:#black; }
        }

Then GAMA can apply the increment (between layers) and it works nicely.

Newt Window 2023-09-01 19-50-08