Page MenuHome

Quick Hack: Change particle material index to ID Block

Authored by Krantz Geoffroy (kgeogeo) on Nov 28 2013, 2:57 PM.

Diff Detail

Event Timeline

I've test to save a file and apply the patch.
When you load the file there is no material in the field but doesn't crash.

Brecht Van Lommel (brecht) requested changes to this revision.Nov 28 2013, 3:55 PM

I don't think this is the right solution, internally the particle system should still point to some index in the material slots. Otherwise there is no clear way to edit the material in the UI, and the material slots then no longer provide the list of all materials on some object or mesh. Further there is no version patch to keep old files working the same, and no proper initialization of particle materials for rendering of viewport drawing.

I'm not sure what the correct solution would be in this case, or what the person who proposed this quick hack had in mind. You can make some nicer way to choose a material slot, maybe by exposing the integer also as an enum property with dynamically generated items, one for each material slot. This can be done by creating an itemf callback that creates on item for each material slot, for example rna_TextureSlot_output_node_itemf does something similar.

ok I anderstand.
I will try the way you say.

Krantz Geoffroy (kgeogeo) updated this revision to Unknown Object (????).Dec 6 2013, 6:03 PM

So here is the new patch, it only display material names in a list.
thanks to mont29 for his help.

Brecht Van Lommel (brecht) requested changes to this revision.Dec 6 2013, 9:55 PM

In the UI, if the enum shows a material icon you can set text="". Also if the object has no materials it's probably best to hide the button and show a "No materials." label?


The empty material slots can't be skipped here, they need to be in the list too since it's valid to assign such an empty slot.


Perhaps add tmp.icon = ICON_MATERIAL_DATA; here (at least for non-empty material slots).

Krantz Geoffroy (kgeogeo) updated this revision to Unknown Object (????).Dec 7 2013, 1:27 AM

Made some change that Brecht suggest

Looks good to me, I will commit it together with a fix for particle settings initialization, seems that was 0 instead of 1, showing an empty material menu when adding a new particle system.

For the author in the commit, should I use your full name (which I don't have) or do you want it to be just "kgeogeo"?

My name is Krantz Geoffroy, I think every developers use the real name so I will do the same.
thanks for the review and the help.