[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54056] trunk/blender/source/blender/ render/intern/source/bake.c: style cleanup: bake
Campbell Barton
ideasman42 at gmail.com
Thu Jan 24 00:28:23 CET 2013
Revision: 54056
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54056
Author: campbellbarton
Date: 2013-01-23 23:28:22 +0000 (Wed, 23 Jan 2013)
Log Message:
-----------
style cleanup: bake
Modified Paths:
--------------
trunk/blender/source/blender/render/intern/source/bake.c
Modified: trunk/blender/source/blender/render/intern/source/bake.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/bake.c 2013-01-23 21:55:11 UTC (rev 54055)
+++ trunk/blender/source/blender/render/intern/source/bake.c 2013-01-23 23:28:22 UTC (rev 54056)
@@ -87,7 +87,8 @@
Image *ima;
ImBuf *ibuf;
- int rectx, recty, quad, type, vdone, ready;
+ int rectx, recty, quad, type, vdone;
+ bool ready;
float dir[3];
Object *actob;
@@ -102,11 +103,11 @@
float *rect_float;
/* displacement buffer used for normalization with unknown maximal distance */
- int use_displacement_buffer;
+ bool use_displacement_buffer;
float *displacement_buffer;
float displacement_min, displacement_max;
- int use_mask;
+ bool use_mask;
char *rect_mask; /* bake pixel mask */
float dxco[3], dyco[3];
@@ -118,21 +119,21 @@
static void bake_set_shade_input(ObjectInstanceRen *obi, VlakRen *vlr, ShadeInput *shi, int quad, int UNUSED(isect), int x, int y, float u, float v)
{
- if (quad)
+ if (quad)
shade_input_set_triangle_i(shi, obi, vlr, 0, 2, 3);
else
shade_input_set_triangle_i(shi, obi, vlr, 0, 1, 2);
/* cache for shadow */
- shi->samplenr= R.shadowsamplenr[shi->thread]++;
+ shi->samplenr = R.shadowsamplenr[shi->thread]++;
- shi->mask= 0xFFFF; /* all samples */
-
- shi->u= -u;
- shi->v= -v;
- shi->xs= x;
- shi->ys= y;
-
+ shi->mask = 0xFFFF; /* all samples */
+
+ shi->u = -u;
+ shi->v = -v;
+ shi->xs = x;
+ shi->ys = y;
+
shade_input_set_uv(shi);
shade_input_set_normals(shi);
@@ -142,21 +143,21 @@
/* set up view vector to look right at the surface (note that the normal
* is negated in the renderer so it does not need to be done here) */
- shi->view[0]= shi->vn[0];
- shi->view[1]= shi->vn[1];
- shi->view[2]= shi->vn[2];
+ shi->view[0] = shi->vn[0];
+ shi->view[1] = shi->vn[1];
+ shi->view[2] = shi->vn[2];
}
static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(quad), int x, int y, float UNUSED(u), float UNUSED(v), float *tvn, float *ttang)
{
- BakeShade *bs= handle;
- ShadeSample *ssamp= &bs->ssamp;
+ BakeShade *bs = handle;
+ ShadeSample *ssamp = &bs->ssamp;
ShadeResult shr;
- VlakRen *vlr= shi->vlr;
-
+ VlakRen *vlr = shi->vlr;
+
shade_input_init_material(shi);
-
- if (bs->type==RE_BAKE_AO) {
+
+ if (bs->type == RE_BAKE_AO) {
ambient_occlusion(shi);
if (R.r.bake_flag & R_BAKE_NORMALIZE) {
@@ -168,24 +169,24 @@
}
}
else {
- if (bs->type==RE_BAKE_SHADOW) /* Why do shadows set the color anyhow?, ignore material color for baking */
+ if (bs->type == RE_BAKE_SHADOW) /* Why do shadows set the color anyhow?, ignore material color for baking */
shi->r = shi->g = shi->b = 1.0f;
shade_input_set_shade_texco(shi);
/* only do AO for a full bake (and obviously AO bakes)
* AO for light bakes is a leftover and might not be needed */
- if ( ELEM3(bs->type, RE_BAKE_ALL, RE_BAKE_AO, RE_BAKE_LIGHT))
+ if (ELEM3(bs->type, RE_BAKE_ALL, RE_BAKE_AO, RE_BAKE_LIGHT))
shade_samples_do_AO(ssamp);
if (shi->mat->nodetree && shi->mat->use_nodes) {
ntreeShaderExecTree(shi->mat->nodetree, shi, &shr);
- shi->mat= vlr->mat; /* shi->mat is being set in nodetree */
+ shi->mat = vlr->mat; /* shi->mat is being set in nodetree */
}
else
shade_material_loop(shi, &shr);
-
- if (bs->type==RE_BAKE_NORMALS) {
+
+ if (bs->type == RE_BAKE_NORMALS) {
float nor[3];
copy_v3_v3(nor, shi->vn);
@@ -214,7 +215,7 @@
mul_m3_v3(imat, nor);
}
else if (R.r.bake_normal_space == R_BAKE_SPACE_OBJECT)
- mul_mat3_m4_v3(ob->imat_ren, nor); /* ob->imat_ren includes viewinv! */
+ mul_mat3_m4_v3(ob->imat_ren, nor); /* ob->imat_ren includes viewinv! */
else if (R.r.bake_normal_space == R_BAKE_SPACE_WORLD)
mul_mat3_m4_v3(R.viewinv, nor);
@@ -226,66 +227,52 @@
* the normal used in the renderer points inward. It is generated
* this way in calc_vertexnormals(). Should this ever change
* this negate must be removed. */
- shr.combined[0]= (-nor[0])/2.0f + 0.5f;
- shr.combined[1]= nor[1]/2.0f + 0.5f;
- shr.combined[2]= nor[2]/2.0f + 0.5f;
+ shr.combined[0] = (-nor[0]) / 2.0f + 0.5f;
+ shr.combined[1] = nor[1] / 2.0f + 0.5f;
+ shr.combined[2] = nor[2] / 2.0f + 0.5f;
}
- else if (bs->type==RE_BAKE_TEXTURE) {
- shr.combined[0]= shi->r;
- shr.combined[1]= shi->g;
- shr.combined[2]= shi->b;
+ else if (bs->type == RE_BAKE_TEXTURE) {
+ copy_v3_v3(shr.combined, &shi->r);
shr.alpha = shi->alpha;
}
- else if (bs->type==RE_BAKE_SHADOW) {
+ else if (bs->type == RE_BAKE_SHADOW) {
copy_v3_v3(shr.combined, shr.shad);
shr.alpha = shi->alpha;
}
- else if (bs->type==RE_BAKE_SPEC_COLOR) {
- shr.combined[0]= shi->specr;
- shr.combined[1]= shi->specg;
- shr.combined[2]= shi->specb;
+ else if (bs->type == RE_BAKE_SPEC_COLOR) {
+ copy_v3_v3(shr.combined, &shi->specr);
shr.alpha = 1.0f;
}
- else if (bs->type==RE_BAKE_SPEC_INTENSITY) {
- shr.combined[0]=
- shr.combined[1]=
- shr.combined[2]= shi->spec;
+ else if (bs->type == RE_BAKE_SPEC_INTENSITY) {
+ copy_v3_fl(shr.combined, shi->spec);
shr.alpha = 1.0f;
}
- else if (bs->type==RE_BAKE_MIRROR_COLOR) {
- shr.combined[0]= shi->mirr;
- shr.combined[1]= shi->mirg;
- shr.combined[2]= shi->mirb;
+ else if (bs->type == RE_BAKE_MIRROR_COLOR) {
+ copy_v3_v3(shr.combined, &shi->mirr);
shr.alpha = 1.0f;
}
- else if (bs->type==RE_BAKE_MIRROR_INTENSITY) {
- shr.combined[0]=
- shr.combined[1]=
- shr.combined[2]= shi->ray_mirror;
+ else if (bs->type == RE_BAKE_MIRROR_INTENSITY) {
+ copy_v3_fl(shr.combined, shi->ray_mirror);
shr.alpha = 1.0f;
}
- else if (bs->type==RE_BAKE_ALPHA) {
- shr.combined[0]=
- shr.combined[1]=
- shr.combined[2]= shi->alpha;
+ else if (bs->type == RE_BAKE_ALPHA) {
+ copy_v3_fl(shr.combined, shi->alpha);
shr.alpha = 1.0f;
}
- else if (bs->type==RE_BAKE_EMIT) {
- shr.combined[0]=
- shr.combined[1]=
- shr.combined[2]= shi->emit;
+ else if (bs->type == RE_BAKE_EMIT) {
+ copy_v3_fl(shr.combined, shi->emit);
shr.alpha = 1.0f;
}
}
if (bs->rect_float && !bs->vcol) {
- float *col= bs->rect_float + 4*(bs->rectx*y + x);
+ float *col = bs->rect_float + 4 * (bs->rectx * y + x);
copy_v3_v3(col, shr.combined);
- if (bs->type==RE_BAKE_ALL || bs->type==RE_BAKE_TEXTURE) {
- col[3]= shr.alpha;
+ if (bs->type == RE_BAKE_ALL || bs->type == RE_BAKE_TEXTURE) {
+ col[3] = shr.alpha;
}
else {
- col[3]= 1.0;
+ col[3] = 1.0;
}
}
else {
@@ -311,10 +298,10 @@
}
if (ELEM(bs->type, RE_BAKE_ALL, RE_BAKE_TEXTURE)) {
- col[3]= FTOCHAR(shr.alpha);
+ col[3] = FTOCHAR(shr.alpha);
}
else {
- col[3]= 255;
+ col[3] = 255;
}
if (bs->vcol) {
@@ -325,25 +312,25 @@
bs->vcol->b = col[2];
}
else {
- unsigned char *imcol= (unsigned char *)(bs->rect + bs->rectx*y + x);
+ unsigned char *imcol = (unsigned char *)(bs->rect + bs->rectx * y + x);
copy_v4_v4_char((char *)imcol, (char *)col);
}
}
if (bs->rect_mask) {
- bs->rect_mask[bs->rectx*y + x] = FILTER_MASK_USED;
+ bs->rect_mask[bs->rectx * y + x] = FILTER_MASK_USED;
}
}
static void bake_displacement(void *handle, ShadeInput *UNUSED(shi), float dist, int x, int y)
{
- BakeShade *bs= handle;
+ BakeShade *bs = handle;
float disp;
-
+
if (R.r.bake_flag & R_BAKE_NORMALIZE) {
if (R.r.bake_maxdist)
- disp = (dist+R.r.bake_maxdist) / (R.r.bake_maxdist*2); /* alter the range from [-bake_maxdist, bake_maxdist] to [0, 1]*/
+ disp = (dist + R.r.bake_maxdist) / (R.r.bake_maxdist * 2); /* alter the range from [-bake_maxdist, bake_maxdist] to [0, 1]*/
else
disp = dist;
}
@@ -359,9 +346,9 @@
}
if (bs->rect_float && !bs->vcol) {
- float *col= bs->rect_float + 4*(bs->rectx*y + x);
+ float *col = bs->rect_float + 4 * (bs->rectx * y + x);
col[0] = col[1] = col[2] = disp;
- col[3]= 1.0f;
+ col[3] = 1.0f;
}
else {
/* Target is char (LDR). */
@@ -369,7 +356,7 @@
col[0] = col[1] = col[2] = FTOCHAR(disp);
col[3] = 255;
- if(bs->vcol) {
+ if (bs->vcol) {
/* Vertex color baking. Vcol has no useful alpha channel (it exists
* but is used only for vertex painting). */
bs->vcol->r = col[0];
@@ -377,25 +364,25 @@
bs->vcol->b = col[2];
}
else {
- char *imcol= (char *)(bs->rect + bs->rectx*y + x);
+ char *imcol = (char *)(bs->rect + bs->rectx * y + x);
copy_v4_v4_char((char *)imcol, (char *)col);
}
}
if (bs->rect_mask) {
- bs->rect_mask[bs->rectx*y + x] = FILTER_MASK_USED;
+ bs->rect_mask[bs->rectx * y + x] = FILTER_MASK_USED;
}
}
-static int bake_intersect_tree(RayObject* raytree, Isect* isect, float *start, float *dir, float sign, float *hitco, float *dist)
+static int bake_intersect_tree(RayObject *raytree, Isect *isect, float *start, float *dir, float sign, float *hitco, float *dist)
{
float maxdist;
int hit;
/* might be useful to make a user setting for maxsize*/
if (R.r.bake_maxdist > 0.0f)
- maxdist= R.r.bake_maxdist;
+ maxdist = R.r.bake_maxdist;
else
- maxdist= RE_RAYTRACE_MAXDIST + R.r.bake_biasdist;
+ maxdist = RE_RAYTRACE_MAXDIST + R.r.bake_biasdist;
/* 'dir' is always normalized */
madd_v3_v3v3fl(isect->start, start, dir, -R.r.bake_biasdist);
@@ -408,7 +395,7 @@
if (hit) {
madd_v3_v3v3fl(hitco, isect->start, isect->dir, isect->dist);
- *dist= isect->dist;
+ *dist = isect->dist;
}
return hit;
@@ -416,45 +403,45 @@
static void bake_set_vlr_dxyco(BakeShade *bs, float *uv1, float *uv2, float *uv3)
{
- VlakRen *vlr= bs->vlr;
+ VlakRen *vlr = bs->vlr;
float A, d1, d2, d3, *v1, *v2, *v3;
if (bs->quad) {
- v1= vlr->v1->co;
- v2= vlr->v3->co;
- v3= vlr->v4->co;
+ v1 = vlr->v1->co;
+ v2 = vlr->v3->co;
+ v3 = vlr->v4->co;
}
else {
- v1= vlr->v1->co;
- v2= vlr->v2->co;
- v3= vlr->v3->co;
+ v1 = vlr->v1->co;
+ v2 = vlr->v2->co;
+ v3 = vlr->v3->co;
}
/* formula derived from barycentric coordinates:
* (uvArea1*v1 + uvArea2*v2 + uvArea3*v3)/uvArea
* then taking u and v partial derivatives to get dxco and dyco */
- A= (uv2[0] - uv1[0])*(uv3[1] - uv1[1]) - (uv3[0] - uv1[0])*(uv2[1] - uv1[1]);
+ A = (uv2[0] - uv1[0]) * (uv3[1] - uv1[1]) - (uv3[0] - uv1[0]) * (uv2[1] - uv1[1]);
if (fabsf(A) > FLT_EPSILON) {
- A= 0.5f/A;
+ A = 0.5f / A;
- d1= uv2[1] - uv3[1];
- d2= uv3[1] - uv1[1];
- d3= uv1[1] - uv2[1];
- bs->dxco[0]= (v1[0]*d1 + v2[0]*d2 + v3[0]*d3)*A;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list