[SOLVED] Unable to change DNA default values from DNA_*_defaults.h

In Brush settings for sculpt mode, radius and strength for SculptDraw brush have incorrect default values (other brushes also have the same issue)

  1. Radius : default on startup is 50px and reset to default value sets it to 0
  2. Strength : default on startup is 0.5 and reset to default value sets it to 1
  3. Dyntopo -> Detail Size : default on startup is 12.00px and reset to default value sets it to 0.00px

I think this is related to T80164 and since its tagged as a good first issue, I decided to try and fix this (I’m new to Blender development). I changed a few default values in DNA_brush_defaults.h, hoping that would fix it, but that didn’t have any effect. I tried changing a few other defaults like particle settings in DNA_particle_defaults.h(see https://developer.blender.org/rBd6f409b862715ba4a07212b5149d6d6c0ec269be), but the default values still remained unchanged.
I suspect the default value in startup.blend is overriding this, although I haven’t checked it yet. Could someone tell me if I understand this correctly, or I’m missing something here?

Brush radius and strength are a bit of a special case. By default, they are scene level, not brush level. That’s what the “Use Unified Radius” icon toggles on the right of the slider.
So you are looking for a value that is somehow nested in the scene. Unless you want to, I won’t tell you exactly where to look so you can learn how to find that yourself. A tip: Enable Python tooltips in the Preferences and use that to find out where the value is stored.
In your case you actually have to add a new default struct, not just set a value.

You are right about the startup.blend when it comes to changing defaults. To avoid having to save that file with a new value, versioning code is added to versioning_defaults.c.

Thanks for the tip. I’ll take look at this again in a few days (college exams start tomorrow) and keep my progress updated on this post and on T80164.

1 Like

@julianeisel Found the UnifiedPaintSettings struct that defines all the properties inside DNA_scene_types.h.

As a test I added RNA_def_property_*_default(prop, *); to the corresponding RNA property in rna_scene.c to see if I was looking at the correct struct. This worked without any problems.

So I moved on to adding a new default struct :


, inside DNA_scene_defaults.h and using

SDNA_DEFAULT_DECL_EX(UnifiedPaintSettings, ToolSettings.unified_paint_settings)

, to add the struct to the DNA_default_table.

For some reason this isn’t working. The implementation I have done is similar to the one for ParticleEditSettings, since both have their instances defined in ToolSettings struct as particle and unified_paint_settings.

Have I missed something or the implementation is wrong?

Could you provide a patch that doesn’t do what you expect?

Sorry for the late response. I was stuck in classes.
I’ve uploaded the patch here : https://developer.blender.org/D10658

I’ve finally fixed it. Turns out that I had actually missed something crucial :
I had added the default struct _DNA_DEFAULTS_UnifiedPaintSettings , but I didn’t assign it as a default to unified_paint_settings under ToolSettings.

The final working patch can be found here : https://developer.blender.org/D10658