From ec04c09365cd47bf9ca7e86e1fa731dd2e4540db Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 21 Jan 2008 23:17:19 +0000 Subject: Fix for error in approximate AO in last commit, made it really slow. Also, duplis are now taking into account, the proper way to exclude them is to set the material to be not traceable. Removed an unnecessary pointer from the VlakRen struct to save some memory, not really that significant, but still, saves 70 mb for 10 million faces. --- source/blender/yafray/intern/export_File.cpp | 10 +++---- source/blender/yafray/intern/export_File.h | 2 +- source/blender/yafray/intern/export_Plugin.cpp | 36 ++++++++++++-------------- source/blender/yafray/intern/export_Plugin.h | 12 ++++----- source/blender/yafray/intern/yafray_Render.cpp | 8 +++--- source/blender/yafray/intern/yafray_Render.h | 10 +++++-- 6 files changed, 39 insertions(+), 39 deletions(-) (limited to 'source/blender/yafray') diff --git a/source/blender/yafray/intern/export_File.cpp b/source/blender/yafray/intern/export_File.cpp index 48e4f267177..73b30105b27 100644 --- a/source/blender/yafray/intern/export_File.cpp +++ b/source/blender/yafray/intern/export_File.cpp @@ -1188,7 +1188,7 @@ void yafrayFileRender_t::writeMaterialsAndModulators() } -void yafrayFileRender_t::writeObject(Object* obj, const vector &VLR_list, const float obmat[4][4]) +void yafrayFileRender_t::writeObject(Object* obj, ObjectRen *obr, const vector &VLR_list, const float obmat[4][4]) { ostr.str(""); // transform first (not necessarily actual obj->obmat, can be duplivert see below) @@ -1230,7 +1230,6 @@ void yafrayFileRender_t::writeObject(Object* obj, const vector &VLR_li string matname(face0mat->id.name); // use name in imgtex_shader list if 'TexFace' enabled for this material if (face0mat->mode & MA_FACETEXTURE) { - ObjectRen *obr = face0->obr; MTFace* tface = RE_vlakren_get_tface(obr, face0, obr->actmtface, NULL, 0); if (tface) { Image* fimg = (Image*)tface->tpage; @@ -1408,7 +1407,6 @@ void yafrayFileRender_t::writeObject(Object* obj, const vector &VLR_li fci2!=VLR_list.end();++fci2) { VlakRen* vlr = *fci2; - ObjectRen *obr = vlr->obr; Material* fmat = vlr->mat; bool EXPORT_VCOL = ((fmat->mode & (MA_VERTEXCOL|MA_VERTEXCOLP))!=0); string fmatname(fmat->id.name); @@ -1510,13 +1508,13 @@ void yafrayFileRender_t::writeAllObjects() { // first all objects except dupliverts (and main instance object for dups) - for (map >::const_iterator obi=all_objects.begin(); + for (map::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 @@ -1536,7 +1534,7 @@ void yafrayFileRender_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;curmtxsecond.size();curmtx+=16) { // number of 4x4 matrices diff --git a/source/blender/yafray/intern/export_File.h b/source/blender/yafray/intern/export_File.h index 5d2e0c53a21..0eb1bfec1ed 100644 --- a/source/blender/yafray/intern/export_File.h +++ b/source/blender/yafray/intern/export_File.h @@ -18,7 +18,7 @@ class yafrayFileRender_t : public yafrayRender_t virtual void writeTextures(); virtual void writeShader(const std::string &shader_name, Material* matr, const std::string &facetexname=""); virtual void writeMaterialsAndModulators(); - virtual void writeObject(Object* obj, const std::vector &VLR_list, const float obmat[4][4]); + virtual void writeObject(Object* obj, ObjectRen *obr, const std::vector &VLR_list, const float obmat[4][4]); virtual void writeAllObjects(); virtual void writeAreaLamp(LampRen* lamp, int num, float iview[4][4]); virtual void writeLamps(); diff --git a/source/blender/yafray/intern/export_Plugin.cpp b/source/blender/yafray/intern/export_Plugin.cpp index cccd6b1ab8d..c8d20180f8c 100644 --- a/source/blender/yafray/intern/export_Plugin.cpp +++ b/source/blender/yafray/intern/export_Plugin.cpp @@ -1079,7 +1079,7 @@ void yafrayPluginRender_t::writeMaterialsAndModulators() } -void yafrayPluginRender_t::genUVcoords(vector &uvcoords, VlakRen *vlr, MTFace* uvc, bool comple) +void yafrayPluginRender_t::genUVcoords(vector &uvcoords, ObjectRen *obr, VlakRen *vlr, MTFace* uvc, bool comple) { if (uvc) { @@ -1107,9 +1107,8 @@ void yafrayPluginRender_t::genUVcoords(vector &uvcoords, VlakRen } } -void yafrayPluginRender_t::genVcol(vector &vcol, VlakRen *vlr, bool comple) +void yafrayPluginRender_t::genVcol(vector &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) @@ -1143,10 +1142,9 @@ void yafrayPluginRender_t::genVcol(vector &vcol, VlakRen *vlr, b void yafrayPluginRender_t::genFace(vector &faces,vector &shaders,vector &faceshader, vector &uvcoords,vector &vcol, - map &vert_idx,VlakRen *vlr, + map &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); @@ -1185,16 +1183,15 @@ void yafrayPluginRender_t::genFace(vector &faces,vector &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 &faces,/*vector &shaders,*/vector &faceshader, vector &uvcoords,vector &vcol, - map &vert_idx,VlakRen *vlr, + map &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); @@ -1210,12 +1207,12 @@ void yafrayPluginRender_t::genCompleFace(vector &faces,/*vector &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 &verts, int &vidx, - map &vert_idx, VlakRen* vlr, int has_orco, Object* obj) + map &vert_idx, ObjectRen *obr, VlakRen* vlr, int has_orco, Object* obj) { VertRen* ver; float tvec[3]; // for back2world transform @@ -1280,7 +1277,7 @@ void yafrayPluginRender_t::genVertices(vector &verts, int &vi } } -void yafrayPluginRender_t::writeObject(Object* obj, const vector &VLR_list, const float obmat[4][4]) +void yafrayPluginRender_t::writeObject(Object* obj, ObjectRen *obr, const vector &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]; @@ -1341,8 +1338,7 @@ void yafrayPluginRender_t::writeObject(Object* obj, const vector &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 @@ -1354,9 +1350,9 @@ void yafrayPluginRender_t::writeObject(Object* obj, const vector &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. @@ -1387,13 +1383,13 @@ void yafrayPluginRender_t::writeObject(Object* obj, const vector &VLR_ void yafrayPluginRender_t::writeAllObjects() { // first all objects except dupliverts (and main instance object for dups) - for (map >::const_iterator obi=all_objects.begin(); + for (map::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 @@ -1411,7 +1407,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;curmtxsecond.size();curmtx+=16) diff --git a/source/blender/yafray/intern/export_Plugin.h b/source/blender/yafray/intern/export_Plugin.h index 1ce4988a260..660271daf96 100644 --- a/source/blender/yafray/intern/export_Plugin.h +++ b/source/blender/yafray/intern/export_Plugin.h @@ -35,7 +35,7 @@ class yafrayPluginRender_t : public yafrayRender_t virtual void writeTextures(); virtual void writeShader(const std::string &shader_name, Material* matr, const std::string &facetexname=""); virtual void writeMaterialsAndModulators(); - virtual void writeObject(Object* obj, + virtual void writeObject(Object* obj, ObjectRen *obr, const std::vector &VLR_list, const float obmat[4][4]); virtual void writeAllObjects(); virtual void writeAreaLamp(LampRen* lamp, int num, float iview[4][4]); @@ -48,18 +48,18 @@ class yafrayPluginRender_t : public yafrayRender_t virtual bool initExport(); virtual bool finishExport(); - void genUVcoords(std::vector &uvcoords,VlakRen *vlr,MTFace* uvc, bool comple=false); - void genVcol(std::vector &vcol, VlakRen *vlr, bool comple=false); + void genUVcoords(std::vector &uvcoords,ObjectRen *obr,VlakRen *vlr,MTFace* uvc, bool comple=false); + void genVcol(std::vector &vcol, ObjectRen *obr, VlakRen *vlr, bool comple=false); void genFace(std::vector &faces,std::vector &shaders,std::vector &faceshader, std::vector &uvcoords,std::vector &vcol, - std::map &vert_idx,VlakRen *vlr, + std::map &vert_idx,ObjectRen *obr,VlakRen *vlr, int has_orco,bool has_uv); void genCompleFace(std::vector &faces,/*std::vector &shaders,*/std::vector &faceshader, std::vector &uvcoords,std::vector &vcol, - std::map &vert_idx,VlakRen *vlr, + std::map &vert_idx,ObjectRen *obr, VlakRen *vlr, int has_orco,bool has_uv); void genVertices(std::vector &verts, int &vidx, - std::map &vert_idx, VlakRen* vlr, int has_orco, Object* obj); + std::map &vert_idx, ObjectRen *obr, VlakRen* vlr, int has_orco, Object* obj); }; class blenderYafrayOutput_t : public yafray::colorOutput_t diff --git a/source/blender/yafray/intern/yafray_Render.cpp b/source/blender/yafray/intern/yafray_Render.cpp index fa7c61072f4..d9d421e0720 100644 --- a/source/blender/yafray/intern/yafray_Render.cpp +++ b/source/blender/yafray/intern/yafray_Render.cpp @@ -141,15 +141,15 @@ bool yafrayRender_t::getAllMatTexObs() // Make list of faces per object, ignore <3 vert faces, duplicate vertex sorting done later. // ignore null object pointers. // Also make list of facetexture images (material 'TexFace'). - if (vlr->obr->ob) { + if (obr->ob) { int nv = 0; // number of vertices MTFace *tface; if (vlr->v4) nv=4; else if (vlr->v3) nv=3; if (nv) { - ObjectRen *obr= vlr->obr; renderobs[obr->ob->id.name] = obr->ob; - all_objects[obr->ob].push_back(vlr); + all_objects[obr->ob].obr= obr; + all_objects[obr->ob].faces.push_back(vlr); tface= RE_vlakren_get_tface(obr, vlr, obr->actmtface, NULL, 0); if (tface && tface->tpage) { @@ -184,7 +184,7 @@ bool yafrayRender_t::getAllMatTexObs() // in all_objects with the name given in dupliMtx_list if (!dupliMtx_list.empty()) { - for (map >::const_iterator obn=all_objects.begin(); + for (map::const_iterator obn=all_objects.begin(); obn!=all_objects.end();++obn) { Object* obj = obn->first; diff --git a/source/blender/yafray/intern/yafray_Render.h b/source/blender/yafray/intern/yafray_Render.h index 0debb0009fa..43d2c6c602a 100644 --- a/source/blender/yafray/intern/yafray_Render.h +++ b/source/blender/yafray/intern/yafray_Render.h @@ -52,6 +52,12 @@ extern void error (char *fmt, ...); #include #include +class yafrayObjectRen { + public: + std::vector faces; + ObjectRen *obr; +}; + class yafrayRender_t { public: @@ -72,7 +78,7 @@ class yafrayRender_t bool hasworld; - std::map > all_objects; + std::map all_objects; std::map used_materials; std::map used_textures; std::map > dupliMtx_list; @@ -86,7 +92,7 @@ class yafrayRender_t virtual void writeTextures()=0; virtual void writeShader(const std::string &shader_name, Material* matr, const std::string &facetexname)=0; virtual void writeMaterialsAndModulators()=0; - virtual void writeObject(Object* obj, const std::vector &VLR_list, const float obmat[4][4])=0; + virtual void writeObject(Object* obj, ObjectRen *obr, const std::vector &VLR_list, const float obmat[4][4])=0; virtual void writeAllObjects()=0; virtual void writeLamps()=0; virtual void writeCamera()=0; -- cgit v1.2.3