From 0b0c8c92441aeb0a21aec52de8689e8000495e0e Mon Sep 17 00:00:00 2001 From: Chris Want Date: Wed, 22 Nov 2006 15:53:46 +0000 Subject: =Texture Plugins= Added a callback instance_init() so that any particular instance of a texture plugin can initialize data. Updated the clouds2 and tile example plugins to have a (dummy) call back. --- source/blender/blenkernel/BKE_plugin_types.h | 1 + source/blender/blenkernel/intern/texture.c | 5 +++++ source/blender/blenloader/intern/readfile.c | 5 +++++ source/blender/blenpluginapi/plugin.h | 2 ++ source/blender/makesdna/DNA_texture_types.h | 1 + 5 files changed, 14 insertions(+) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_plugin_types.h b/source/blender/blenkernel/BKE_plugin_types.h index 338cfee7291..2b7c6c06832 100644 --- a/source/blender/blenkernel/BKE_plugin_types.h +++ b/source/blender/blenkernel/BKE_plugin_types.h @@ -65,6 +65,7 @@ typedef struct _PluginInfo { void (*callback)(int); TexDoit tex_doit; SeqDoit seq_doit; + void (*instance_init)(void *); } PluginInfo; #endif diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 3f78ad3a1d6..62ac911bea7 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -136,6 +136,7 @@ void open_plugin_tex(PluginTex *pit) info_func= (int (*)(PluginInfo *))PIL_dynlib_find_symbol(pit->handle, "plugin_getinfo"); if (!test_dlerr(pit->name, "plugin_getinfo")) { + info->instance_init = NULL; info_func(info); @@ -148,6 +149,7 @@ void open_plugin_tex(PluginTex *pit) pit->varstr= info->varstr; pit->result= info->result; pit->cfra= info->cfra; + pit->instance_init = info->instance_init; if (info->init) info->init(); } MEM_freeN(info); @@ -191,6 +193,9 @@ PluginTex *add_plugin_tex(char *str) *((int *)(pit->data+a))= (int) varstr->def; } + if (pit->instance_init) + pit->instance_init((void *) pit->data); + return pit; } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 807af79f76b..1a00ff1490c 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2255,6 +2255,11 @@ static void direct_link_texture(FileData *fd, Tex *tex) if(tex->plugin) { tex->plugin->handle= 0; open_plugin_tex(tex->plugin); + /* initialize data for this instance, if an initialization + * function exists. + */ + if (tex->plugin->instance_init) + tex->plugin->instance_init((void *) tex->plugin->data); } tex->coba= newdataadr(fd, tex->coba); tex->env= newdataadr(fd, tex->env); diff --git a/source/blender/blenpluginapi/plugin.h b/source/blender/blenpluginapi/plugin.h index f7ffc7e7c8e..b9048b92878 100644 --- a/source/blender/blenpluginapi/plugin.h +++ b/source/blender/blenpluginapi/plugin.h @@ -62,6 +62,8 @@ typedef struct _PluginInfo { void (*callback)(int); TexDoit tex_doit; SeqDoit seq_doit; + + void (*instance_init)(void *); } PluginInfo; int plugin_tex_getversion(void); diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index b93276624d5..01de2196f8c 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -89,6 +89,7 @@ typedef struct PluginTex { float data[32]; int (*doit)(void); + void (*instance_init)(void *); /* should be void (*)(unsigned short)... patched */ void (*callback)(dna_ushort_fix); -- cgit v1.2.3