diff options
Diffstat (limited to 'source/blender/yafray')
-rwxr-xr-x | source/blender/yafray/intern/export_File.cpp | 28 | ||||
-rw-r--r-- | source/blender/yafray/intern/export_Plugin.cpp | 26 | ||||
-rw-r--r-- | source/blender/yafray/intern/yafray_Render.cpp | 20 |
3 files changed, 46 insertions, 28 deletions
diff --git a/source/blender/yafray/intern/export_File.cpp b/source/blender/yafray/intern/export_File.cpp index 4bae9520a90..7b34404a205 100755 --- a/source/blender/yafray/intern/export_File.cpp +++ b/source/blender/yafray/intern/export_File.cpp @@ -342,6 +342,10 @@ static string noise2string(short nbtype) void yafrayFileRender_t::writeTextures() { + // used to keep track of images already written + // (to avoid duplicates if also in imagetex for material TexFace texture) + map<Image*, bool> dupimg; + string ts; for (map<string, MTex*>::const_iterator blendtex=used_textures.begin(); blendtex!=used_textures.end();++blendtex) { @@ -489,8 +493,9 @@ void yafrayFileRender_t::writeTextures() case TEX_IMAGE: { Image* ima = tex->ima; if (ima) { - // remove from imagetex list to avoid possible duplicates when TexFace used - imagetex.erase(ima); + // remember image to avoid duplicates later if also in imagetex + // (formerly done by removing from imagetex, but need image/material link) + dupimg[ima] = true; ostr.str(""); // use image name instead of texname here ostr << "<shader type=\"image\" name=\"" << ima->id.name << "\" >\n"; @@ -536,14 +541,17 @@ void yafrayFileRender_t::writeTextures() for (map<Image*, Material*>::const_iterator imgtex=imagetex.begin(); imgtex!=imagetex.end();++imgtex) { - ostr.str(""); - ostr << "<shader type=\"image\" name=\"" << imgtex->first->id.name << "\" >\n"; - ostr << "\t<attributes>\n"; - string texpath(imgtex->first->name); - adjustPath(texpath); - ostr << "\t\t<filename value=\"" << texpath << "\" />\n"; - ostr << "\t</attributes>\n</shader>\n\n"; - xmlfile << ostr.str(); + // skip if already written above + if (dupimg.find(imgtex->first)==dupimg.end()) { + ostr.str(""); + ostr << "<shader type=\"image\" name=\"" << imgtex->first->id.name << "\" >\n"; + ostr << "\t<attributes>\n"; + string texpath(imgtex->first->name); + adjustPath(texpath); + ostr << "\t\t<filename value=\"" << texpath << "\" />\n"; + ostr << "\t</attributes>\n</shader>\n\n"; + xmlfile << ostr.str(); + } } } diff --git a/source/blender/yafray/intern/export_Plugin.cpp b/source/blender/yafray/intern/export_Plugin.cpp index 0db51bb0120..8470adf86c7 100644 --- a/source/blender/yafray/intern/export_Plugin.cpp +++ b/source/blender/yafray/intern/export_Plugin.cpp @@ -346,6 +346,10 @@ static string noise2string(short nbtype) void yafrayPluginRender_t::writeTextures() { + // used to keep track of images already written + // (to avoid duplicates if also in imagetex for material TexFace texture) + map<Image*, bool> dupimg; + string ts; yafray::paramMap_t params; list<yafray::paramMap_t> lparams; @@ -407,8 +411,9 @@ void yafrayPluginRender_t::writeTextures() { Image* ima = tex->ima; if (ima) { - // remove from imagetex list to avoid possible duplicates when TexFace used - imagetex.erase(ima); + // remember image to avoid duplicates later if also in imagetex + // (formerly done by removing from imagetex, but need image/material link) + dupimg[ima] = true; params["type"] = yafray::parameter_t("image"); params["name"] = yafray::parameter_t(ima->id.name); string texpath = ima->name; @@ -529,13 +534,16 @@ void yafrayPluginRender_t::writeTextures() for (map<Image*, Material*>::const_iterator imgtex=imagetex.begin(); imgtex!=imagetex.end();++imgtex) { - params.clear(); - params["name"] = yafray::parameter_t(imgtex->first->id.name); - params["type"] = yafray::parameter_t("image"); - string texpath(imgtex->first->name); - adjustPath(texpath); - params["filename"] = yafray::parameter_t(texpath); - yafrayGate->addShader(params, lparams); + // skip if already written above + if (dupimg.find(imgtex->first)==dupimg.end()) { + params.clear(); + params["name"] = yafray::parameter_t(imgtex->first->id.name); + params["type"] = yafray::parameter_t("image"); + string texpath(imgtex->first->name); + adjustPath(texpath); + params["filename"] = yafray::parameter_t(texpath); + yafrayGate->addShader(params, lparams); + } } } diff --git a/source/blender/yafray/intern/yafray_Render.cpp b/source/blender/yafray/intern/yafray_Render.cpp index c0bf86b1840..ba5121858e6 100644 --- a/source/blender/yafray/intern/yafray_Render.cpp +++ b/source/blender/yafray/intern/yafray_Render.cpp @@ -1,5 +1,5 @@ //---------------------------------------------------------------------------------------------------- -// YafRay XML export +// YafRay export // // For anyone else looking at this, this was designed for a tabspacing of 2 (YafRay/Jandro standard :) //---------------------------------------------------------------------------------------------------- @@ -124,13 +124,15 @@ bool yafrayRender_t::getAllMatTexObs() if (vlr->ob) { int nv = 0; // number of vertices if (vlr->v4) nv=4; else if (vlr->v3) nv=3; - if (nv) all_objects[vlr->ob].push_back(vlr); - if (vlr->tface) { - Image* fc_img = (Image*)vlr->tface->tpage; - if (fc_img) { - Material* fmat = vlr->mat; - // only save if TexFace enabled - if (fmat && (fmat->mode & MA_FACETEXTURE)) imagetex[fc_img] = fmat; + if (nv) { + all_objects[vlr->ob].push_back(vlr); + if (vlr->tface) { + Image* fc_img = (Image*)vlr->tface->tpage; + if (fc_img) { + Material* fmat = vlr->mat; + // only save if TexFace enabled + if (fmat && (fmat->mode & MA_FACETEXTURE)) imagetex[fc_img] = fmat; + } } } } @@ -151,7 +153,7 @@ bool yafrayRender_t::getAllMatTexObs() // if the name reference list is empty, return now, something was seriously wrong if (dup_srcob.empty()) { - // error() doesn't work to well, when switching from Blender to console at least, so use stdout instead + // error() doesn't work to well, when switching from Blender to console at least, so use stdout instead cout << "ERROR: Duplilist non_empty, but no srcobs\n"; return false; } |