[Bf-committers] Using Blender Palettes vs bGPDpalettes for Grease Pencil

blendergit at gmail.com blendergit at gmail.com
Tue Jan 10 19:16:40 CET 2017


Hi All,
 
As you probably know,  We are working in new improvements for grease pencil in 2.8 release. One of the main points of these new changes is create a new GP object and this brings the palette question.
 
In 2.78, the palettes are defined as bGPDpalettes and bGPDpalettecolor inside GP datablock, so each datablock has his own palette. This is not practical if we want to have several GP objects on screen and we need a way to share the palettes with several GP datablocks.
 
During last November 2.8 workshop, the palette subject was reviewed and the idea was to move to Blender Palettes in order to have one system only for all Blender. You can see more details here: https://wiki.blender.org/index.php/User:Antoniov/Convert_bGPDpalettes_to_BlenderPalettes
 
Since them I have been working in a private branch and I got a version running using the Blender Palettes (pending animation topic), but at this moment arises a concern about the use of Blender Palettes instead  of separated GP only palettes.
 
Here I made a summary of the private mails we had about using Blender Palettes or not :
 
Cons:
 
A lot more new fancy linestyle and fill options will be added in there in the future. For example, stuff like gradients, linestyle (solid vs dotted/dashes, etc.) texturing support, etc.  
 
If we move to Blender Palettes, this will mean bloating up the general case with a lot of GP only stuff. However, if we keep it the current bGPDpalette stuff, we have lot more freedom to do stuff like this.  (Also, keep in mind that bloating up Blender Palettes means that, 1) There's more filesize wastage, 2) Any scripter going through the PyAPI or RNA listings is going to have a harder time figuring out which properties can be used normally, and which are GP only)
 
We're going to break forward compatibility *again*. Sure, if we're moving palettes to datablocks, there's going to be some breakage anyway, but at the very least, old Blender versions will still have a chance of reading the colors out of the palettes (ignoring the ID datablock stuff) since the pointers would still be present and working.
 
Pros:
 
We have one system for all Palettes in Blender and we use only a ID block.
 
After reviewing the API of Blender Palettes in 2.78, I have seen the API is very limited, almost inexistent (https://www.blender.org/api/blender_python_api_2_78_0/bpy.types.PaletteColor.html#bpy.types.PaletteColor).
 
The current use of the Blender 2.78 Palettes is very limited and I had to add a lot of new API to this ID in order to support GP. I don’t think we are going to break important scripts and if we talk about GP, I have replicated all old API methods, so the conversion would be very easy. If we use Blender Palettes or move the bGPDpalette outside GP, both options will require an update of the scripts, and must be updated to use Paint or Scene instead of GP as parent.
 
About the concern of having part of the API for GP only, we could solve this adding a "pencil" prefix or suffix to all related API functions, but I’m not sure we really need this because the current API is “create” and “remove” only, so all API would be GP.
 
For the Palettes used in Vertex Paint, weight paint, etc. I have kept the same UI, so the users will not see any difference and at API level, as old methods (create/remove) remain equal, there aren’t changes at script level.
 
I have added new context methods too and changed the old methods of bGPDpalettes and bGPDpalettecolors (active_gpencil_palette, etc.)  to use Blender palettes internally, so this part of the scripts remain untouched. The support of context methods in the Blender Palettes was non-existent, so I had to add all from scratch.
 
As the current use of the 2.78 palettes is very limited, if we add things to the struct we are not breaking anything and we can add what we need today and in the future (we are free to implement anything here). The size of the file only will be bigger if we add data for GP and the original size of the struct is small.
 
For conversion, I have developed the corresponding code in versioning file, and we could provide a script  (add-on) for more complex conversion of old files.
 
Of course, use an existing ID will be better for others developers and keeps the list of IDs shorter.
 
I would like to take a final decision in the next meeting and decide if I follow developing animation support of Blender Palettes  or undo all changes I did and take a new direction.
 
Waiting for your comments!
 
Best Regards,
Antonio Vazquez



More information about the Bf-committers mailing list