Freestyle: Fix for an increasing reference count of images in copied Image Texture shader nodes.

This commit is contained in:
Tamito Kajiyama 2014-07-20 17:41:36 +09:00
parent 45af769020
commit cc33d73185
3 changed files with 9 additions and 5 deletions

View File

@ -232,7 +232,7 @@ unsigned int BlenderStrokeRenderer::get_stroke_mesh_id(void) const
return mesh_id;
}
Material* BlenderStrokeRenderer::GetStrokeShader(bContext *C, Main *bmain, bNodeTree *iNodeTree)
Material* BlenderStrokeRenderer::GetStrokeShader(bContext *C, Main *bmain, bNodeTree *iNodeTree, bool do_id_user)
{
Material *ma = BKE_material_add(bmain, "stroke_shader");
bNodeTree *ntree;
@ -242,7 +242,7 @@ Material* BlenderStrokeRenderer::GetStrokeShader(bContext *C, Main *bmain, bNode
if (iNodeTree) {
// make a copy of linestyle->nodetree
ntree = ntreeCopyTree_ex(iNodeTree, bmain, true);
ntree = ntreeCopyTree_ex(iNodeTree, bmain, do_id_user);
// find the active Output Line Style node
for (bNode *node = (bNode *)ntree->nodes.first; node; node = node->next) {
@ -387,7 +387,7 @@ void BlenderStrokeRenderer::RenderStrokeRep(StrokeRep *iStrokeRep) const
bNodeTree *nt = iStrokeRep->getNodeTree();
Material *ma = (Material *)BLI_ghash_lookup(_nodetree_hash, nt);
if (!ma) {
ma = BlenderStrokeRenderer::GetStrokeShader(_context, freestyle_bmain, nt);
ma = BlenderStrokeRenderer::GetStrokeShader(_context, freestyle_bmain, nt, false);
BLI_ghash_insert(_nodetree_hash, nt, ma);
#if 0
if (G.debug & G_DEBUG_FREESTYLE) {

View File

@ -55,7 +55,7 @@ public:
Render *RenderScene(Render *re, bool render);
static Material* GetStrokeShader(bContext *C, Main *bmain, bNodeTree *iNodeTree);
static Material* GetStrokeShader(bContext *C, Main *bmain, bNodeTree *iNodeTree, bool do_id_user);
protected:
Main *freestyle_bmain;

View File

@ -43,6 +43,7 @@ extern "C" {
#include "DNA_camera_types.h"
#include "DNA_freestyle_types.h"
#include "DNA_group_types.h"
#include "DNA_material_types.h"
#include "DNA_text_types.h"
#include "BKE_freestyle.h"
@ -737,12 +738,15 @@ void FRS_move_active_lineset_down(FreestyleConfig *config)
Material *FRS_create_stroke_material(bContext *C, Main *bmain, Scene *scene)
{
FreestyleLineStyle *linestyle = BKE_linestyle_active_from_scene(scene);
Material *ma;
if (!linestyle) {
cout << "FRS_create_stroke_material: No active line style in the current scene" << endl;
return NULL;
}
return BlenderStrokeRenderer::GetStrokeShader(C, bmain, linestyle->nodetree);
ma = BlenderStrokeRenderer::GetStrokeShader(C, bmain, linestyle->nodetree, true);
ma->id.us = 0;
return ma;
}
} // extern "C"