From 41144750da7d0dab39bc487fe086f627347fb16d Mon Sep 17 00:00:00 2001 From: Alfredo de Greef Date: Sun, 18 Jan 2004 20:00:17 +0000 Subject: corrected particle object dupliverts and aramature duplivert export problems corrected power slider increment update --- source/blender/makesdna/DNA_object_types.h | 2 -- .../renderconverter/intern/convertBlenderScene.c | 24 ++++++------- source/blender/src/buttons_scene.c | 8 ++--- source/blender/yafray/intern/export_File.cpp | 39 +++++++++++----------- source/blender/yafray/intern/yafray_Render.cpp | 25 ++++---------- 5 files changed, 41 insertions(+), 57 deletions(-) diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 4fb5bd6c5c3..c5fa7aeafd5 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -278,8 +278,6 @@ extern Object workob; #define OB_DONE 1024 #define OB_RADIO 2048 #define OB_FROMGROUP 4096 -/* yafray: flag to indicate this object is a source object for duplivert instancing, see convertBlenderScene.c */ -#define OB_YAF_DUPLISOURCE 8192 /* ob->gameflag */ #define OB_DYNAMIC 1 diff --git a/source/blender/renderconverter/intern/convertBlenderScene.c b/source/blender/renderconverter/intern/convertBlenderScene.c index 43fed2d269a..fd131515a3c 100644 --- a/source/blender/renderconverter/intern/convertBlenderScene.c +++ b/source/blender/renderconverter/intern/convertBlenderScene.c @@ -2855,12 +2855,9 @@ void RE_rotateBlenderScene(void) ob= G.main->object.first; while(ob) { ob->flag &= ~OB_DONE; - /* yafray: OB_YAF_DUPLISOURCE flag should be cleared as well here, otherwise is saved in .blend */ - ob->flag &= ~OB_YAF_DUPLISOURCE; ob= ob->id.next; } - /* layers: render in foreground current 3D window */ lay= G.scene->lay; if(G.vd) lay= G.vd->lay; @@ -2876,15 +2873,15 @@ void RE_rotateBlenderScene(void) This only works for dupliverts, dupliframes handled below. This is based on the assumption that OB_DONE is only set for duplivert objects, before scene conversion, there are no other flags set to indicate it's use as far as I know... - A special flag only used by yafray is set to indicate this object is the 'source' object - of which all other duplivert objects are an instance of. - Correction: NOT done for lamps, these are included as separate objects, see below */ - if ((ob->type!=OB_LAMP) && (R.r.mode & R_YAFRAY)) { + NOT done for lamps, these are included as separate objects, see below. + correction: also ignore lattices, armatures and camera's (.....) */ + if ((ob->type!=OB_LATTICE) && (ob->type!=OB_ARMATURE) && + (ob->type!=OB_LAMP) && (ob->type!=OB_CAMERA) && (R.r.mode & R_YAFRAY)) + { printf("Adding %s to renderlist\n", ob->id.name); ob->flag &= ~OB_DONE; init_render_object(ob); ob->flag |= OB_DONE; - ob->flag |= OB_YAF_DUPLISOURCE; } } else { @@ -2900,7 +2897,6 @@ void RE_rotateBlenderScene(void) if ((ob->type!=OB_MBALL) && ((ob->transflag & OB_DUPLIFRAMES)!=0)) { printf("Object %s has OB_DUPLIFRAMES set, adding to renderlist\n", ob->id.name); init_render_object(ob); - ob->flag |= OB_YAF_DUPLISOURCE; } } make_duplilist(sce, ob); @@ -2929,8 +2925,11 @@ void RE_rotateBlenderScene(void) /* yafray: special handling of duplivert objects for yafray: only the matrix is stored, together with the source object name. Since the original object is needed as well, it is included in the renderlist (see above) - correction: NOT done for lamps, these need to be included as normal lamps separately */ - if ((obd->type!=OB_LAMP) && (R.r.mode & R_YAFRAY)) { + NOT done for lamps, these need to be included as normal lamps separately + correction: also ignore lattices, armatures and cameras (....) */ + if ((obd->type!=OB_LATTICE) && (obd->type!=OB_ARMATURE) && + (obd->type!=OB_LAMP) && (obd->type!=OB_CAMERA) && (R.r.mode & R_YAFRAY)) + { printf("Adding dupli matrix for object %s\n", obd->id.name); YAF_addDupliMtx(obd); } @@ -2944,8 +2943,7 @@ void RE_rotateBlenderScene(void) else { /* yafray: if there are linked data objects (except lamps), yafray only needs to know about one, the rest can be instanciated. - The dupliMtx list is used for this purpose, so the test function sets the OB_YAF_DUPLISOURCE - flag when for the already known object as well. */ + The dupliMtx list is used for this purpose */ if (R.r.mode & R_YAFRAY) { if ((ob->type!=OB_LAMP) && (YAF_objectKnownData(ob))) printf("Added dupli matrix for linked data object %s\n", ob->id.name); diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c index 61935ebd65e..82977d1fdac 100644 --- a/source/blender/src/buttons_scene.c +++ b/source/blender/src/buttons_scene.c @@ -1219,7 +1219,7 @@ static void render_panel_yafrayGI() if (G.scene->r.GImethod>0) { if (G.scene->r.GIpower==0) G.scene->r.GIpower=1; - uiDefButF(block, NUM, 0, "Power:", 5,35,154,20, &G.scene->r.GIpower, 0.01, 100.0, 0, 0, "GI lighting intensity scale, 1 is normal"); + uiDefButF(block, NUM, 0, "Power:", 5,35,154,20, &G.scene->r.GIpower, 0.01, 10.0, 10, 0, "GI lighting intensity scale, 1 is normal"); } @@ -1269,10 +1269,8 @@ static void render_panel_yafrayGlobal() // label to force a boundbox for buttons not to be centered uiDefBut(block, LABEL, 0, " ", 305,180,10,10, 0, 0, 0, 0, 0, ""); - if(G.scene->r.YF_raybias==0.0) G.scene->r.YF_raybias=0.001; uiDefButF(block, NUMSLI, 0,"Bi ", 5,35,150,20, &(G.scene->r.YF_raybias), 0.0, 10.0 ,0,0, "Shadow ray bias to avoid self shadowing"); - if(G.scene->r.YF_raydepth==0) G.scene->r.YF_raydepth=5; uiDefButI(block, NUM, 0, "Raydepth ", 5,60,150,20, &G.scene->r.YF_raydepth, 1.0, 80.0, 10, 10, "Maximum render ray depth from the camera"); uiDefButF(block, NUMSLI, 0, "Gam ", 5,10,150,20, &G.scene->r.YF_gamma, 0.001, 5.0, 0, 0, "Gamma correction, 1 is off"); @@ -1291,9 +1289,11 @@ void render_panels() render_panel_render(); render_panel_anim(); render_panel_format(); - /* yafray: GI panel only available when yafray enabled for rendering */ + /* yafray: GI & Global panel, only available when yafray enabled for rendering */ if (G.scene->r.mode & R_YAFRAY) { if (G.scene->r.YF_gamma==0.0) G.scene->r.YF_gamma=1.0; + if (G.scene->r.YF_raybias==0.0) G.scene->r.YF_raybias=0.001; + if (G.scene->r.YF_raydepth==0) G.scene->r.YF_raydepth=5; render_panel_yafrayGlobal(); render_panel_yafrayGI(); } diff --git a/source/blender/yafray/intern/export_File.cpp b/source/blender/yafray/intern/export_File.cpp index 04614efb2af..8d20eb3e681 100755 --- a/source/blender/yafray/intern/export_File.cpp +++ b/source/blender/yafray/intern/export_File.cpp @@ -898,9 +898,10 @@ void yafrayFileRender_t::writeAllObjects() for (map >::const_iterator obi=all_objects.begin(); obi!=all_objects.end(); ++obi) { - // skip main duplivert, written later - if (obi->first->flag & OB_YAF_DUPLISOURCE) continue; - writeObject(obi->first, obi->second, obi->first->obmat); + // 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, obi->first->obmat); } // Now all duplivert objects (if any) as instances of main object @@ -954,19 +955,18 @@ void yafrayFileRender_t::writeAllObjects() } -void yafrayFileRender_t::writeAreaLamp(LampRen* lamp,int num) +void yafrayFileRender_t::writeAreaLamp(LampRen* lamp, int num) { - if(lamp->area_shape != LA_AREA_SQUARE) return; - float *a=lamp->area[0],*b=lamp->area[1],*c=lamp->area[2],*d=lamp->area[3]; + if (lamp->area_shape!=LA_AREA_SQUARE) return; + float *a=lamp->area[0], *b=lamp->area[1], *c=lamp->area[2], *d=lamp->area[3]; ostr.str(""); - ostr << "energy <<"\">" <r<<"\" g=\""<g<<"\" b=\""<b<<"\"/>"<"<"<"<"<"<dist <<"\">\n"; + ostr << "\t\n"; + ostr << "\t\n"; + ostr << "\t\n"; + ostr << "\t\n"; + ostr << "\tr << "\" g=\"" << lamp->g << "\" b=\"" << lamp->b << "\" />\n"; + ostr << "\n\n"; xmlfile << ostr.str(); } @@ -977,14 +977,14 @@ void yafrayFileRender_t::writeLamps() { ostr.str(""); LampRen* lamp = R.la[i]; - if(lamp->type==LA_AREA) {writeAreaLamp(lamp,i);continue;} + if (lamp->type==LA_AREA) { writeAreaLamp(lamp,i); continue; } // TODO: add decay setting in yafray ostr << "type==LA_LOCAL) ostr << "pointlight"; else if (lamp->type==LA_SPOT) ostr << "spotlight"; - else if (lamp->type==LA_SUN) // for now, hemi == sun + else if ((lamp->type==LA_SUN) || (lamp->type==LA_HEMI)) // for now, hemi same as sun ostr << "sunlight"; else { // possibly unknown type, ignore @@ -1024,9 +1024,10 @@ void yafrayFileRender_t::writeLamps() ostr << "\tco[0] << "\" y=\"" << lamp->co[1] << "\" z=\"" << lamp->co[2] << "\" />\n"; // 'to' for spot, already calculated by Blender if (lamp->type==LA_SPOT) - ostr << "\tco[0]+1e6*lamp->vec[0] - << "\" y=\"" << lamp->co[1]+1e6*lamp->vec[1] - << "\" z=\"" << lamp->co[2]+1e6*lamp->vec[2] << "\" />\n"; + ostr << "\tco[0] //+1e6*lamp->vec[0] + << "\" y=\"" << lamp->co[1] //+1e6*lamp->vec[1] + << "\" z=\"" << lamp->co[2] //+1e6*lamp->vec[2] + << "\" />\n"; // color // rgb in LampRen is premultiplied by energy, power is compensated for that above ostr << "\tr << "\" g=\"" << lamp->g << "\" b=\"" << lamp->b << "\" />\n"; diff --git a/source/blender/yafray/intern/yafray_Render.cpp b/source/blender/yafray/intern/yafray_Render.cpp index aa031126966..a8f6746f36e 100644 --- a/source/blender/yafray/intern/yafray_Render.cpp +++ b/source/blender/yafray/intern/yafray_Render.cpp @@ -33,7 +33,7 @@ bool yafrayRender_t::exportScene() maxraydepth = 5; // will be set to maximum depth used in blender materials // recreate the scene as object data, as well as sorting the material & textures, ignoring duplicates - if (!getAllMatTexObs()) + if (!getAllMatTexObs()) { // error found, clear for next call clearAll(); @@ -137,30 +137,22 @@ bool yafrayRender_t::getAllMatTexObs() // in case dupliMtx_list not empty, make sure that there is at least one source object // in all_objects with the name given in dupliMtx_list - if (dupliMtx_list.size()!=0) { + if (!dupliMtx_list.empty()) { for (map >::const_iterator obn=all_objects.begin(); obn!=all_objects.end();++obn) { Object* obj = obn->first; - if (obj->flag & OB_YAF_DUPLISOURCE) dup_srcob[string(obj->id.name)] = obj; + string obname = obj->id.name; + if (dupliMtx_list.find(obname)!=dupliMtx_list.end()) dup_srcob[obname] = obj; } // if the name reference list is empty, return now, something was seriously wrong - if (dup_srcob.size()==0) { + if (dup_srcob.empty()) { // 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; } - // else make sure every object is found in dupliMtx_list - for (map::const_iterator obn2=dup_srcob.begin(); - obn2!=dup_srcob.end();++obn2) - { - if (dupliMtx_list.find(obn2->first)==dupliMtx_list.end()) { - cout << "ERROR: Source ob missing for dupli's\n"; - return false; - } - } } return true; @@ -180,12 +172,10 @@ bool yafrayRender_t::objectKnownData(Object* obj) { // if object data already known, no need to include in renderlist, otherwise save object datapointer if (objectData.find(obj->data)!=objectData.end()) { - // set OB_YAF_DUPLISOURCE flag for known object Object* orgob = objectData[obj->data]; - orgob->flag |= OB_YAF_DUPLISOURCE; // first save original object matrix in dupliMtx_list, if not added yet if (dupliMtx_list.find(orgob->id.name)==dupliMtx_list.end()) { - cout << "Added orignal matrix\n"; + cout << "Added original matrix\n"; addDupliMtx(orgob); } // then save matrix of linked object in dupliMtx_list, using name of ORIGINAL object @@ -198,6 +188,3 @@ bool yafrayRender_t::objectKnownData(Object* obj) objectData[obj->data] = obj; return false; } - - - -- cgit v1.2.3