If YFexport directory is not set, it will now attempt to use the temp directory.

(/tmp or $TEMP for win.)

Probably too early still, but now in plugin mode the floatbuffer will be used too,
including postprocessing.
This commit is contained in:
Alfredo de Greef 2004-12-30 01:34:42 +00:00
parent fcb00bf294
commit a970419d0e
3 changed files with 60 additions and 36 deletions

@ -820,8 +820,16 @@ void yafrayRender()
{
R.flag |= R_RENDERING; /* !!! */
/* all allocs moved here, out of export code */
/* display rgba buf */
if (R.rectot) MEM_freeN(R.rectot);
R.rectot = MEM_callocN(sizeof(int)*R.rectx*R.recty, "rectot");
/* zbuf */
if (R.rectz) MEM_freeN(R.rectz);
R.rectz = NULL;
R.rectz = (unsigned int *)MEM_mallocN(sizeof(int)*R.rectx*R.recty, "rectz");
/* float rgba buf */
if (R.rectftot) MEM_freeN(R.rectftot);
if (R.r.mode & R_FBUF) R.rectftot= MEM_callocN(4*sizeof(float)*R.rectx*R.recty, "rectftot");
// switch must be done before prepareScene()
if (!R.r.YFexportxml)
@ -835,6 +843,12 @@ void yafrayRender()
YAF_exportScene();
finalizeScene();
// show postpro effects if floatbuffer used (plugin only)
if (R.r.YFexportxml) {
if ((R.r.mode & R_FBUF) && R.rectftot)
RE_floatbuffer_to_output();
}
}

@ -119,8 +119,12 @@ bool yafrayFileRender_t::initExport()
// try the user setting setting first, export dir must be set and exist
if (strlen(U.yfexportdir)==0)
{
cout << "No export directory set in user defaults!\n";
dir_failed = true;
cout << "No export directory set in user defaults!" << endl;
char* temp = getenv("TEMP");
// if no envar, use /tmp
xmlpath = temp ? temp : "/tmp";
cout << "Will try TEMP instead: " << xmlpath << endl;
// no fail here, but might fail when opening file...
}
else
{
@ -256,9 +260,6 @@ void yafrayFileRender_t::displayImage()
// although it is possible to load the image using blender,
// maybe it is best to just do a read here, for now the yafray output is always a raw tga anyway
// rectot already freed in initrender
R.rectot = (unsigned int *)MEM_callocN(sizeof(int)*R.rectx*R.recty, "rectot");
FILE* fp = fopen(imgout.c_str(), "rb");
if (fp==NULL) {
cout << "YAF_displayImage(): Could not open image file\n";

@ -189,20 +189,18 @@ bool yafrayPluginRender_t::initExport()
plugin_loaded = true;
}
if (R.rectot==NULL) {
R.rectot = (unsigned int *)MEM_callocN(sizeof(int)*R.rectx*R.recty, "rectot");
unsigned int *bpt=R.rectot, count=R.rectx*R.recty;
while (--count) bpt[count] = 0xff800000;
cout << "Image allocated" << endl;
}
// all buffers allocated in initrender.c
unsigned int *bpt=R.rectot, count=R.rectx*R.recty;
while (--count) bpt[count] = 0xff800000;
cout << "Image initialized" << endl;
if (R.rectz==NULL) {
R.rectz = (unsigned int *)MEM_mallocN(sizeof(int)*R.rectx*R.recty, "rectz");
unsigned int *zbuf=R.rectz, count=R.rectx*R.recty;
while (--count) zbuf[count] = 0x7fffffff;
cout << "Zbuffer allocated" << endl;
}
unsigned int *zbuf=R.rectz;
count = R.rectx*R.recty;
while (--count) zbuf[count] = 0x7fffffff;
cout << "Zbuffer initialized" << endl;
// no need to fill ftot
return true;
}
@ -1690,30 +1688,41 @@ bool yafrayPluginRender_t::writeWorld()
#include "RE_callbacks.h"
bool blenderYafrayOutput_t::putPixel(int x, int y,const yafray::color_t &c,
yafray::CFLOAT alpha,yafray::PFLOAT depth)
bool blenderYafrayOutput_t::putPixel(int x, int y, const yafray::color_t &c,
yafray::CFLOAT alpha, yafray::PFLOAT depth)
{
unsigned char* bpt = (unsigned char*)R.rectot + ((((R.recty-1)-y)*R.rectx)<<2);
int temp=(int)(c.R*255.0+0.5);
if(temp>255) temp=255;
bpt[4*x]=temp;
temp=(int)(c.G*255.0+0.5);
if(temp>255) temp=255;
bpt[4*x+1]=temp;
temp=(int)(c.B*255.0+0.5);
if(temp>255) temp=255;
bpt[4*x+2]=temp;
temp=(int)(alpha*255.0+0.5);
if(temp>255) temp=255;
bpt[4*x+3]=temp;
unsigned int px = ((R.recty-1)-y)*R.rectx;
unsigned char* bpt = (unsigned char*)R.rectot + (px<<2);
int x4 = x<<2;
int temp = (int)(c.R*255.f+0.5f);
if (temp>255) temp=255;
bpt[x4] = temp;
temp=(int)(c.G*255.f+0.5f);
if (temp>255) temp=255;
bpt[x4+1] = temp;
temp=(int)(c.B*255.f+0.5f);
if (temp>255) temp=255;
bpt[x4+2] = temp;
temp=(int)(alpha*255.f+0.5f);
if (temp>255) temp=255;
bpt[x4+3] = temp;
// float buffer
if ((R.r.mode & R_FBUF) && R.rectftot) {
float* fpt = R.rectftot + (px<<2);
fpt[x4] = c.R;
fpt[x4+1] = c.G;
fpt[x4+2] = c.B;
fpt[x4+3] = alpha;
}
// depth values
unsigned int* zbuf = R.rectz + ((R.recty-1)-y)*R.rectx;
unsigned int* zbuf = R.rectz + px;
depth -= R.near;
float mz = R.far - R.near;
if (depth<0) depth=0; else if (depth>mz) depth=mz;
if (mz!=0.f) mz = 1.f/mz;
zbuf[x] = (unsigned int)(depth*mz*2147483647.f);
if (mz!=0.f) mz = 2147483647.f/mz;
zbuf[x] = (unsigned int)(depth*mz);
out++;
if(out==4096)