Page MenuHome

GP ruler data reinstances GP_Palette Color on save if visible
Closed, ResolvedPublic

Description

System Information
Win7, Quadro 2000

Blender Version
Broken: 9b0f6fa
Worked: (optional)

Short description of error
Using the Ruler, it is useful to turn on the visibility of the RulerData3D GP layer so that references can be seen / modified.

Noticed that after GP V2 (which it should be noted is awesome otherwise), a new GP palette color instance is made for each ruler, each time the user goes into ruler/protractor mode and presses 'Enter' to save. Quickly gets out of hand.

Exact steps for others to reproduce the error
Factory Defaults
Grease Pencil -> Ruler/Protractor
Make a measurement in 3D view
Press 'Enter' to save to GP layer 'RulerData3D'
Toggle on visibility of GP layer 'RulerData3D' -> new palette color is made
Go back to Ruler / Protractor mode and press 'Enter' again -> another new palette color is made

*try making several measurements in Ruler mode w/ Ctrl + drag, pressing 'Enter' then progressively adds as many measurements exist each time.

Event Timeline

Poked around the code but am not a hardcore c coder- hope this helps focus efforts:

in view3d_ruler.c, line 319:

	BKE_gpencil_free_strokes(gpf);

would delete and regenerate the strokes per frame? since there isn't any reference to a palcolor per stroke it would add a new one when the draw function runs.

Maybe define a palcolor in this function and make it default to a "RulerData3D" palette like it did with the GPencil layer, then per stroke apply?

Patch which seems to work, but it doesn't do the UI GP Color panel initializing if the first thing done is the Ruler Set.

I can reproduce the error. Thanks for the investigation, I will take a look.

@Ryan (shiprex) Your solution is good and I like the idea to check if "rulename" color exists and reuse it.

I have only a doubt about the default color.

  • I don't like to set a color harcoded, so we need a parameter to control it.
  • I could use the layer default color (defined in user preferences) and the stroke would have the same color as if were draw manually or I can use the default wire color (used while the ruler is active).

@Joshua Leung (aligorith) What do you think?

Sergey Sharybin (sergey) lowered the priority of this task from 90 to Normal.Aug 16 2016, 1:43 PM

@Antonio Vazquez (antoniov) Thanks! Much of that code block is duplicated over from gpencil_utils.c:473 (refactor if appropriate). I like the idea of a parameterized default color, but only on construction, not reference. Once the color is initialized, set and saved in a .blend, it would be great to be whatever the user wants it to be.

Best,
Ryan

Yes, this is used in the first creation only, after the creation of the color, the user can customize or move the stroke to a new color (as any other stroke).

We can use any user preference color value, but at this moment we cannot add a new user preferences color (it's too late for 2.78 release).

I will wait for @Joshua Leung (aligorith) answer before commmit the fix.

Awesome :) While we're at it, has there been a change to the draw order for X-ray strokes? they seem to disappear in objects with just a bit of transparency.

Here's a minimum effective blend for example, there is a GP stroke in the cube, either put the viewport alpha all the way up, or all the way down, the GP stroke is visible, but mixed it disappears.

No change for X-ray strokes. I will test your file.

Woot, first patch :D (question, why the strcopy? Still learning...)

RE: X-Ray, Thank you, no rush :) FWIW, I don't imagine you signed up to troubleshoot ruler/protractor users ;) MeasureIt has a lot more features which are super cool (will it work with modifier-deformed/shapekey-ed meshes in the future? I imagine it would be tough to pull this off with the Python API...)

Wonder if separating measurement system from the GP would save headache in the long run?