diff options
author | Ton Roosendaal <ton@blender.org> | 2011-03-03 21:53:07 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2011-03-03 21:53:07 +0300 |
commit | 18afcbcb7db513fa9e27d8245ead3401570eb44e (patch) | |
tree | 672cb683045c6c88a55e2e82a020fe97fd281567 /source/blender/editors/render | |
parent | 3c184def72693e319253c31896b385c297183778 (diff) |
bugfix #26267
ImageWindow + 3D view texture paint + texture preview render + texture nodes.
Threading hell! But it works now :)
Diffstat (limited to 'source/blender/editors/render')
-rw-r--r-- | source/blender/editors/render/render_preview.c | 62 |
1 files changed, 49 insertions, 13 deletions
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index e2f7a459be4..1a454341f01 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -67,13 +67,14 @@ #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_global.h" +#include "BKE_idprop.h" #include "BKE_image.h" #include "BKE_icons.h" #include "BKE_library.h" #include "BKE_main.h" #include "BKE_material.h" #include "BKE_node.h" -#include "BKE_idprop.h" +#include "BKE_texture.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" @@ -156,8 +157,10 @@ typedef struct ShaderPreview { ID *parent; MTex *slot; - /* node materials need full copy during preview render, glsl uses it too */ + /* node materials/texture need full copy during preview render, glsl uses it too */ Material *matcopy; + Tex *texcopy; + float col[4]; /* active object color */ int sizex, sizey; @@ -482,8 +485,13 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre } } else if(id_type==ID_TE) { - Tex *tex= (Tex *)id; + Tex *tex= NULL, *origtex= (Tex *)id; + if(origtex) { + tex= localize_texture(origtex); + sp->texcopy= tex; + BLI_addtail(&pr_main->tex, tex); + } sce->lay= 1<<MA_TEXTURE; for(base= sce->base.first; base; base= base->next) { @@ -508,8 +516,11 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre } } - if(tex && tex->nodetree && sp->pr_method==PR_NODE_RENDER) + if(tex && tex->nodetree && sp->pr_method==PR_NODE_RENDER) { + /* two previews, they get copied by wmJob */ + ntreeInitPreview(origtex->nodetree, sp->sizex, sp->sizey); ntreeInitPreview(tex->nodetree, sp->sizex, sp->sizey); + } } else if(id_type==ID_LA) { Lamp *la= (Lamp *)id; @@ -971,11 +982,20 @@ static void shader_preview_updatejob(void *spv) { ShaderPreview *sp= spv; - if(sp->id && GS(sp->id->name) == ID_MA) { - Material *mat= (Material *)sp->id; + if(sp->id) { + if( GS(sp->id->name) == ID_MA) { + Material *mat= (Material *)sp->id; + + if(sp->matcopy && mat->nodetree && sp->matcopy->nodetree) + ntreeLocalSync(sp->matcopy->nodetree, mat->nodetree); + } + else if( GS(sp->id->name) == ID_TE) { + Tex *tex= (Tex *)sp->id; + + if(sp->texcopy && tex->nodetree && sp->texcopy->nodetree) + ntreeLocalSync(sp->texcopy->nodetree, tex->nodetree); + } - if(sp->matcopy && mat->nodetree && sp->matcopy->nodetree) - ntreeLocalSync(sp->matcopy->nodetree, mat->nodetree); } } @@ -1062,11 +1082,11 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs preview_prepare_scene(sp->scene, NULL, GS(id->name), sp); /* XXX bad exception, end-exec is not being called in render, because it uses local main */ - if(idtype == ID_TE) { - Tex *tex= (Tex *)id; - if(tex->use_nodes && tex->nodetree) - ntreeEndExecTree(tex->nodetree); - } +// if(idtype == ID_TE) { +// Tex *tex= (Tex *)id; +// if(tex->use_nodes && tex->nodetree) +// ntreeEndExecTree(tex->nodetree); +// } } @@ -1108,6 +1128,22 @@ static void shader_preview_free(void *customdata) } MEM_freeN(sp->matcopy); } + if(sp->texcopy) { + struct IDProperty *properties; + /* node previews */ + shader_preview_updatejob(sp); + + /* get rid of copied texture */ + BLI_remlink(&pr_main->tex, sp->texcopy); + free_texture(sp->texcopy); + + properties= IDP_GetProperties((ID *)sp->texcopy, FALSE); + if (properties) { + IDP_FreeProperty(properties); + MEM_freeN(properties); + } + MEM_freeN(sp->texcopy); + } MEM_freeN(sp); } |