Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/yafray/intern/export_Plugin.cpp')
-rw-r--r--source/blender/yafray/intern/export_Plugin.cpp62
1 files changed, 34 insertions, 28 deletions
diff --git a/source/blender/yafray/intern/export_Plugin.cpp b/source/blender/yafray/intern/export_Plugin.cpp
index 16ae2d97f62..db9fb7ccc72 100644
--- a/source/blender/yafray/intern/export_Plugin.cpp
+++ b/source/blender/yafray/intern/export_Plugin.cpp
@@ -1,7 +1,9 @@
#include "export_Plugin.h"
#include <math.h>
+
#include <cstring>
+
using namespace std;
@@ -72,7 +74,7 @@ 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(":");
+ size_t sp = path.find_first_of(":");
if (sp==-1) {
string blpath = bprogname;
sp = blpath.find_first_of(":");
@@ -96,9 +98,12 @@ static string YafrayPath()
string path=find_path();
return path;
#else
- static char *alternative[]=
+ static const char *alternative[]=
{
"/usr/local/lib/",
+#ifdef __x86_64__
+ "/usr/lib64/",
+#endif
"/usr/lib/",
NULL
};
@@ -119,9 +124,12 @@ static string YafrayPluginPath()
#ifdef WIN32
return find_path()+"\\plugins";
#else
- static char *alternative[]=
+ static const char *alternative[]=
{
"/usr/local/lib/yafray",
+#ifdef __x86_64__
+ "/usr/lib64/yafray",
+#endif
"/usr/lib/yafray",
NULL
};
@@ -163,7 +171,9 @@ bool yafrayPluginRender_t::initExport()
corehandle = PIL_dynlib_open((char *)(location + "\\yafraycore.dll").c_str());
if (corehandle==NULL)
{
- cerr << "Error loading yafray plugin: " << PIL_dynlib_get_error_as_string(corehandle) << endl;
+ char *err = PIL_dynlib_get_error_as_string(corehandle);
+ if (err) cerr << "Error loading yafray plugin: " << err << endl;
+ else cerr << "Error loading yafray plugin: Unknown." << endl;
return false;
}
location += "\\yafrayplugin.dll";
@@ -184,7 +194,7 @@ bool yafrayPluginRender_t::initExport()
cerr << "Error loading yafray plugin: " << PIL_dynlib_get_error_as_string(handle) << endl;
return false;
}
- yafrayGate = constructor(re->r.YF_numprocs, YafrayPluginPath());
+ yafrayGate = constructor(re->r.threads, YafrayPluginPath());
cout << "YafRay plugin loaded" << endl;
plugin_loaded = true;
@@ -244,7 +254,7 @@ bool yafrayPluginRender_t::writeRender()
params["bias"] = yafray::parameter_t(re->r.YF_raybias);
params["clamp_rgb"] = yafray::parameter_t((re->r.YF_clamprgb==0) ? "on" : "off");
// lynx request
- params["threads"] = yafray::parameter_t((int)re->r.YF_numprocs);
+ params["threads"] = yafray::parameter_t((int)re->r.threads);
blenderYafrayOutput_t output(re);
yafrayGate->render(params, output);
cout << "render finished" << endl;
@@ -270,7 +280,7 @@ static void adjustPath(string &path)
// if relative, expand to full path
char cpath[MAXPATHLEN];
strcpy(cpath, path.c_str());
- BLI_convertstringcode(cpath, G.sce, 0);
+ BLI_convertstringcode(cpath, G.sce);
path = cpath;
#ifdef WIN32
// add drive char if not there
@@ -774,7 +784,7 @@ void yafrayPluginRender_t::writeShader(const string &shader_name, Material* matr
mparams["input"] = yafray::parameter_t(shader_name + temp);
// blendtype, would have been nice if the order would have been the same as for ramps...
- const string blendtype[9] = {"mix", "mul", "add", "sub", "divide", "darken", "difference", "lighten", "screen"};
+ const string blendtype[MTEX_NUM_BLENDTYPES] = {"mix", "mul", "add", "sub", "divide", "darken", "difference", "lighten", "screen", "hue", "sat", "val", "color"};
mparams["mode"] = yafray::parameter_t(blendtype[(int)mtex->blendtype]);
// texture color (for use with MUL and/or no_rgb etc..)
@@ -1080,7 +1090,7 @@ void yafrayPluginRender_t::writeMaterialsAndModulators()
}
-void yafrayPluginRender_t::genUVcoords(vector<yafray::GFLOAT> &uvcoords, VlakRen *vlr, MTFace* uvc, bool comple)
+void yafrayPluginRender_t::genUVcoords(vector<yafray::GFLOAT> &uvcoords, ObjectRen *obr, VlakRen *vlr, MTFace* uvc, bool comple)
{
if (uvc)
{
@@ -1108,9 +1118,8 @@ void yafrayPluginRender_t::genUVcoords(vector<yafray::GFLOAT> &uvcoords, VlakRen
}
}
-void yafrayPluginRender_t::genVcol(vector<yafray::CFLOAT> &vcol, VlakRen *vlr, bool comple)
+void yafrayPluginRender_t::genVcol(vector<yafray::CFLOAT> &vcol, ObjectRen *obr, VlakRen *vlr, bool comple)
{
- ObjectRen *obr= vlr->obr;
MCol *mcol= RE_vlakren_get_mcol(obr, vlr, obr->actmcol, NULL, 0);
if (mcol)
@@ -1144,10 +1153,9 @@ void yafrayPluginRender_t::genVcol(vector<yafray::CFLOAT> &vcol, VlakRen *vlr, b
void yafrayPluginRender_t::genFace(vector<int> &faces,vector<string> &shaders,vector<int> &faceshader,
vector<yafray::GFLOAT> &uvcoords,vector<yafray::CFLOAT> &vcol,
- map<VertRen*, int> &vert_idx,VlakRen *vlr,
+ map<VertRen*, int> &vert_idx,ObjectRen *obr,VlakRen *vlr,
int has_orco,bool has_uv)
{
- ObjectRen *obr= vlr->obr;
Material* fmat = vlr->mat;
bool EXPORT_VCOL = ((fmat->mode & (MA_VERTEXCOL|MA_VERTEXCOLP))!=0);
string fmatname(fmat->id.name);
@@ -1186,16 +1194,15 @@ void yafrayPluginRender_t::genFace(vector<int> &faces,vector<string> &shaders,ve
faces.push_back(idx1); faces.push_back(idx2); faces.push_back(idx3);
- if(has_uv) genUVcoords(uvcoords, vlr, uvc);
- if (EXPORT_VCOL) genVcol(vcol, vlr);
+ if(has_uv) genUVcoords(uvcoords, obr, vlr, uvc);
+ if (EXPORT_VCOL) genVcol(vcol, obr, vlr);
}
void yafrayPluginRender_t::genCompleFace(vector<int> &faces,/*vector<string> &shaders,*/vector<int> &faceshader,
vector<yafray::GFLOAT> &uvcoords,vector<yafray::CFLOAT> &vcol,
- map<VertRen*, int> &vert_idx,VlakRen *vlr,
+ map<VertRen*, int> &vert_idx,ObjectRen *obr,VlakRen *vlr,
int has_orco,bool has_uv)
{
- ObjectRen *obr= vlr->obr;
Material* fmat = vlr->mat;
bool EXPORT_VCOL = ((fmat->mode & (MA_VERTEXCOL|MA_VERTEXCOLP))!=0);
@@ -1211,12 +1218,12 @@ void yafrayPluginRender_t::genCompleFace(vector<int> &faces,/*vector<string> &sh
faces.push_back(idx1); faces.push_back(idx2); faces.push_back(idx3);
- if (has_uv) genUVcoords(uvcoords, vlr, uvc, true);
- if (EXPORT_VCOL) genVcol(vcol, vlr, true);
+ if (has_uv) genUVcoords(uvcoords, obr, vlr, uvc, true);
+ if (EXPORT_VCOL) genVcol(vcol, obr, vlr, true);
}
void yafrayPluginRender_t::genVertices(vector<yafray::point3d_t> &verts, int &vidx,
- map<VertRen*, int> &vert_idx, VlakRen* vlr, int has_orco, Object* obj)
+ map<VertRen*, int> &vert_idx, ObjectRen *obr, VlakRen* vlr, int has_orco, Object* obj)
{
VertRen* ver;
float tvec[3]; // for back2world transform
@@ -1281,7 +1288,7 @@ void yafrayPluginRender_t::genVertices(vector<yafray::point3d_t> &verts, int &vi
}
}
-void yafrayPluginRender_t::writeObject(Object* obj, const vector<VlakRen*> &VLR_list, const float obmat[4][4])
+void yafrayPluginRender_t::writeObject(Object* obj, ObjectRen *obr, const vector<VlakRen*> &VLR_list, const float obmat[4][4])
{
float mtr[4*4];
mtr[0*4+0]=obmat[0][0]; mtr[0*4+1]=obmat[1][0]; mtr[0*4+2]=obmat[2][0]; mtr[0*4+3]=obmat[3][0];
@@ -1342,8 +1349,7 @@ void yafrayPluginRender_t::writeObject(Object* obj, const vector<VlakRen*> &VLR_
fci!=VLR_list.end();++fci)
{
VlakRen* vlr = *fci;
- ObjectRen *obr = vlr->obr;
- genVertices(verts, vidx, vert_idx, vlr, has_orco, obj);
+ genVertices(verts, vidx, vert_idx, obr, vlr, has_orco, obj);
if(RE_vlakren_get_tface(obr, vlr, obr->actmtface, NULL, 0)) has_uv=true;
}
// all faces using the index list created above
@@ -1355,9 +1361,9 @@ void yafrayPluginRender_t::writeObject(Object* obj, const vector<VlakRen*> &VLR_
fci2!=VLR_list.end();++fci2)
{
VlakRen* vlr = *fci2;
- genFace(faces, shaders, faceshader, uvcoords, vcol, vert_idx, vlr, has_orco, has_uv);
+ genFace(faces, shaders, faceshader, uvcoords, vcol, vert_idx, obr, vlr, has_orco, has_uv);
if (vlr->v4)
- genCompleFace(faces, faceshader, uvcoords, vcol, vert_idx, vlr, has_orco, has_uv);
+ genCompleFace(faces, faceshader, uvcoords, vcol, vert_idx, obr, vlr, has_orco, has_uv);
}
// using the ObjectRen database, contruct a new name if object has a parent.
@@ -1388,13 +1394,13 @@ void yafrayPluginRender_t::writeObject(Object* obj, const vector<VlakRen*> &VLR_
void yafrayPluginRender_t::writeAllObjects()
{
// first all objects except dupliverts (and main instance object for dups)
- for (map<Object*, vector<VlakRen*> >::const_iterator obi=all_objects.begin();
+ for (map<Object*, yafrayObjectRen >::const_iterator obi=all_objects.begin();
obi!=all_objects.end(); ++obi)
{
// skip main duplivert object if in dupliMtx_list, written later
Object* obj = obi->first;
if (dupliMtx_list.find(string(obj->id.name))!=dupliMtx_list.end()) continue;
- writeObject(obj, obi->second, obj->obmat);
+ writeObject(obj, obi->second.obr, obi->second.faces, obj->obmat);
}
// Now all duplivert objects (if any) as instances of main object
@@ -1412,7 +1418,7 @@ void yafrayPluginRender_t::writeAllObjects()
// first object written as normal (but with transform of first duplivert)
Object* obj = dup_srcob[dupMtx->first];
- writeObject(obj, all_objects[obj], obmat);
+ writeObject(obj, all_objects[obj].obr, all_objects[obj].faces, obmat);
// all others instances of first
for (unsigned int curmtx=16;curmtx<dupMtx->second.size();curmtx+=16)