diff --git a/source/blender/src/renderwin.c b/source/blender/src/renderwin.c index 64d64ad9da5..8aade84fe83 100644 --- a/source/blender/src/renderwin.c +++ b/source/blender/src/renderwin.c @@ -797,7 +797,7 @@ static void renderwin_progress(RenderWin *rw, RenderResult *rr, volatile rcti *r rcti win_rct; float *rectf= NULL, fullrect[2][2]; unsigned int *rect32= NULL; - int ymin, ymax; + int ymin, ymax, xmin, xmax; /* if renrect argument, we only display scanlines */ if(renrect) { @@ -805,15 +805,21 @@ static void renderwin_progress(RenderWin *rw, RenderResult *rr, volatile rcti *r if(rr->renlay==NULL || renrect->ymax>=rr->recty) return; + /* xmin here is first subrect x coord, xmax defines subrect width */ + xmin = renrect->xmin; + xmax = renrect->xmax - xmin; + if (xmax<2) return; + ymin= renrect->ymin; - ymax= renrect->ymax-ymin; + ymax= renrect->ymax - ymin; if(ymax<2) return; renrect->ymin= renrect->ymax; } else { - ymin= 0; - ymax= rr->recty-2*rr->crop; + xmin = ymin = 0; + xmax = rr->rectx - 2*rr->crop; + ymax = rr->recty - 2*rr->crop; } /* renderwindow cruft */ @@ -835,7 +841,7 @@ static void renderwin_progress(RenderWin *rw, RenderResult *rr, volatile rcti *r } if(rectf) { /* if scanline updates... */ - rectf+= 4*rr->rectx*ymin; + rectf+= 4*(rr->rectx*ymin + xmin); /* when rendering more pixels than needed, we crop away cruft */ if(rr->crop) @@ -844,8 +850,8 @@ static void renderwin_progress(RenderWin *rw, RenderResult *rr, volatile rcti *r /* tilerect defines drawing offset from (0,0) */ /* however, tilerect (xmin, ymin) is first pixel */ - fullrect[0][0] += (rr->tilerect.xmin+rr->crop)*rw->zoom; - fullrect[0][1] += (rr->tilerect.ymin+rr->crop + ymin)*rw->zoom; + fullrect[0][0] += (rr->tilerect.xmin + rr->crop + xmin)*rw->zoom; + fullrect[0][1] += (rr->tilerect.ymin + rr->crop + ymin)*rw->zoom; glEnable(GL_SCISSOR_TEST); glaDefine2DArea(&win_rct); @@ -855,13 +861,11 @@ static void renderwin_progress(RenderWin *rw, RenderResult *rr, volatile rcti *r glDrawBuffer(GL_FRONT); #endif glPixelZoom(rw->zoom, rw->zoom); - + if(rect32) - glaDrawPixelsSafe(fullrect[0][0], fullrect[0][1], rr->rectx-2*rr->crop, ymax, rr->rectx, - GL_RGBA, GL_UNSIGNED_BYTE, rect32); - else - glaDrawPixelsSafe_to32(fullrect[0][0], fullrect[0][1], rr->rectx-2*rr->crop, ymax, rr->rectx, - GL_RGBA, GL_FLOAT, rectf); + glaDrawPixelsSafe(fullrect[0][0], fullrect[0][1], xmax, ymax, rr->rectx, GL_RGBA, GL_UNSIGNED_BYTE, rect32); + else + glaDrawPixelsSafe_to32(fullrect[0][0], fullrect[0][1], xmax, ymax, rr->rectx, GL_RGBA, GL_FLOAT, rectf); glPixelZoom(1.0, 1.0); diff --git a/source/blender/yafray/intern/export_File.cpp b/source/blender/yafray/intern/export_File.cpp index 25e51a1b0bb..740431dd3a0 100755 --- a/source/blender/yafray/intern/export_File.cpp +++ b/source/blender/yafray/intern/export_File.cpp @@ -1177,7 +1177,11 @@ void yafrayFileRender_t::writeObject(Object* obj, const vector &VLR_li xmlfile << ostr.str(); ostr.str(""); - ostr << "id.name << "\""; + // if objects are externally linked from a library, they could have a name that is already + // defined locally, so to prevent name clashes, prefix name with 'lib' + string obname(obj->id.name); + if (obj->id.flag & (LIB_EXTERN|LIB_INDIRECT))obname = "lib_" + obname; + ostr << "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); blenderYafrayOutput_t output(re); yafrayGate->render(params, output); cout << "render finished" << endl; @@ -1350,7 +1352,11 @@ void yafrayPluginRender_t::writeObject(Object* obj, const vector &VLR_ genCompleFace(faces, faceshader, uvcoords, vcol, vert_idx, vlr, has_orco, has_uv); } - yafrayGate->addObject_trimesh(string(obj->id.name), verts, faces, uvcoords, vcol, + // if objects are externally linked from a library, they could have a name that is already + // defined locally, so to prevent name clashes, prefix name with 'lib' + string obname(obj->id.name); + if (obj->id.flag & (LIB_EXTERN|LIB_INDIRECT))obname = "lib_" + obname; + yafrayGate->addObject_trimesh(obname, verts, faces, uvcoords, vcol, shaders, faceshader, sm_angle, castShadows, true, true, caus, has_orco, caus_rcolor, caus_tcolor, caus_IOR); yafrayGate->transformPop(); @@ -1883,14 +1889,15 @@ extern "C" { bool blenderYafrayOutput_t::putPixel(int x, int y, const yafray::color_t &c, yafray::CFLOAT alpha, yafray::PFLOAT depth) { - /* XXX how to get the image from Blender and write to it. This call doesn't allow to change buffer rects */ + // XXX how to get the image from Blender and write to it. This call doesn't allow to change buffer rects RenderResult rres; RE_GetResultImage(re, &rres); // rres.rectx, rres.recty is width/height // rres.rectf is float buffer, scanlines starting in bottom // rres.rectz is zbuffer, available when associated pass is set - const unsigned int yy = (rres.recty - 1) - y; + const unsigned int maxy = rres.recty-1; + const unsigned int yy = maxy - y; const unsigned int px = yy * rres.rectx; // rgba @@ -1901,15 +1908,25 @@ bool blenderYafrayOutput_t::putPixel(int x, int y, const yafray::color_t &c, *fpt = alpha; // depth values - float* zbuf = rres.rectz + px; - if (zbuf) zbuf[x] = depth; - - out++; - // draw on completion of bucket & end of pass - if (((out & 4095)==0) || ((out % (re->rectx*re->recty))==0)) { + if (rres.rectz) rres.rectz[px + x] = depth; + + // attempt to optimize drawing, by only drawing the tile currently rendered by yafray, + // and not the entire display every time (blender has to to do float->char conversion), + // but since the tile is not actually known, it has to be calculated from the coords. + // not sure if it really makes all that much difference at all... unless rendering really large pictures + // (renderwin.c also had to be adapted for this) + // tile start & end coords + int txs = x & 0xffffffc0, tys = y & 0xffffffc0; + int txe = txs + 63, tye = tys + 63; + // tile border clip + if (txe >= rres.rectx) txe = rres.rectx-1; + if (tye >= rres.recty) tye = maxy; + // draw tile if last pixel reached + if ((y*rres.rectx + x) == (tye*rres.rectx + txe)) { re->result->renlay = render_get_active_layer(re, re->result); - /* XXX second arg is rcti *rect, allows to indicate sub-rect in image to draw */ - re->display_draw(re->result, NULL); + // note: ymin/ymax swapped here, img. upside down! + rcti rt = {txs, txe+1, maxy-tye, ((tys==0) ? maxy : ((maxy+1)-tys))}; // !!! tys can be zero + re->display_draw(re->result, &rt); } if (re->test_break()) return false;