style cleanup

This commit is contained in:
Campbell Barton 2012-06-16 16:57:16 +00:00
parent cf6aefcce6
commit 42d0e34fac
3 changed files with 402 additions and 403 deletions

@ -64,15 +64,17 @@ static RenderEngineType internal_render_type = {
NULL, NULL,
"BLENDER_RENDER", N_("Blender Render"), RE_INTERNAL,
NULL, NULL, NULL, NULL,
{NULL, NULL, NULL}};
{NULL, NULL, NULL}
};
#ifdef WITH_GAMEENGINE
static RenderEngineType internal_game_type = {
NULL, NULL,
"BLENDER_GAME", N_("Blender Game"), RE_INTERNAL|RE_GAME,
"BLENDER_GAME", N_("Blender Game"), RE_INTERNAL | RE_GAME,
NULL, NULL, NULL, NULL,
{NULL, NULL, NULL}};
{NULL, NULL, NULL}
};
#endif
@ -90,8 +92,8 @@ void RE_engines_exit(void)
{
RenderEngineType *type, *next;
for (type=R_engines.first; type; type=next) {
next= type->next;
for (type = R_engines.first; type; type = next) {
next = type->next;
BLI_remlink(&R_engines, type);
@ -108,16 +110,16 @@ RenderEngineType *RE_engines_find(const char *idname)
{
RenderEngineType *type;
type= BLI_findstring(&R_engines, idname, offsetof(RenderEngineType, idname));
type = BLI_findstring(&R_engines, idname, offsetof(RenderEngineType, idname));
if (!type)
type= &internal_render_type;
type = &internal_render_type;
return type;
}
int RE_engine_is_external(Render *re)
{
RenderEngineType *type= RE_engines_find(re->r.engine);
RenderEngineType *type = RE_engines_find(re->r.engine);
return (type && type->render);
}
@ -126,7 +128,7 @@ int RE_engine_is_external(Render *re)
RenderEngine *RE_engine_create(RenderEngineType *type)
{
RenderEngine *engine = MEM_callocN(sizeof(RenderEngine), "RenderEngine");
engine->type= type;
engine->type = type;
return engine;
}
@ -149,7 +151,7 @@ void RE_engine_free(RenderEngine *engine)
RenderResult *RE_engine_begin_result(RenderEngine *engine, int x, int y, int w, int h)
{
Render *re= engine->re;
Render *re = engine->re;
RenderResult *result;
rcti disprect;
@ -160,17 +162,17 @@ RenderResult *RE_engine_begin_result(RenderEngine *engine, int x, int y, int w,
CLAMP(h, 0, re->result->recty);
if (x + w > re->result->rectx)
w= re->result->rectx - x;
w = re->result->rectx - x;
if (y + h > re->result->recty)
h= re->result->recty - y;
h = re->result->recty - y;
/* allocate a render result */
disprect.xmin = x;
disprect.xmax = x+w;
disprect.xmax = x + w;
disprect.ymin = y;
disprect.ymax = y+h;
disprect.ymax = y + h;
result= render_result_new(re, &disprect, 0, RR_USE_MEM);
result = render_result_new(re, &disprect, 0, RR_USE_MEM);
BLI_addtail(&engine->fullresult, result);
result->tilerect.xmin += re->disprect.xmin;
@ -183,17 +185,17 @@ RenderResult *RE_engine_begin_result(RenderEngine *engine, int x, int y, int w,
void RE_engine_update_result(RenderEngine *engine, RenderResult *result)
{
Render *re= engine->re;
Render *re = engine->re;
if (result) {
result->renlay= result->layers.first; // weak, draws first layer always
result->renlay = result->layers.first; // weak, draws first layer always
re->display_draw(re->ddh, result, NULL);
}
}
void RE_engine_end_result(RenderEngine *engine, RenderResult *result)
{
Render *re= engine->re;
Render *re = engine->re;
if (!result)
return;
@ -204,7 +206,7 @@ void RE_engine_end_result(RenderEngine *engine, RenderResult *result)
/* draw */
if (!re->test_break(re->tbh)) {
result->renlay= result->layers.first; // weak, draws first layer always
result->renlay = result->layers.first; // weak, draws first layer always
re->display_draw(re->ddh, result, NULL);
}
@ -216,7 +218,7 @@ void RE_engine_end_result(RenderEngine *engine, RenderResult *result)
int RE_engine_test_break(RenderEngine *engine)
{
Render *re= engine->re;
Render *re = engine->re;
if (re)
return re->test_break(re->tbh);
@ -228,34 +230,34 @@ int RE_engine_test_break(RenderEngine *engine)
void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char *info)
{
Render *re= engine->re;
Render *re = engine->re;
/* stats draw callback */
if (re) {
re->i.statstr= stats;
re->i.infostr= info;
re->i.statstr = stats;
re->i.infostr = info;
re->stats_draw(re->sdh, &re->i);
re->i.infostr= NULL;
re->i.statstr= NULL;
re->i.infostr = NULL;
re->i.statstr = NULL;
}
/* set engine text */
if (engine->text) {
MEM_freeN(engine->text);
engine->text= NULL;
engine->text = NULL;
}
if (stats && stats[0] && info && info[0])
engine->text= BLI_sprintfN("%s | %s", stats, info);
engine->text = BLI_sprintfN("%s | %s", stats, info);
else if (info && info[0])
engine->text= BLI_strdup(info);
engine->text = BLI_strdup(info);
else if (stats && stats[0])
engine->text= BLI_strdup(stats);
engine->text = BLI_strdup(stats);
}
void RE_engine_update_progress(RenderEngine *engine, float progress)
{
Render *re= engine->re;
Render *re = engine->re;
if (re) {
CLAMP(progress, 0.0f, 1.0f);
@ -272,7 +274,7 @@ void RE_engine_report(RenderEngine *engine, int type, const char *msg)
int RE_engine_render(Render *re, int do_all)
{
RenderEngineType *type= RE_engines_find(re->r.engine);
RenderEngineType *type = RE_engines_find(re->r.engine);
RenderEngine *engine;
/* verify if we can render */
@ -287,24 +289,24 @@ int RE_engine_render(Render *re, int do_all)
/* create render result */
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
if (re->result==NULL || !(re->r.scemode & R_PREVIEWBUTS)) {
if (re->result == NULL || !(re->r.scemode & R_PREVIEWBUTS)) {
if (re->result)
render_result_free(re->result);
re->result= render_result_new(re, &re->disprect, 0, 0);
re->result = render_result_new(re, &re->disprect, 0, 0);
}
BLI_rw_mutex_unlock(&re->resultmutex);
if (re->result==NULL)
if (re->result == NULL)
return 1;
/* set render info */
re->i.cfra= re->scene->r.cfra;
BLI_strncpy(re->i.scenename, re->scene->id.name+2, sizeof(re->i.scenename));
re->i.totface=re->i.totvert=re->i.totstrand=re->i.totlamp=re->i.tothalo= 0;
re->i.cfra = re->scene->r.cfra;
BLI_strncpy(re->i.scenename, re->scene->id.name + 2, sizeof(re->i.scenename));
re->i.totface = re->i.totvert = re->i.totstrand = re->i.totlamp = re->i.tothalo = 0;
/* render */
engine = RE_engine_create(type);
engine->re= re;
engine->re = re;
if (re->flag & R_ANIMATION)
engine->flag |= RE_ENGINE_ANIMATION;
@ -312,7 +314,7 @@ int RE_engine_render(Render *re, int do_all)
engine->flag |= RE_ENGINE_PREVIEW;
engine->camera_override = re->camera_override;
if ((re->r.scemode & (R_NO_FRAME_UPDATE|R_PREVIEWBUTS))==0)
if ((re->r.scemode & (R_NO_FRAME_UPDATE | R_PREVIEWBUTS)) == 0)
BKE_scene_update_for_newframe(re->main, re->scene, re->lay);
if (type->update)

@ -87,12 +87,12 @@
static void init_render_jit(Render *re)
{
static float jit[32][2]; /* simple caching */
static float mblur_jit[32][2]; /* simple caching */
static int lastjit= 0;
static int last_mblur_jit= 0;
static float jit[32][2]; /* simple caching */
static float mblur_jit[32][2]; /* simple caching */
static int lastjit = 0;
static int last_mblur_jit = 0;
if (lastjit!=re->r.osa || last_mblur_jit != re->r.mblur_samples) {
if (lastjit != re->r.osa || last_mblur_jit != re->r.mblur_samples) {
memset(jit, 0, sizeof(jit));
BLI_jitter_init(jit[0], re->r.osa);
@ -100,10 +100,10 @@ static void init_render_jit(Render *re)
BLI_jitter_init(mblur_jit[0], re->r.mblur_samples);
}
lastjit= re->r.osa;
lastjit = re->r.osa;
memcpy(re->jit, jit, sizeof(jit));
last_mblur_jit= re->r.mblur_samples;
last_mblur_jit = re->r.mblur_samples;
memcpy(re->mblur_jit, mblur_jit, sizeof(mblur_jit));
}
@ -113,135 +113,135 @@ static void init_render_jit(Render *re)
static float filt_quadratic(float x)
{
if (x < 0.0f) x = -x;
if (x < 0.5f) return 0.75f-(x*x);
if (x < 1.5f) return 0.50f*(x-1.5f)*(x-1.5f);
if (x < 0.5f) return 0.75f - (x * x);
if (x < 1.5f) return 0.50f * (x - 1.5f) * (x - 1.5f);
return 0.0f;
}
static float filt_cubic(float x)
{
float x2= x*x;
float x2 = x * x;
if (x < 0.0f) x = -x;
if (x < 1.0f) return 0.5f*x*x2 - x2 + 2.0f/3.0f;
if (x < 2.0f) return (2.0f-x)*(2.0f-x)*(2.0f-x)/6.0f;
if (x < 1.0f) return 0.5f * x * x2 - x2 + 2.0f / 3.0f;
if (x < 2.0f) return (2.0f - x) * (2.0f - x) * (2.0f - x) / 6.0f;
return 0.0f;
}
static float filt_catrom(float x)
{
float x2= x*x;
float x2 = x * x;
if (x < 0.0f) x = -x;
if (x < 1.0f) return 1.5f*x2*x - 2.5f*x2 + 1.0f;
if (x < 2.0f) return -0.5f*x2*x + 2.5f*x2 - 4.0f*x + 2.0f;
if (x < 1.0f) return 1.5f * x2 * x - 2.5f * x2 + 1.0f;
if (x < 2.0f) return -0.5f * x2 * x + 2.5f * x2 - 4.0f * x + 2.0f;
return 0.0f;
}
static float filt_mitchell(float x) /* Mitchell & Netravali's two-param cubic */
static float filt_mitchell(float x) /* Mitchell & Netravali's two-param cubic */
{
float b = 1.0f/3.0f, c = 1.0f/3.0f;
float p0 = ( 6.0f - 2.0f*b ) / 6.0f;
float p2 = (-18.0f + 12.0f*b + 6.0f*c) / 6.0f;
float p3 = ( 12.0f - 9.0f*b - 6.0f*c) / 6.0f;
float q0 = ( 8.0f*b + 24.0f*c) / 6.0f;
float q1 = ( - 12.0f *b - 48.0f*c) / 6.0f;
float q2 = ( 6.0f *b + 30.0f*c) / 6.0f;
float q3 = ( - b - 6.0f*c) / 6.0f;
float b = 1.0f / 3.0f, c = 1.0f / 3.0f;
float p0 = ( 6.0f - 2.0f * b) / 6.0f;
float p2 = (-18.0f + 12.0f * b + 6.0f * c) / 6.0f;
float p3 = ( 12.0f - 9.0f * b - 6.0f * c) / 6.0f;
float q0 = ( 8.0f * b + 24.0f * c) / 6.0f;
float q1 = ( -12.0f * b - 48.0f * c) / 6.0f;
float q2 = ( 6.0f * b + 30.0f * c) / 6.0f;
float q3 = ( -b - 6.0f * c) / 6.0f;
if (x<-2.0f) return 0.0f;
if (x<-1.0f) return (q0-x*(q1-x*(q2-x*q3)));
if (x< 0.0f) return (p0+x*x*(p2-x*p3));
if (x< 1.0f) return (p0+x*x*(p2+x*p3));
if (x< 2.0f) return (q0+x*(q1+x*(q2+x*q3)));
if (x < -2.0f) return 0.0f;
if (x < -1.0f) return (q0 - x * (q1 - x * (q2 - x * q3)));
if (x < 0.0f) return (p0 + x * x * (p2 - x * p3));
if (x < 1.0f) return (p0 + x * x * (p2 + x * p3));
if (x < 2.0f) return (q0 + x * (q1 + x * (q2 + x * q3)));
return 0.0f;
}
/* x ranges from -1 to 1 */
float RE_filter_value(int type, float x)
{
float gaussfac= 1.6f;
float gaussfac = 1.6f;
x= ABS(x);
x = ABS(x);
switch (type) {
case R_FILTER_BOX:
if (x>1.0f) return 0.0f;
if (x > 1.0f) return 0.0f;
return 1.0f;
case R_FILTER_TENT:
if (x>1.0f) return 0.0f;
return 1.0f-x;
if (x > 1.0f) return 0.0f;
return 1.0f - x;
case R_FILTER_GAUSS:
x*= gaussfac;
return (1.0f/expf(x*x) - 1.0f/expf(gaussfac*gaussfac*2.25f));
x *= gaussfac;
return (1.0f / expf(x * x) - 1.0f / expf(gaussfac * gaussfac * 2.25f));
case R_FILTER_MITCH:
return filt_mitchell(x*gaussfac);
return filt_mitchell(x * gaussfac);
case R_FILTER_QUAD:
return filt_quadratic(x*gaussfac);
return filt_quadratic(x * gaussfac);
case R_FILTER_CUBIC:
return filt_cubic(x*gaussfac);
return filt_cubic(x * gaussfac);
case R_FILTER_CATROM:
return filt_catrom(x*gaussfac);
return filt_catrom(x * gaussfac);
}
return 0.0f;
}
static float calc_weight(Render *re, float *weight, int i, int j)
{
float x, y, dist, totw= 0.0;
float x, y, dist, totw = 0.0;
int a;
for (a=0; a<re->osa; a++) {
x= re->jit[a][0] + i;
y= re->jit[a][1] + j;
dist= sqrt(x*x+y*y);
for (a = 0; a < re->osa; a++) {
x = re->jit[a][0] + i;
y = re->jit[a][1] + j;
dist = sqrt(x * x + y * y);
weight[a]= 0.0;
weight[a] = 0.0;
/* Weighting choices */
switch (re->r.filtertype) {
case R_FILTER_BOX:
if (i==0 && j==0) weight[a]= 1.0;
break;
case R_FILTER_BOX:
if (i == 0 && j == 0) weight[a] = 1.0;
break;
case R_FILTER_TENT:
if (dist < re->r.gauss)
weight[a]= re->r.gauss - dist;
break;
case R_FILTER_TENT:
if (dist < re->r.gauss)
weight[a] = re->r.gauss - dist;
break;
case R_FILTER_GAUSS:
x = dist*re->r.gauss;
weight[a]= (1.0f/expf(x*x) - 1.0f/expf(re->r.gauss*re->r.gauss*2.25f));
break;
case R_FILTER_GAUSS:
x = dist * re->r.gauss;
weight[a] = (1.0f / expf(x * x) - 1.0f / expf(re->r.gauss * re->r.gauss * 2.25f));
break;
case R_FILTER_MITCH:
weight[a]= filt_mitchell(dist*re->r.gauss);
break;
case R_FILTER_MITCH:
weight[a] = filt_mitchell(dist * re->r.gauss);
break;
case R_FILTER_QUAD:
weight[a]= filt_quadratic(dist*re->r.gauss);
break;
case R_FILTER_QUAD:
weight[a] = filt_quadratic(dist * re->r.gauss);
break;
case R_FILTER_CUBIC:
weight[a]= filt_cubic(dist*re->r.gauss);
break;
case R_FILTER_CUBIC:
weight[a] = filt_cubic(dist * re->r.gauss);
break;
case R_FILTER_CATROM:
weight[a]= filt_catrom(dist*re->r.gauss);
break;
case R_FILTER_CATROM:
weight[a] = filt_catrom(dist * re->r.gauss);
break;
}
totw+= weight[a];
totw += weight[a];
}
return totw;
@ -252,21 +252,21 @@ void free_sample_tables(Render *re)
int a;
if (re->samples) {
for (a=0; a<9; a++) {
for (a = 0; a < 9; a++) {
MEM_freeN(re->samples->fmask1[a]);
MEM_freeN(re->samples->fmask2[a]);
}
MEM_freeN(re->samples->centmask);
MEM_freeN(re->samples);
re->samples= NULL;
re->samples = NULL;
}
}
/* based on settings in render, it makes the lookup tables */
void make_sample_tables(Render *re)
{
static int firsttime= 1;
static int firsttime = 1;
SampleTables *st;
float flweight[32];
float weight[32], totw, val, *fpx1, *fpx2, *fpy1, *fpy2, *m3, *m4;
@ -274,27 +274,27 @@ void make_sample_tables(Render *re)
/* optimization tables, only once */
if (firsttime) {
firsttime= 0;
firsttime = 0;
}
free_sample_tables(re);
init_render_jit(re); /* needed for mblur too */
init_render_jit(re); /* needed for mblur too */
if (re->osa==0) {
if (re->osa == 0) {
/* just prevents cpu cycles for larger render and copying */
re->r.filtertype= 0;
re->r.filtertype = 0;
return;
}
st= re->samples= MEM_callocN(sizeof(SampleTables), "sample tables");
st = re->samples = MEM_callocN(sizeof(SampleTables), "sample tables");
for (a=0; a<9;a++) {
st->fmask1[a]= MEM_callocN(256*sizeof(float), "initfilt");
st->fmask2[a]= MEM_callocN(256*sizeof(float), "initfilt");
for (a = 0; a < 9; a++) {
st->fmask1[a] = MEM_callocN(256 * sizeof(float), "initfilt");
st->fmask2[a] = MEM_callocN(256 * sizeof(float), "initfilt");
}
for (a=0; a<256; a++) {
st->cmask[a]= 0;
for (a = 0; a < 256; a++) {
st->cmask[a] = 0;
if (a & 1) st->cmask[a]++;
if (a & 2) st->cmask[a]++;
if (a & 4) st->cmask[a]++;
@ -305,64 +305,64 @@ void make_sample_tables(Render *re)
if (a & 128) st->cmask[a]++;
}
st->centmask= MEM_mallocN((1<<re->osa), "Initfilt3");
st->centmask = MEM_mallocN((1 << re->osa), "Initfilt3");
for (a=0; a<16; a++) {
st->centLut[a]= -0.45f+((float)a)/16.0f;
for (a = 0; a < 16; a++) {
st->centLut[a] = -0.45f + ((float)a) / 16.0f;
}
/* calculate totw */
totw= 0.0;
for (j= -1; j<2; j++) {
for (i= -1; i<2; i++) {
totw+= calc_weight(re, weight, i, j);
totw = 0.0;
for (j = -1; j < 2; j++) {
for (i = -1; i < 2; i++) {
totw += calc_weight(re, weight, i, j);
}
}
for (j= -1; j<2; j++) {
for (i= -1; i<2; i++) {
for (j = -1; j < 2; j++) {
for (i = -1; i < 2; i++) {
/* calculate using jit, with offset the weights */
memset(weight, 0, sizeof(weight));
calc_weight(re, weight, i, j);
for (a=0; a<16; a++) flweight[a]= weight[a]*(1.0f/totw);
for (a = 0; a < 16; a++) flweight[a] = weight[a] * (1.0f / totw);
m3= st->fmask1[ 3*(j+1)+i+1 ];
m4= st->fmask2[ 3*(j+1)+i+1 ];
m3 = st->fmask1[3 * (j + 1) + i + 1];
m4 = st->fmask2[3 * (j + 1) + i + 1];
for (a=0; a<256; a++) {
for (a = 0; a < 256; a++) {
if (a & 1) {
m3[a]+= flweight[0];
m4[a]+= flweight[8];
m3[a] += flweight[0];
m4[a] += flweight[8];
}
if (a & 2) {
m3[a]+= flweight[1];
m4[a]+= flweight[9];
m3[a] += flweight[1];
m4[a] += flweight[9];
}
if (a & 4) {
m3[a]+= flweight[2];
m4[a]+= flweight[10];
m3[a] += flweight[2];
m4[a] += flweight[10];
}
if (a & 8) {
m3[a]+= flweight[3];
m4[a]+= flweight[11];
m3[a] += flweight[3];
m4[a] += flweight[11];
}
if (a & 16) {
m3[a]+= flweight[4];
m4[a]+= flweight[12];
m3[a] += flweight[4];
m4[a] += flweight[12];
}
if (a & 32) {
m3[a]+= flweight[5];
m4[a]+= flweight[13];
m3[a] += flweight[5];
m4[a] += flweight[13];
}
if (a & 64) {
m3[a]+= flweight[6];
m4[a]+= flweight[14];
m3[a] += flweight[6];
m4[a] += flweight[14];
}
if (a & 128) {
m3[a]+= flweight[7];
m4[a]+= flweight[15];
m3[a] += flweight[7];
m4[a] += flweight[15];
}
}
}
@ -370,71 +370,71 @@ void make_sample_tables(Render *re)
/* centmask: the correct subpixel offset per mask */
fpx1= MEM_mallocN(256*sizeof(float), "initgauss4");
fpx2= MEM_mallocN(256*sizeof(float), "initgauss4");
fpy1= MEM_mallocN(256*sizeof(float), "initgauss4");
fpy2= MEM_mallocN(256*sizeof(float), "initgauss4");
for (a=0; a<256; a++) {
fpx1[a]= fpx2[a]= 0.0;
fpy1[a]= fpy2[a]= 0.0;
fpx1 = MEM_mallocN(256 * sizeof(float), "initgauss4");
fpx2 = MEM_mallocN(256 * sizeof(float), "initgauss4");
fpy1 = MEM_mallocN(256 * sizeof(float), "initgauss4");
fpy2 = MEM_mallocN(256 * sizeof(float), "initgauss4");
for (a = 0; a < 256; a++) {
fpx1[a] = fpx2[a] = 0.0;
fpy1[a] = fpy2[a] = 0.0;
if (a & 1) {
fpx1[a]+= re->jit[0][0];
fpy1[a]+= re->jit[0][1];
fpx2[a]+= re->jit[8][0];
fpy2[a]+= re->jit[8][1];
fpx1[a] += re->jit[0][0];
fpy1[a] += re->jit[0][1];
fpx2[a] += re->jit[8][0];
fpy2[a] += re->jit[8][1];
}
if (a & 2) {
fpx1[a]+= re->jit[1][0];
fpy1[a]+= re->jit[1][1];
fpx2[a]+= re->jit[9][0];
fpy2[a]+= re->jit[9][1];
fpx1[a] += re->jit[1][0];
fpy1[a] += re->jit[1][1];
fpx2[a] += re->jit[9][0];
fpy2[a] += re->jit[9][1];
}
if (a & 4) {
fpx1[a]+= re->jit[2][0];
fpy1[a]+= re->jit[2][1];
fpx2[a]+= re->jit[10][0];
fpy2[a]+= re->jit[10][1];
fpx1[a] += re->jit[2][0];
fpy1[a] += re->jit[2][1];
fpx2[a] += re->jit[10][0];
fpy2[a] += re->jit[10][1];
}
if (a & 8) {
fpx1[a]+= re->jit[3][0];
fpy1[a]+= re->jit[3][1];
fpx2[a]+= re->jit[11][0];
fpy2[a]+= re->jit[11][1];
fpx1[a] += re->jit[3][0];
fpy1[a] += re->jit[3][1];
fpx2[a] += re->jit[11][0];
fpy2[a] += re->jit[11][1];
}
if (a & 16) {
fpx1[a]+= re->jit[4][0];
fpy1[a]+= re->jit[4][1];
fpx2[a]+= re->jit[12][0];
fpy2[a]+= re->jit[12][1];
fpx1[a] += re->jit[4][0];
fpy1[a] += re->jit[4][1];
fpx2[a] += re->jit[12][0];
fpy2[a] += re->jit[12][1];
}
if (a & 32) {
fpx1[a]+= re->jit[5][0];
fpy1[a]+= re->jit[5][1];
fpx2[a]+= re->jit[13][0];
fpy2[a]+= re->jit[13][1];
fpx1[a] += re->jit[5][0];
fpy1[a] += re->jit[5][1];
fpx2[a] += re->jit[13][0];
fpy2[a] += re->jit[13][1];
}
if (a & 64) {
fpx1[a]+= re->jit[6][0];
fpy1[a]+= re->jit[6][1];
fpx2[a]+= re->jit[14][0];
fpy2[a]+= re->jit[14][1];
fpx1[a] += re->jit[6][0];
fpy1[a] += re->jit[6][1];
fpx2[a] += re->jit[14][0];
fpy2[a] += re->jit[14][1];
}
if (a & 128) {
fpx1[a]+= re->jit[7][0];
fpy1[a]+= re->jit[7][1];
fpx2[a]+= re->jit[15][0];
fpy2[a]+= re->jit[15][1];
fpx1[a] += re->jit[7][0];
fpy1[a] += re->jit[7][1];
fpx2[a] += re->jit[15][0];
fpy2[a] += re->jit[15][1];
}
}
for (a= (1<<re->osa)-1; a>0; a--) {
val= st->cmask[a & 255] + st->cmask[a>>8];
i= 8+(15.9f*(fpy1[a & 255]+fpy2[a>>8])/val);
for (a = (1 << re->osa) - 1; a > 0; a--) {
val = st->cmask[a & 255] + st->cmask[a >> 8];
i = 8 + (15.9f * (fpy1[a & 255] + fpy2[a >> 8]) / val);
CLAMP(i, 0, 15);
j= 8+(15.9f*(fpx1[a & 255]+fpx2[a>>8])/val);
j = 8 + (15.9f * (fpx1[a & 255] + fpx2[a >> 8]) / val);
CLAMP(j, 0, 15);
i= j + (i<<4);
st->centmask[a]= i;
i = j + (i << 4);
st->centmask[a] = i;
}
MEM_freeN(fpx1);
@ -455,13 +455,13 @@ static void re_camera_params_get(Render *re, CameraParams *params, Object *cam_o
{
copy_m4_m4(re->winmat, params->winmat);
re->clipsta= params->clipsta;
re->clipend= params->clipend;
re->clipsta = params->clipsta;
re->clipend = params->clipend;
re->ycor= params->ycor;
re->viewdx= params->viewdx;
re->viewdy= params->viewdy;
re->viewplane= params->viewplane;
re->ycor = params->ycor;
re->viewdx = params->viewdx;
re->viewdy = params->viewdy;
re->viewplane = params->viewplane;
BKE_camera_object_mode(&re->r, cam_ob);
}
@ -474,12 +474,12 @@ void RE_SetEnvmapCamera(Render *re, Object *cam_ob, float viewscale, float clips
BKE_camera_params_init(&params);
BKE_camera_params_from_object(&params, cam_ob);
params.lens= 16.0f*viewscale;
params.sensor_x= 32.0f;
params.sensor_y= 32.0f;
params.lens = 16.0f * viewscale;
params.sensor_x = 32.0f;
params.sensor_y = 32.0f;
params.sensor_fit = CAMERA_SENSOR_FIT_AUTO;
params.clipsta= clipsta;
params.clipend= clipend;
params.clipsta = clipsta;
params.clipend = clipend;
/* compute matrix, viewplane, .. */
BKE_camera_params_compute_viewplane(&params, re->winx, re->winy, 1.0f, 1.0f);
@ -499,9 +499,9 @@ void RE_SetCamera(Render *re, Object *cam_ob)
BKE_camera_params_init(&params);
BKE_camera_params_from_object(&params, cam_ob);
params.use_fields= (re->r.mode & R_FIELDS);
params.field_second= (re->flag & R_SEC_FIELD);
params.field_odd= (re->r.mode & R_ODDFIELD);
params.use_fields = (re->r.mode & R_FIELDS);
params.field_second = (re->flag & R_SEC_FIELD);
params.field_odd = (re->r.mode & R_ODDFIELD);
/* compute matrix, viewplane, .. */
BKE_camera_params_compute_viewplane(&params, re->winx, re->winy, re->r.xasp, re->r.yasp);
@ -513,13 +513,13 @@ void RE_SetCamera(Render *re, Object *cam_ob)
void RE_SetPixelSize(Render *re, float pixsize)
{
re->viewdx= pixsize;
re->viewdy= re->ycor*pixsize;
re->viewdx = pixsize;
re->viewdy = re->ycor * pixsize;
}
void RE_GetCameraWindow(struct Render *re, struct Object *camera, int frame, float mat[][4])
{
re->r.cfra= frame;
re->r.cfra = frame;
RE_SetCamera(re, camera);
copy_m4_m4(mat, re->winmat);
}
@ -529,12 +529,12 @@ void RE_GetCameraWindow(struct Render *re, struct Object *camera, int frame, flo
void freeparts(Render *re)
{
RenderPart *part= re->parts.first;
RenderPart *part = re->parts.first;
while (part) {
if (part->rectp) MEM_freeN(part->rectp);
if (part->rectz) MEM_freeN(part->rectz);
part= part->next;
part = part->next;
}
BLI_freelistN(&re->parts);
}
@ -547,91 +547,91 @@ void initparts(Render *re)
freeparts(re);
/* this is render info for caller, is not reset when parts are freed! */
re->i.totpart= 0;
re->i.curpart= 0;
re->i.totpart = 0;
re->i.curpart = 0;
re->i.partsdone = FALSE;
/* just for readable code.. */
xminb= re->disprect.xmin;
yminb= re->disprect.ymin;
xmaxb= re->disprect.xmax;
ymaxb= re->disprect.ymax;
xminb = re->disprect.xmin;
yminb = re->disprect.ymin;
xmaxb = re->disprect.xmax;
ymaxb = re->disprect.ymax;
xparts= re->r.xparts;
yparts= re->r.yparts;
xparts = re->r.xparts;
yparts = re->r.yparts;
/* mininum part size, but for exr tile saving it was checked already */
if (!(re->r.scemode & (R_EXR_TILE_FILE|R_FULL_SAMPLE))) {
if (!(re->r.scemode & (R_EXR_TILE_FILE | R_FULL_SAMPLE))) {
if (re->r.mode & R_PANORAMA) {
if (ceil(re->rectx/(float)xparts) < 8)
xparts= 1 + re->rectx/8;
if (ceil(re->rectx / (float)xparts) < 8)
xparts = 1 + re->rectx / 8;
}
else
if (ceil(re->rectx/(float)xparts) < 64)
xparts= 1 + re->rectx/64;
if (ceil(re->rectx / (float)xparts) < 64)
xparts = 1 + re->rectx / 64;
if (ceil(re->recty/(float)yparts) < 64)
yparts= 1 + re->recty/64;
if (ceil(re->recty / (float)yparts) < 64)
yparts = 1 + re->recty / 64;
}
/* part size */
partx= ceil(re->rectx/(float)xparts);
party= ceil(re->recty/(float)yparts);
partx = ceil(re->rectx / (float)xparts);
party = ceil(re->recty / (float)yparts);
re->xparts= xparts;
re->yparts= yparts;
re->partx= partx;
re->party= party;
re->xparts = xparts;
re->yparts = yparts;
re->partx = partx;
re->party = party;
/* calculate rotation factor of 1 pixel */
if (re->r.mode & R_PANORAMA)
re->panophi= panorama_pixel_rot(re);
re->panophi = panorama_pixel_rot(re);
for (nr=0; nr<xparts*yparts; nr++) {
for (nr = 0; nr < xparts * yparts; nr++) {
rcti disprect;
int rectx, recty;
xd= (nr % xparts);
yd= (nr-xd)/xparts;
xd = (nr % xparts);
yd = (nr - xd) / xparts;
disprect.xmin = xminb+ xd*partx;
disprect.ymin = yminb+ yd*party;
disprect.xmin = xminb + xd * partx;
disprect.ymin = yminb + yd * party;
/* ensure we cover the entire picture, so last parts go to end */
if (xd<xparts-1) {
if (xd < xparts - 1) {
disprect.xmax = disprect.xmin + partx;
if (disprect.xmax > xmaxb)
disprect.xmax = xmaxb;
}
else disprect.xmax = xmaxb;
if (yd<yparts-1) {
if (yd < yparts - 1) {
disprect.ymax = disprect.ymin + party;
if (disprect.ymax > ymaxb)
disprect.ymax = ymaxb;
}
else disprect.ymax = ymaxb;
rectx= disprect.xmax - disprect.xmin;
recty= disprect.ymax - disprect.ymin;
rectx = disprect.xmax - disprect.xmin;
recty = disprect.ymax - disprect.ymin;
/* so, now can we add this part? */
if (rectx>0 && recty>0) {
RenderPart *pa= MEM_callocN(sizeof(RenderPart), "new part");
if (rectx > 0 && recty > 0) {
RenderPart *pa = MEM_callocN(sizeof(RenderPart), "new part");
/* Non-box filters need 2 pixels extra to work */
if ((re->r.filtertype || (re->r.mode & R_EDGE))) {
pa->crop= 2;
pa->crop = 2;
disprect.xmin -= pa->crop;
disprect.ymin -= pa->crop;
disprect.xmax += pa->crop;
disprect.ymax += pa->crop;
rectx+= 2*pa->crop;
recty+= 2*pa->crop;
rectx += 2 * pa->crop;
recty += 2 * pa->crop;
}
pa->disprect= disprect;
pa->rectx= rectx;
pa->recty= recty;
pa->disprect = disprect;
pa->rectx = rectx;
pa->recty = recty;
BLI_addtail(&re->parts, pa);
re->i.totpart++;

@ -78,12 +78,12 @@ void addAlphaOverFloat(float dest[4], const float source[4])
/* d = s + (1-alpha_s)d*/
float mul;
mul= 1.0f - source[3];
mul = 1.0f - source[3];
dest[0]= (mul*dest[0]) + source[0];
dest[1]= (mul*dest[1]) + source[1];
dest[2]= (mul*dest[2]) + source[2];
dest[3]= (mul*dest[3]) + source[3];
dest[0] = (mul * dest[0]) + source[0];
dest[1] = (mul * dest[1]) + source[1];
dest[2] = (mul * dest[2]) + source[2];
dest[3] = (mul * dest[3]) + source[3];
}
@ -94,12 +94,12 @@ void addAlphaUnderFloat(float dest[4], const float source[4])
{
float mul;
mul= 1.0f - dest[3];
mul = 1.0f - dest[3];
dest[0]+= (mul*source[0]);
dest[1]+= (mul*source[1]);
dest[2]+= (mul*source[2]);
dest[3]+= (mul*source[3]);
dest[0] += (mul * source[0]);
dest[1] += (mul * source[1]);
dest[2] += (mul * source[2]);
dest[3] += (mul * source[3]);
}
@ -111,36 +111,36 @@ void addalphaAddfacFloat(float dest[4], const float source[4], char addfac)
/* Addfac is a number between 0 and 1: rescale */
/* final target is to diminish the influence of dest when addfac rises */
m = 1.0f - ( source[3] * ((255 - addfac) / 255.0f));
m = 1.0f - (source[3] * ((255 - addfac) / 255.0f));
/* blend colors*/
c= (m * dest[0]) + source[0];
c = (m * dest[0]) + source[0];
#ifdef RE_FLOAT_COLOR_CLIPPING
if (c >= RE_FULL_COLOR_FLOAT) dest[0] = RE_FULL_COLOR_FLOAT;
else
#endif
dest[0]= c;
dest[0] = c;
c= (m * dest[1]) + source[1];
c = (m * dest[1]) + source[1];
#ifdef RE_FLOAT_COLOR_CLIPPING
if (c >= RE_FULL_COLOR_FLOAT) dest[1] = RE_FULL_COLOR_FLOAT;
else
#endif
dest[1]= c;
dest[1] = c;
c= (m * dest[2]) + source[2];
c = (m * dest[2]) + source[2];
#ifdef RE_FLOAT_COLOR_CLIPPING
if (c >= RE_FULL_COLOR_FLOAT) dest[2] = RE_FULL_COLOR_FLOAT;
else
#endif
dest[2]= c;
dest[2] = c;
c= (m * dest[3]) + source[3];
c = (m * dest[3]) + source[3];
#ifdef RE_ALPHA_CLIPPING
if (c >= RE_FULL_COLOR_FLOAT) dest[3] = RE_FULL_COLOR_FLOAT;
else
#endif
dest[3]= c;
dest[3] = c;
}
@ -151,81 +151,81 @@ void addalphaAddfacFloat(float dest[4], const float source[4], char addfac)
void add_filt_fmask(unsigned int mask, const float col[4], float *rowbuf, int row_w)
{
/* calc the value of mask */
float **fmask1= R.samples->fmask1, **fmask2=R.samples->fmask2;
float **fmask1 = R.samples->fmask1, **fmask2 = R.samples->fmask2;
float *rb1, *rb2, *rb3;
float val, r, g, b, al;
unsigned int a, maskand, maskshift;
int j;
r= col[0];
g= col[1];
b= col[2];
al= col[3];
rb2= rowbuf-4;
rb3= rb2-4*row_w;
rb1= rb2+4*row_w;
maskand= (mask & 255);
maskshift= (mask >>8);
for (j=2; j>=0; j--) {
a= j;
val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift);
if (val!=0.0f) {
rb1[0]+= val*r;
rb1[1]+= val*g;
rb1[2]+= val*b;
rb1[3]+= val*al;
r = col[0];
g = col[1];
b = col[2];
al = col[3];
rb2 = rowbuf - 4;
rb3 = rb2 - 4 * row_w;
rb1 = rb2 + 4 * row_w;
maskand = (mask & 255);
maskshift = (mask >> 8);
for (j = 2; j >= 0; j--) {
a = j;
val = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift);
if (val != 0.0f) {
rb1[0] += val * r;
rb1[1] += val * g;
rb1[2] += val * b;
rb1[3] += val * al;
}
a+=3;
a += 3;
val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift);
if (val!=0.0f) {
rb2[0]+= val*r;
rb2[1]+= val*g;
rb2[2]+= val*b;
rb2[3]+= val*al;
val = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift);
if (val != 0.0f) {
rb2[0] += val * r;
rb2[1] += val * g;
rb2[2] += val * b;
rb2[3] += val * al;
}
a+=3;
a += 3;
val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift);
if (val!=0.0f) {
rb3[0]+= val*r;
rb3[1]+= val*g;
rb3[2]+= val*b;
rb3[3]+= val*al;
val = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift);
if (val != 0.0f) {
rb3[0] += val * r;
rb3[1] += val * g;
rb3[2] += val * b;
rb3[3] += val * al;
}
rb1+= 4;
rb2+= 4;
rb3+= 4;
rb1 += 4;
rb2 += 4;
rb3 += 4;
}
}
void mask_array(unsigned int mask, float filt[][3])
{
float **fmask1= R.samples->fmask1, **fmask2=R.samples->fmask2;
unsigned int maskand= (mask & 255);
unsigned int maskshift= (mask >>8);
float **fmask1 = R.samples->fmask1, **fmask2 = R.samples->fmask2;
unsigned int maskand = (mask & 255);
unsigned int maskshift = (mask >> 8);
int a, j;
for (j=2; j>=0; j--) {
for (j = 2; j >= 0; j--) {
a= j;
a = j;
filt[2][2-j]= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift);
filt[2][2 - j] = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift);
a+=3;
a += 3;
filt[1][2-j]= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift);
filt[1][2 - j] = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift);
a+=3;
a += 3;
filt[0][2-j]= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift);
filt[0][2 - j] = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift);
}
}
@ -247,61 +247,61 @@ void add_filt_fmask_coord(float filt[][3], const float col[4], float *rowbuf, in
float *fpoin[3][3];
float val, r, g, b, al, lfilt[3][3];
r= col[0];
g= col[1];
b= col[2];
al= col[3];
r = col[0];
g = col[1];
b = col[2];
al = col[3];
memcpy(lfilt, filt, sizeof(lfilt));
fpoin[0][1]= rowbuf-4*row_w;
fpoin[1][1]= rowbuf;
fpoin[2][1]= rowbuf+4*row_w;
fpoin[0][0]= fpoin[0][1] - 4;
fpoin[1][0]= fpoin[1][1] - 4;
fpoin[2][0]= fpoin[2][1] - 4;
fpoin[0][2]= fpoin[0][1] + 4;
fpoin[1][2]= fpoin[1][1] + 4;
fpoin[2][2]= fpoin[2][1] + 4;
if (y==0) {
fpoin[0][0]= fpoin[1][0];
fpoin[0][1]= fpoin[1][1];
fpoin[0][2]= fpoin[1][2];
fpoin[0][1] = rowbuf - 4 * row_w;
fpoin[1][1] = rowbuf;
fpoin[2][1] = rowbuf + 4 * row_w;
fpoin[0][0] = fpoin[0][1] - 4;
fpoin[1][0] = fpoin[1][1] - 4;
fpoin[2][0] = fpoin[2][1] - 4;
fpoin[0][2] = fpoin[0][1] + 4;
fpoin[1][2] = fpoin[1][1] + 4;
fpoin[2][2] = fpoin[2][1] + 4;
if (y == 0) {
fpoin[0][0] = fpoin[1][0];
fpoin[0][1] = fpoin[1][1];
fpoin[0][2] = fpoin[1][2];
/* filter needs the opposite value yes! */
lfilt[0][0]= filt[2][0];
lfilt[0][1]= filt[2][1];
lfilt[0][2]= filt[2][2];
lfilt[0][0] = filt[2][0];
lfilt[0][1] = filt[2][1];
lfilt[0][2] = filt[2][2];
}
else if (y==col_h-1) {
fpoin[2][0]= fpoin[1][0];
fpoin[2][1]= fpoin[1][1];
fpoin[2][2]= fpoin[1][2];
lfilt[2][0]= filt[0][0];
lfilt[2][1]= filt[0][1];
lfilt[2][2]= filt[0][2];
else if (y == col_h - 1) {
fpoin[2][0] = fpoin[1][0];
fpoin[2][1] = fpoin[1][1];
fpoin[2][2] = fpoin[1][2];
lfilt[2][0] = filt[0][0];
lfilt[2][1] = filt[0][1];
lfilt[2][2] = filt[0][2];
}
if (x==0) {
fpoin[2][0]= fpoin[2][1];
fpoin[1][0]= fpoin[1][1];
fpoin[0][0]= fpoin[0][1];
lfilt[2][0]= filt[2][2];
lfilt[1][0]= filt[1][2];
lfilt[0][0]= filt[0][2];
if (x == 0) {
fpoin[2][0] = fpoin[2][1];
fpoin[1][0] = fpoin[1][1];
fpoin[0][0] = fpoin[0][1];
lfilt[2][0] = filt[2][2];
lfilt[1][0] = filt[1][2];
lfilt[0][0] = filt[0][2];
}
else if (x==row_w-1) {
fpoin[2][2]= fpoin[2][1];
fpoin[1][2]= fpoin[1][1];
fpoin[0][2]= fpoin[0][1];
lfilt[2][2]= filt[2][0];
lfilt[1][2]= filt[1][0];
lfilt[0][2]= filt[0][0];
else if (x == row_w - 1) {
fpoin[2][2] = fpoin[2][1];
fpoin[1][2] = fpoin[1][1];
fpoin[0][2] = fpoin[0][1];
lfilt[2][2] = filt[2][0];
lfilt[1][2] = filt[1][0];
lfilt[0][2] = filt[0][0];
}
@ -332,46 +332,46 @@ void add_filt_fmask_coord(float filt[][3], const float col[4], float *rowbuf, in
void add_filt_fmask_pixsize(unsigned int mask, float *in, float *rowbuf, int row_w, int pixsize)
{
/* calc the value of mask */
float **fmask1= R.samples->fmask1, **fmask2=R.samples->fmask2;
float **fmask1 = R.samples->fmask1, **fmask2 = R.samples->fmask2;
float *rb1, *rb2, *rb3;
float val;
unsigned int a, maskand, maskshift;
int i, j;
rb2= rowbuf-pixsize;
rb3= rb2-pixsize*row_w;
rb1= rb2+pixsize*row_w;
rb2 = rowbuf - pixsize;
rb3 = rb2 - pixsize * row_w;
rb1 = rb2 + pixsize * row_w;
maskand= (mask & 255);
maskshift= (mask >>8);
maskand = (mask & 255);
maskshift = (mask >> 8);
for (j=2; j>=0; j--) {
for (j = 2; j >= 0; j--) {
a= j;
a = j;
val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift);
if (val!=0.0f) {
for (i= 0; i<pixsize; i++)
rb1[i]+= val*in[i];
val = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift);
if (val != 0.0f) {
for (i = 0; i < pixsize; i++)
rb1[i] += val * in[i];
}
a+=3;
a += 3;
val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift);
if (val!=0.0f) {
for (i= 0; i<pixsize; i++)
rb2[i]+= val*in[i];
val = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift);
if (val != 0.0f) {
for (i = 0; i < pixsize; i++)
rb2[i] += val * in[i];
}
a+=3;
a += 3;
val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift);
if (val!=0.0f) {
for (i= 0; i<pixsize; i++)
rb3[i]+= val*in[i];
val = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift);
if (val != 0.0f) {
for (i = 0; i < pixsize; i++)
rb3[i] += val * in[i];
}
rb1+= pixsize;
rb2+= pixsize;
rb3+= pixsize;
rb1 += pixsize;
rb2 += pixsize;
rb3 += pixsize;
}
}
@ -380,7 +380,7 @@ void addalphaAddFloat(float dest[4], const float source[4])
{
/* Makes me wonder whether this is required... */
if ( dest[3] < RE_EMPTY_COLOR_FLOAT) {
if (dest[3] < RE_EMPTY_COLOR_FLOAT) {
dest[0] = source[0];
dest[1] = source[1];
dest[2] = source[2];
@ -389,15 +389,12 @@ void addalphaAddFloat(float dest[4], const float source[4])
}
/* no clipping! */
dest[0] = dest[0]+source[0];
dest[1] = dest[1]+source[1];
dest[2] = dest[2]+source[2];
dest[3] = dest[3]+source[3];
dest[0] = dest[0] + source[0];
dest[1] = dest[1] + source[1];
dest[2] = dest[2] + source[2];
dest[3] = dest[3] + source[3];
}
/* ---------------------------------------------------------------------------- */
/* eof pixelblending.c */