Maniphest T62101

Grease Pencil selection order is wrong
Closed, Resolved

Assigned To
Antonio Vazquez (antoniov)
Authored By
William Reynish (billreynish)
Mar 1 2019, 9:59 PM
Tags
  • BF Blender
Subscribers
Antonio Vazquez (antoniov)
Clément Foucault (fclem)
Germano Cavalcante (mano-wii)
William Reynish (billreynish)

Description

System Information
Operating system: macOS 10.14.3
Graphics card: AMD Radeon R9 M395X 4096 MB

Blender Version
Broken: Blender 2.80 beta, 2019-03-01

Short description of error
Grease Pencil selection order is wrong. Grease Pencil objects will always be selected last, even if they are in front.

Exact steps for others to reproduce the error
In the blend file below, there's a simple example of a bunch of GP objects in front of a mesh:


Click over the Grease Pencil monkey objects to select them. Rather than the GP objects being selected, the mesh object behind them will be selected instead.

Revisions and Commits

rB Blender
D5193

Event Timeline

William Reynish (billreynish) created this task.Mar 1 2019, 9:59 PM
William Reynish (billreynish) assigned this task to Antonio Vazquez (antoniov).Mar 1 2019, 10:01 PM
Antonio Vazquez (antoniov) added a subscriber: Clément Foucault (fclem).Mar 1 2019, 11:26 PM

We need @Clément Foucault (fclem) help here.

I only add the render section for select, but I did not make any code of the selection itself. No idea why is working in this way.

William Reynish (billreynish) reassigned this task from Antonio Vazquez (antoniov) to Clément Foucault (fclem).Mar 1 2019, 11:37 PM
William Reynish (billreynish) added a subscriber: Antonio Vazquez (antoniov).
Sebastian Parborg (zeddb) lowered the priority of this task from 90 to 50.Mar 2 2019, 3:36 PM
Germano Cavalcante (mano-wii) added a subscriber: Germano Cavalcante (mano-wii).Jul 4 2019, 6:11 PM

Is this bug still reproducible in the latest builds?

Germano Cavalcante (mano-wii) added a comment.Jul 5 2019, 1:24 AM

I tried again by disabling the OpenGL Depth Picking option and I was able to reproduce the bug.

The problem is that gpencil calls gpencil_free_runtime_data(stl) inside GPENCIL_draw_scene() thus releasing some resources in the first call from DRW_draw_select_loop(...).
However, DRW_draw_select_loop(...) calls drw_engines_draw_scene() at least three consecutive times.
I don't know if the solution has to be done in the DRW_manager itself or in the GPencil engine.

I also noticed an efficiency issue.
gpu_select_query_load_id(id) is called several times consecutively for the same id.
This forces the creation and use of more glQueries.
It would be good to investigate this too.

Clément Foucault (fclem) added a comment.Jul 5 2019, 3:03 PM

This forces the creation and use of more glQueries.

If I remember correctly, Similar queries are merged together.

However, DRW_draw_select_loop(...) calls drw_engines_draw_scene() at least three consecutive times.

Best way of fixing it would be to introduce a post draw callback in the draw engine struct and free the runtime data here. But that maybe a bit too big of a modification at this time.

Other possible fix is to move all these resources to a per layer storage (DRW_view_layer_engine_data_get) and discard only in cache_init.

Germano Cavalcante (mano-wii) added a comment.Jul 5 2019, 4:07 PM

Is there any way to recreate the entire runtime_data within GPENCIL_draw_scene(...)?
It would be another possible fix.

Antonio Vazquez (antoniov) added a comment.Jul 5 2019, 4:38 PM

I think this can be complex...you have a list of object sorted by z-depth, the layers, the strokes with different types, etc...not sure what really you need, but maybe could be possible if you give me more details of what you want to do.

Have you checked drw_gpencil_select_render(stl, psl); function?

Germano Cavalcante (mano-wii) added a comment.Jul 5 2019, 5:15 PM

@Antonio Vazquez (antoniov) would be nice to remove that gpencil_free_runtime_data(stl) from GPENCIL_draw_scene(...).
At least for selection.

Antonio Vazquez (antoniov) claimed this task.Jul 5 2019, 11:16 PM
Antonio Vazquez (antoniov) changed the task status from Unknown Status to Resolved by committing rBa0f3ea7da3f6: Fix T62101: GPencil: selection order is wrong.Jul 5 2019, 11:54 PM
Antonio Vazquez (antoniov) added a commit: rBa0f3ea7da3f6: Fix T62101: GPencil: selection order is wrong.