[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15838] branches/soc-2008-unclezeiv/source /blender/render/intern/source/lightcuts.c: Added support for the "Sphere" option.
Davide Vercelli
davide.vercelli at gmail.com
Mon Jul 28 13:30:04 CEST 2008
Revision: 15838
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15838
Author: unclezeiv
Date: 2008-07-28 13:30:04 +0200 (Mon, 28 Jul 2008)
Log Message:
-----------
Added support for the "Sphere" option.
This, though, should be useful only in the (rare?) case of a big number of user-placed Lamps having the "Sphere" option on.
Modified Paths:
--------------
branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c
Modified: branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c
===================================================================
--- branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c 2008-07-28 11:05:35 UTC (rev 15837)
+++ branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c 2008-07-28 11:30:04 UTC (rev 15838)
@@ -107,8 +107,9 @@
float cone_angle;
float luminance;
LampRen * lar;
- short falloff_type, pad;
+ short falloff_type, sphere;
float falloff_dist;
+ float sphere_dist;
#ifdef LIGHTCUTS_DEBUG
int dbg_parent;
#endif
@@ -267,6 +268,9 @@
/* worst case falloff type/dist for conservative error estimation */
dest->falloff_type= falloff_merge[one->falloff_type][two->falloff_type];
dest->falloff_dist= MAX2(one->falloff_dist, two->falloff_dist);
+
+ dest->sphere= one->sphere && two->sphere;
+ dest->sphere_dist= MAX2(one->sphere_dist, two->sphere_dist);
(*root)++;
}
@@ -401,6 +405,11 @@
}
break;
}
+
+ if(lar->mode & LA_SPHERE) {
+ clus->sphere = 1;
+ clus->sphere_dist = lar->dist;
+ }
clus++;
tree->free++;
@@ -1246,9 +1255,10 @@
{
float *min= clus->min;
float *max= clus->max;
- float nearest[3], len_sq;
+ float nearest[3], len_sq, len, sph= 1.0f;
+ short sphere = clus->sphere;
- if (clus->falloff_type == FALLOFF_CONST)
+ if (!sphere && clus->falloff_type == FALLOFF_CONST)
return 1.0f;
/* find the nearest point in the bounding box */
@@ -1257,17 +1267,25 @@
nearest[2]= CLAMPIS(pos[2], min[2], max[2]) - pos[2];
len_sq= VEC_LEN_SQ(nearest);
+ if (sphere || ELEM(clus->falloff_type, FALLOFF_LINEAR, FALLOFF_MIX))
+ len= sqrtf(len_sq);
+ if (sphere) {
+ sph= clus->sphere_dist - len;
+ if (sph < 0.0f)
+ return 0.0f;
+ sph= sph/clus->sphere_dist;
+ }
switch (clus->falloff_type) {
- /* FALLOFF_CONST already considered as early out */
case FALLOFF_LINEAR:
- return clus->falloff_dist / (clus->falloff_dist + sqrtf(len_sq));
+ return sph * clus->falloff_dist / (clus->falloff_dist + len);
case FALLOFF_QUAD:
- return clus->falloff_dist / (clus->falloff_dist + len_sq);
+ return sph * clus->falloff_dist / (clus->falloff_dist + len_sq);
case FALLOFF_MIX:
- return clus->falloff_dist / (clus->falloff_dist + (len_sq < 1.0f ? len_sq : sqrtf(len_sq)));
+ return sph * clus->falloff_dist / (clus->falloff_dist + (len_sq < 1.0f ? len_sq : len));
+ case FALLOFF_CONST:
default:
- return 1.0f;
+ return sph;
}
}
More information about the Bf-blender-cvs
mailing list