From 516a0370adc5afeb1e72cbab3645bb655da3471e Mon Sep 17 00:00:00 2001 From: Alfredo de Greef Date: Fri, 30 Jan 2004 21:47:34 +0000 Subject: Fixed problem of missing win32 drive when file selector was used to choose export path. Fixed missing background when not rendering with GI enabled. --- source/blender/yafray/intern/export_File.cpp | 74 ++++++++++++++++------------ 1 file changed, 43 insertions(+), 31 deletions(-) (limited to 'source/blender/yafray/intern') diff --git a/source/blender/yafray/intern/export_File.cpp b/source/blender/yafray/intern/export_File.cpp index a8eadffd024..991d9ce5012 100755 --- a/source/blender/yafray/intern/export_File.cpp +++ b/source/blender/yafray/intern/export_File.cpp @@ -68,6 +68,19 @@ static int createDir(char* name) } } +extern "C" { extern char bprogname[]; } + +// add drive character if not in path string, using blender executable location as reference +static void addDrive(string &path) +{ + int sp = path.find_first_of(":"); + if (sp==-1) { + string blpath = bprogname; + sp = blpath.find_first_of(":"); + if (sp!=-1) path = blpath.substr(0, sp+1) + path; + } +} + #else #include @@ -123,6 +136,10 @@ bool yafrayFileRender_t::initExport() #endif } xmlpath = U.yfexportdir; +#ifdef WIN32 + // have to add drive char here too, in case win user still wants to set path him/herself + addDrive(xmlpath); +#endif } #ifdef WIN32 @@ -144,15 +161,15 @@ bool yafrayFileRender_t::initExport() // if no export dir set, or could not create, try to create one in the yafray dir, unless it already exists if (dir_failed) { - string ybdir = command_path + "\\YBtest"; + string ybdir = command_path + "YBtest"; if (createDir(const_cast(ybdir.c_str()))==0) dir_failed=true; else dir_failed=false; xmlpath = ybdir; } #else - if(command_path=="") + if (command_path=="") { command_path = unixYafrayPath(); - if(command_path.size()) cout<<"Yafray found at : "<first << "\" >\n"; ostr << "\t\n"; // image->name is full path + string texpath = ima->name; #ifdef WIN32 - // add drive character if not in texpath, using blender executable location as reference - string texpath = ima->name; - int sp = texpath.find_first_of(":"); - if (sp==-1) { - string blpath = bprogname; - sp = blpath.find_first_of(":"); - if (sp!=-1) texpath = blpath.substr(0, sp+1) + texpath; - } -#else - string texpath = ima->name; + // add drive char if not there + addDrive(texpath); #endif - ostr << "\t\t\n"; ostr << "\t\n"; ostr << "\n\n"; @@ -1226,9 +1235,12 @@ bool yafrayFileRender_t::writeWorld() ostr.str(""); ostr << "\n"; - ostr << "\thorr * R.r.GIpower) << - "\" g=\"" << (world->horg * R.r.GIpower) << - "\" b=\"" << (world->horb * R.r.GIpower) << "\" />\n"; + // if no GI used, the GIpower parameter is not always initialized, so in that case ignore it (have to change method to init yafray vars in Blender) + float bg_mult; + if (R.r.GImethod==0) bg_mult=1; else bg_mult=R.r.GIpower; + ostr << "\thorr * bg_mult) << + "\" g=\"" << (world->horg * bg_mult) << + "\" b=\"" << (world->horb * bg_mult) << "\" />\n"; ostr << "\n\n"; xmlfile << ostr.str(); @@ -1243,25 +1255,25 @@ bool yafrayFileRender_t::executeYafray(const string &xmlpath) #ifndef WIN32 sigset_t yaf,old; sigemptyset(&yaf); - sigaddset(&yaf,SIGVTALRM); - sigprocmask(SIG_BLOCK,&yaf,&old); + sigaddset(&yaf, SIGVTALRM); + sigprocmask(SIG_BLOCK, &yaf, &old); int ret=system(command.c_str()); - sigprocmask(SIG_SETMASK,&old,NULL); - if(WIFEXITED(ret)) + sigprocmask(SIG_SETMASK, &old, NULL); + if (WIFEXITED(ret)) { - if(WEXITSTATUS(ret)) cout<<"Executed -"<