[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40519] trunk/blender/source/blender/ render/intern: edits to internal renderer - no functional changes.
Campbell Barton
ideasman42 at gmail.com
Sat Sep 24 16:34:25 CEST 2011
Revision: 40519
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40519
Author: campbellbarton
Date: 2011-09-24 14:34:24 +0000 (Sat, 24 Sep 2011)
Log Message:
-----------
edits to internal renderer - no functional changes.
- move some larger vars into a nested scope.
- replace memset with zero initializer.
- rempace VECCOPY macros with copy_v3v3
- change function args to give the float array length.
Modified Paths:
--------------
trunk/blender/source/blender/render/intern/include/rendercore.h
trunk/blender/source/blender/render/intern/include/shading.h
trunk/blender/source/blender/render/intern/source/convertblender.c
trunk/blender/source/blender/render/intern/source/envmap.c
trunk/blender/source/blender/render/intern/source/rayshade.c
trunk/blender/source/blender/render/intern/source/rendercore.c
trunk/blender/source/blender/render/intern/source/shadeinput.c
trunk/blender/source/blender/render/intern/source/shadeoutput.c
trunk/blender/source/blender/render/intern/source/strand.c
trunk/blender/source/blender/render/intern/source/zbuf.c
Modified: trunk/blender/source/blender/render/intern/include/rendercore.h
===================================================================
--- trunk/blender/source/blender/render/intern/include/rendercore.h 2011-09-24 12:13:13 UTC (rev 40518)
+++ trunk/blender/source/blender/render/intern/include/rendercore.h 2011-09-24 14:34:24 UTC (rev 40519)
@@ -76,12 +76,12 @@
void calc_view_vector(float *view, float x, float y);
-float mistfactor(float zcor, float *co); /* dist and height, return alpha */
+float mistfactor(float zcor, const float co[3]); /* dist and height, return alpha */
-void renderspothalo(struct ShadeInput *shi, float *col, float alpha);
+void renderspothalo(struct ShadeInput *shi, float col[4], float alpha);
void add_halo_flare(Render *re);
-void calc_renderco_zbuf(float co[3], float *view, int z);
+void calc_renderco_zbuf(float co[3], const float view[3], int z);
void calc_renderco_ortho(float co[3], float x, float y, int z);
int count_mask(unsigned short mask);
@@ -103,9 +103,9 @@
extern void makeraytree(Render *re);
struct RayObject* makeraytree_object(Render *re, ObjectInstanceRen *obi);
-extern void ray_shadow(ShadeInput *, LampRen *, float *);
-extern void ray_trace(ShadeInput *, ShadeResult *);
-extern void ray_ao(ShadeInput *, float *, float *);
+extern void ray_shadow(ShadeInput *shi, LampRen *lar, float shadfac[4]);
+extern void ray_trace(ShadeInput *shi, ShadeResult *);
+extern void ray_ao(ShadeInput *shi, float ao[3], float env[3]);
extern void init_jitter_plane(LampRen *lar);
extern void init_ao_sphere(struct World *wrld);
extern void init_render_qmcsampler(Render *re);
Modified: trunk/blender/source/blender/render/intern/include/shading.h
===================================================================
--- trunk/blender/source/blender/render/intern/include/shading.h 2011-09-24 12:13:13 UTC (rev 40518)
+++ trunk/blender/source/blender/render/intern/include/shading.h 2011-09-24 14:34:24 UTC (rev 40519)
@@ -96,8 +96,8 @@
void environment_lighting_apply(struct ShadeInput *shi, struct ShadeResult *shr);
ListBase *get_lights(struct ShadeInput *shi);
-float lamp_get_visibility(struct LampRen *lar, const float co[3], float *lv, float *dist);
-void lamp_get_shadow(struct LampRen *lar, ShadeInput *shi, float inp, float *shadfac, int do_real);
+float lamp_get_visibility(struct LampRen *lar, const float co[3], float lv[3], float *dist);
+void lamp_get_shadow(struct LampRen *lar, ShadeInput *shi, float inp, float shadfac[4], int do_real);
float fresnel_fac(float *view, float *vn, float fresnel, float fac);
Modified: trunk/blender/source/blender/render/intern/source/convertblender.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/convertblender.c 2011-09-24 12:13:13 UTC (rev 40518)
+++ trunk/blender/source/blender/render/intern/source/convertblender.c 2011-09-24 14:34:24 UTC (rev 40519)
@@ -5304,11 +5304,13 @@
static float *calculate_strandsurface_speedvectors(Render *re, ObjectInstanceRen *obi, StrandSurface *mesh)
{
- float winsq= (float)re->winx*(float)re->winy, winroot= sqrt(winsq), (*winspeed)[4]; /* int's can wrap on large images */
- float ho[4], prevho[4], nextho[4], winmat[4][4], vec[2];
- int a;
+ if(mesh->co && mesh->prevco && mesh->nextco) {
+ float winsq= (float)re->winx*(float)re->winy; /* int's can wrap on large images */
+ float winroot= sqrt(winsq);
+ float (*winspeed)[4];
+ float ho[4], prevho[4], nextho[4], winmat[4][4], vec[2];
+ int a;
- if(mesh->co && mesh->prevco && mesh->nextco) {
if(obi->flag & R_TRANSFORMED)
mul_m4_m4m4(winmat, obi->mat, re->winmat);
else
Modified: trunk/blender/source/blender/render/intern/source/envmap.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/envmap.c 2011-09-24 12:13:13 UTC (rev 40518)
+++ trunk/blender/source/blender/render/intern/source/envmap.c 2011-09-24 14:34:24 UTC (rev 40519)
@@ -689,9 +689,9 @@
env->ima= tex->ima;
if(env->ima && env->ima->ok) {
if(env->cube[1]==NULL) {
- ImBuf *ibuf= BKE_image_get_ibuf(env->ima, NULL);
- if(ibuf)
- envmap_split_ima(env, ibuf);
+ ImBuf *ibuf_ima= BKE_image_get_ibuf(env->ima, NULL);
+ if(ibuf_ima)
+ envmap_split_ima(env, ibuf_ima);
else
env->ok= 0;
}
Modified: trunk/blender/source/blender/render/intern/source/rayshade.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/rayshade.c 2011-09-24 12:13:13 UTC (rev 40518)
+++ trunk/blender/source/blender/render/intern/source/rayshade.c 2011-09-24 14:34:24 UTC (rev 40519)
@@ -334,7 +334,6 @@
for(obi=re->instancetable.first; obi; obi=obi->next)
if(is_raytraceable(re, obi))
{
- int v;
ObjectRen *obr = obi->obr;
obs++;
@@ -344,6 +343,7 @@
}
else
{
+ int v;
for(v=0;v<obr->totvlak;v++)
{
VlakRen *vlr = obr->vlaknodes[v>>8].vlak + (v&255);
@@ -539,7 +539,7 @@
VlakRen *vlr= (VlakRen*)is->hit.face;
/* set up view vector */
- VECCOPY(shi->view, is->dir);
+ copy_v3_v3(shi->view, is->dir);
/* render co */
shi->co[0]= is->start[0]+is->dist*(shi->view[0]);
@@ -594,16 +594,16 @@
}
/* raytrace likes to separate the spec color */
- VECSUB(shr->diff, shr->combined, shr->spec);
+ sub_v3_v3v3(shr->diff, shr->combined, shr->spec);
}
}
-static int refraction(float *refract, float *n, float *view, float index)
+static int refraction(float refract[3], const float n[3], const float view[3], float index)
{
float dot, fac;
- VECCOPY(refract, view);
+ copy_v3_v3(refract, view);
dot= view[0]*n[0] + view[1]*n[1] + view[2]*n[2];
@@ -626,26 +626,26 @@
return 1;
}
+static void reflection_simple(float ref[3], float n[3], const float view[3])
+{
+ const float f1= -2.0f * dot_v3v3(n, view);
+ madd_v3_v3v3fl(ref, view, n, f1);
+}
+
/* orn = original face normal */
-static void reflection(float *ref, float *n, float *view, float *orn)
+static void reflection(float ref[3], float n[3], const float view[3], const float orn[3])
{
float f1;
-
- f1= -2.0f*(n[0]*view[0]+ n[1]*view[1]+ n[2]*view[2]);
-
- ref[0]= (view[0]+f1*n[0]);
- ref[1]= (view[1]+f1*n[1]);
- ref[2]= (view[2]+f1*n[2]);
- if(orn) {
- /* test phong normals, then we should prevent vector going to the back */
- f1= ref[0]*orn[0]+ ref[1]*orn[1]+ ref[2]*orn[2];
- if(f1>0.0f) {
- f1+= .01f;
- ref[0]-= f1*orn[0];
- ref[1]-= f1*orn[1];
- ref[2]-= f1*orn[2];
- }
+ reflection_simple(ref, n, view);
+
+ /* test phong normals, then we should prevent vector going to the back */
+ f1= dot_v3v3(ref, orn);
+ if(f1>0.0f) {
+ f1+= 0.01f;
+ ref[0]-= f1*orn[0];
+ ref[1]-= f1*orn[1];
+ ref[2]-= f1*orn[2];
}
}
@@ -672,8 +672,7 @@
static float shade_by_transmission(Isect *is, ShadeInput *shi, ShadeResult *shr)
{
- float dx, dy, dz, d, p;
-
+ float d;
if (0 == (shi->mat->mode & MA_TRANSP))
return -1;
@@ -681,10 +680,12 @@
d= 1.0f;
}
else {
+ float p;
+
/* shi.co[] calculated by shade_ray() */
- dx= shi->co[0] - is->start[0];
- dy= shi->co[1] - is->start[1];
- dz= shi->co[2] - is->start[2];
+ const float dx= shi->co[0] - is->start[0];
+ const float dy= shi->co[1] - is->start[1];
+ const float dz= shi->co[2] - is->start[2];
d= sqrt(dx*dx+dy*dy+dz*dz);
if (d > shi->mat->tx_limit)
d= shi->mat->tx_limit;
@@ -701,13 +702,13 @@
return d;
}
-static void ray_fadeout_endcolor(float *col, ShadeInput *origshi, ShadeInput *shi, ShadeResult *shr, Isect *isec, float *vec)
+static void ray_fadeout_endcolor(float col[3], ShadeInput *origshi, ShadeInput *shi, ShadeResult *shr, Isect *isec, const float vec[3])
{
/* un-intersected rays get either rendered material color or sky color */
if (origshi->mat->fadeto_mir == MA_RAYMIR_FADETOMAT) {
- VECCOPY(col, shr->combined);
+ copy_v3_v3(col, shr->combined);
} else if (origshi->mat->fadeto_mir == MA_RAYMIR_FADETOSKY) {
- VECCOPY(shi->view, vec);
+ copy_v3_v3(shi->view, vec);
normalize_v3(shi->view);
shadeSkyView(col, isec->start, shi->view, NULL, shi->thread);
@@ -715,7 +716,7 @@
}
}
-static void ray_fadeout(Isect *is, ShadeInput *shi, float *col, float *blendcol, float dist_mir)
+static void ray_fadeout(Isect *is, ShadeInput *shi, float col[3], const float blendcol[3], float dist_mir)
{
/* if fading out, linear blend against fade color */
float blendfac;
@@ -729,14 +730,14 @@
/* the main recursive tracer itself
* note: 'col' must be initialized */
-static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, float *start, float *dir, float *col, ObjectInstanceRen *obi, VlakRen *vlr, int traflag)
+static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, const float start[3], const float dir[3], float col[4], ObjectInstanceRen *obi, VlakRen *vlr, int traflag)
{
ShadeInput shi= {0};
Isect isec;
float dist_mir = origshi->mat->dist_mir;
- VECCOPY(isec.start, start);
- VECCOPY(isec.dir, dir );
+ copy_v3_v3(isec.start, start);
+ copy_v3_v3(isec.dir, dir );
isec.dist = dist_mir > 0 ? dist_mir : RE_RAYTRACE_MAXDIST;
isec.mode= RE_RAY_MIRROR;
isec.check = RE_CHECK_VLR_RENDER;
@@ -752,8 +753,8 @@
float d= 1.0f;
/* for as long we don't have proper dx/dy transform for rays we copy over original */
- VECCOPY(shi.dxco, origshi->dxco);
- VECCOPY(shi.dyco, origshi->dyco);
+ copy_v3_v3(shi.dxco, origshi->dxco);
+ copy_v3_v3(shi.dyco, origshi->dyco);
shi.mask= origshi->mask;
shi.osatex= origshi->osatex;
@@ -845,7 +846,7 @@
float mircol[4];
float ref[3];
- reflection(ref, shi.vn, shi.view, NULL);
+ reflection_simple(ref, shi.vn, shi.view);
traceray(origshi, origshr, depth-1, shi.co, ref, mircol, shi.obi, shi.vlr, 0);
f1= 1.0f-f;
@@ -896,7 +897,7 @@
/* calc distributed planar energy */
-static void DP_energy(float *table, float *vec, int tot, float xsize, float ysize)
+static void DP_energy(float *table, float vec[2], int tot, float xsize, float ysize)
{
int x, y, a;
float *fp, force[3], result[3];
@@ -950,7 +951,7 @@
void init_jitter_plane(LampRen *lar)
{
float *fp;
- int x, iter=12, tot= lar->ray_totsamp;
+ int x, tot= lar->ray_totsamp;
/* test if already initialized */
if(lar->jitter) return;
@@ -962,7 +963,8 @@
/* if 1 sample, we leave table to be zero's */
if(tot>1) {
-
+ int iter=12;
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list