RNA_def_modifier is not called?

I’m trying to learn about the way modifiers are implemented in Blender. For that I’ve added a new simple one but I’ve an issue: it seems ‘RNA_def_modifier’ is not called.

What I’ve done so far:

  • Defined the modifier data struct in DNA_modifier_types.h
  • Declared the type info in MOD_modifiertypes.h
  • Added a INIT_TYPE in MOD_util.c
  • Added a new c file in bf_modifiers project. In this file ModifierTypeInfo is defined and few (blank) functions are implemented
  • Added a new line in rna_def_modifier for a call to the modifier rna properties definitions
  • Added a new function in properties_data_modifier.py (this function is called but fails to find the rna properties)
  • Completed CMakelists.txt in bf_modifiers

At runtime, I can add the modifier and see that its functions defined in ModifierTypeInfo are called (due to some printf in them).

Visual Studio does not want to add a breakpoint in RNA_def_modifier and adding a printf in it traces nothing.

What am I missing?

Well… sorry for the question. It is solved. I forgot to add a line in rna_Modifier_refine…

there is also a repository https://github.com/ideasman42/blender_patch_templates with the motivation of providing simple patches to add new functionality (like modifiers). I believe they dont apply atm as is (maybe @ideasman42 can have a look?)

edit: just saw there is already a thread about that here https://devtalk.blender.org/t/feedback-on-patch-templates

@lichtwerk, thanks.

Effectively, nothing is “so simple” in the Blender coding world… ok, I am new to that, but the learning curve is hard to me!

I’m planning to do this. But I know I need to learn first. So I decided to code a “random modifier” first (which I felt more simple in theory).

The “random modifier” is to randomize vertices locations with the following parameters:

  • Using the modified object axis or using another object (world) axis
  • A min and magnitude value for X, Y and Z axis (so that result value is location + min + rnd * magnitude)
  • A min and magnitude for random along vertex normal
  • A vertex group to influence/filter the random (planed)

The wanted parameters finally appears correctly in the modifier panel, but:

  • If I save the blend file and try to reload it an exception occurs: this is due to the object parameter (“using another object axis” above). Certainly I’ve to specify something somewhere to handle pointers… but what and where?

  • Another aspect: I presume this random modifier is deformVerts(EM) only, So I’ve look at the corresponding functions signatures. We have a coordinates array and count. But I will need the vertices normals and vertex groups information: can I consider the array to be in the same order as the vertices of the derived mesh?

Thanks for your help.

PS: I know this reply is no more related to the original question, but I’m afraid to open too many questions…

Did you setup a foreachObjectLink function in your ModifierTypeInfo struct ?

No idea about your second question but I would assume the answer is yes. Don’t forget to setup the dependsOnNormals and the requiredDataMask functions.

@pragma37, thanks a lot, it was effectively foreachObjectLink! I will continue a bit coding but I’d like to have some guidance later so that I can document somewhere my experience around modifiers so that it can be useful for others… I’ll ask later here about that.

Concerning deformVerts, I’ve changed it to a applyModifier (without knowing the exact impact of that, if there is any).

But good! Thanks to your help, all seems ok now for this first modifier I made! YaY!