I am numbering objects in my scene with the help of "Pass Index" button. Pass Index button .

Apparently this button is short and it can not be set to more than 32767 objects in the scene. I would like to change blender source code to be able to set more objects. I found file in which this property is declared: "DNA_object_types.h" (struct Object -> line 252: short index; /* custom index, for renderpasses */.)

But once I change it to int, program will not compile and will give me a lot of errors. What is the proper way to change short to int for this button? How actually rna_object_gen.c is generated? I read through rna and dna articles, but I still didn’t get an idea how to change this short to int. What are the other places in the code which I need to change?

  • 3
    $\begingroup$ Do you have a legitimate use for having more than 32k pass objects to differentiate from? Consider if you really want to use object pass for your case, you could easily set up a new custom property per object. $\endgroup$
    – kheetor
    Apr 19 '18 at 11:02
  • $\begingroup$ Changing that property could be horribly complex - depending on what else uses it, what records and structures also use it, what else is dependent on it, etc. Only by tracing through the code (and effectively debugging all of the errors reported by your failed compile) will you be able to determine what needs to change - and each change may also be depended on other changes and further dependencies. As @kheetor quite rightly suggests, it might be easier to work around the problem in other ways than trying to change this. $\endgroup$ Apr 19 '18 at 15:28
  • $\begingroup$ Thanks for answers. I found a solution, everything works for now, but it should be tested more in the future. $\endgroup$
    – Shurup4ik
    Apr 19 '18 at 20:40


1) Read useful info on following websites: RNA, Property, DataApi.

2) On this websites blender guys give description how they are creating their gui. Description is not very easy to understand, but following sentences gave me an idea, what is wrong, when I try to convert button from short to int.

More later about saving and loading, what we have to be careful about in the DNA files is alignment. For compatibility between different compilers and platforms, all members must be aligned correctly. The general rule is that if the size of some member variable is n, it must be defined starting at a location in the struct that is a multiple of n. For example ints must be defined at locations that are a multiple of 4. Structs must be created at locations that are a multiple of 8. If for some reason this does not work out, padding variables can be added in between (usually named pad, pad1, ..). Alignment errors in DNA structs will be printed during compilation.

This is exactly the error, which I was getting, when building the program with my changes.

Align 4 error (32 bit) in struct: Object col[4] (add 2 padding bytes)

Then I have noticed that all over the code in the "DNA_object_types.h" developers were adding padding variables (void pad, char pad1, char pad2[3]...) for the aligning of the memory.

3) So when you create additional property or variable in DNA, you should align it properly. More on alignment you can find in the file "dna_genfile.c".


  • do not use #defines in structs for array lengths, this cannot be read by the dna functions
  • do not use uint, but unsigned int instead, ushort and ulong are allowed
  • only use a long in Blender if you want this to be the size of a pointer. so it is 32 bits or 64 bits, dependent at the cpu architecture
  • chars are always unsigned
  • alignment of variables has to be done in such a way, that any system does not create 'padding' (gaps) in structures. So make sure that:
    • short: 2 aligned
    • int: 4 aligned
    • float: 4 aligned
    • double: 8 aligned
    • long: 8 aligned
    • struct: 8 aligned
    • the sdna functions have several error prints builtin, always check blender running from a console.

After I have added padding variable, "Pass index" was finally converted from short to int.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.