Re-evaluate "Reset to Default Value"
Open, NormalPublic

Description

Re-evaluate "Reset to Default Value"

Motivation

Users have the option to reset a property to its default vaule (in UI: RMB MenuReset to Default Value). However, this barely works, in the majority of cases it just sets it to its minimum value. So as it is, it can definitely be considered broken.

Keep it or wipe it out?

Just wiping it out would safe us some work, but IMHO this feature would be very useful - if it worked. It gives users some safety, since they don't need to be afraid of breaking something by playing around with values. (I personally wanted to use it all the time.)

How to solve?

First of, we need to ask what we define as the default value. AFAICS there are three potential default values:

  • RNA default value
  • Startup file value
  • User defined value

RNA default value:
RNA already supports default values, assigning one to a property is a one line fix. The issue is that it had to be done for all properties that miss it (quickly checked, more than 2000, maybe 3000 properties).
To solve this, I'd propose we add a maniphest task that lists all RNA files and ask people to submit patches that add default values for theses files. Think operator RNA properties could be neglected a bit.
Note that these default values should match the ones from the startup.blend, meaning they had to be kept in sync too.

Startup file value:
AFAIK it's possible to get the property value of a .blend using Python, so we could do this with the startup.blend.
Using this solution we wouldn't have to worry about keeping startup.blend and RNA defaults in sync.

User defined value:
This should work 'on top' of one of the other two solutions, and it's obviously the solution that would be the most configurable. It could be set in a popup that is invoked from the context menu (this popup could also allow resetting to non-user defined default).

Details

Type
To Do

If we take the RNA option I could make patches

There's actually 3 places with default values, in RNA, in the function that allocates the struct, and in the startup file. The startup file only contains a small subset of all data structures though.

If we want to avoid duplication, it's possible to make a function that sets RNA default values in structs when they are allocated. Something similar could be done for the startup.blend, though I'm not sure where that fits in exactly.

IMHO startup blend should be kept aside. First because people typically customize it, second because there are several things in it which shall not be set to default values (you do not want all your vertex coordinates to be (0,0,0), same for all your objects location/rotation/scale etc.). We could use a py script to ensure a reasonable subset of 'factory setting' matches the RNA default values, though, once we have unified defaults in code.

Which leaves C struct and RNA. I really like Brecht’s suggestion here, would enforce both real default values in RNA (as said, most of those are not set in current code), and greatly simplifies C struct initializations too.

Regarding "How To Solve" (if we want to).

A while back I wrote a script to report invalid defaults (comparing newly created data against RNA defaults).

You can run it with:

blender --background -noaudio --factory-startup --python tests/python/bl_rna_defaults.py

Current output: