Hey guys!
I’m trying to extend the Blender’s painting system, to make it be able to paint with multiple canvas and textures. I’ve tested with two fixed canvas, it works.
I’m starting to extending the Brush
with a ListBase
which will store PaintTarget
typedef struct Brush{
ListBase mtexs;
} Brush;
typedef struct PaintTarget {
struct PaintTarget *next, *prev;
struct ImageUser iuser;
struct Tex *tex;
struct Image *ima; // the canvas image
} PaintTarget;
I’ve already defined the dna/rna stuff.
Write in writefile.c
// static void write_brush
// adapted from color palette
PaintTarget *paint_target;
for (paint_target = brush->mtexs.first; paint_target; paint_target = paint_target->next) {
BLO_write_struct(writer, PaintTarget, paint_target);
}
Read in readfile.c
// static void direct_link_brush
BLO_read_list(reader, &(brush->mtexs));
// static void lib_link_brush
LISTBASE_FOREACH (PaintTarget *, paint_target, &brush->mtexs) {
paint_target->iuser.ok = 1;
paint_target->iuser.scene = NULL;
if (paint_target->ima) {
paint_target->ima = newlibadr(fd, brush->id.lib, paint_target->ima);
}
}
The code above worked almost. But after save it to disk and reload it lost the user of that Image, the UI looks like this
In Python Console,
bpy.data.images['Material Base Color.png'].users
equals to 0