Page MenuHome

Default Value for Viewport Display Color's Alpha Wrong.
Confirmed, LowPublicBUG

Description

System Information
Operating system: Windows-10-10.0.18362-SP0 64 Bits
Graphics card: GeForce RTX 2070 with Max-Q Design/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 457.09

Blender Version
Broken: version: 2.92.0 Alpha, branch: master (modified), commit date: 2020-11-02 19:31, hash: rBb9ec6c305cc8
Also tested on 2.83.8 and same problem.
Worked: It do not think this has ever worked

Short description of error
When reverting to the Default Value for Viewport Display Color the alpha gets down to 0.8 making the object semi transparent.

Exact steps for others to reproduce the error
Open up a new scene.
Select the cube.
Go to the materials tab.
Scroll down to "Viewport Display"
Right Click on "Color"
"Reset to Default Value"
Result: RGB values go back to the default, but Alpha goes to 0.8

Thank you so much !

Event Timeline

Robert Guetzkow (rjg) changed the task status from Needs Triage to Confirmed.Nov 9 2020, 12:24 PM
Robert Guetzkow (rjg) triaged this task as Low priority.
Robert Guetzkow (rjg) changed the subtype of this task from "Report" to "Bug".

I can confirm this issue, this was already broken in 2.80.

We have two issues here. Booth rooting in the fact (hack) that RNA expose colors as an array of four floats, but DNA stores them in four separated contiguous variables.

  1. RNA default-from-DNA code use smallest of DNA or RNA-defined size of current property to read default values (MIN2(size_final, dp->dnasize)), which will always fail in our hack-case, since the DNA-size is only of one float.
  2. On top of that, code defines the length of our color array (4) after RNA_def_property_float_sdna (and trying to do otherwise breaks compilation), which means that size_final will never be accurate in RNA_def_property_XXX_sdna`.

So I think that for now:

  1. Since RNA data access itself does not care about actual DNA size property (which is bad security-wise btw), we should not do it either when dealing with DNA-defaults.
  2. Code handling default value retrieval from DNA should be put into its own function, and re-run from other rna define functions that may affect actual data size info (like RNA_def_property_array).

On the longer run, think we should forbid that hack altogether? It is both dirty and potentially unsafe, and relies on some assumptions regarding how data are actually laid out by the compiler in the DNA struct. If we want an arrays, either define and array in DNA, or use explicit accessors in RNA.

@Campbell Barton (campbellbarton) this is your code originally, want to chime in?

Bastien Montagne (mont29) moved this task from Backlog to Bugs on the Core board.