* Fix for a small bug where multiple scattering wasn't being enabled properly.
authorMatt Ebb <matt@mke3.net>
Thu, 26 Feb 2009 00:13:40 +0000 (00:13 +0000)
committerMatt Ebb <matt@mke3.net>
Thu, 26 Feb 2009 00:13:40 +0000 (00:13 +0000)
* Also a MSVC compile fix

source/blender/render/intern/include/volume_precache.h
source/blender/render/intern/source/volume_precache.c
source/blender/render/intern/source/volumetric.c

index 9d87a219c829f076510999374488a7a83334bd40..d8a94c2d560a092b2c7c374cafc9afae13ed3765 100644 (file)
@@ -29,5 +29,6 @@
 void volume_precache(Render *re);
 void free_volume_precache(Render *re);
 int point_inside_volume_objectinstance(ObjectInstanceRen *obi, float *co);
+int using_lightcache(Material *ma);
 
 #define VOL_MS_TIMESTEP        0.1f
\ No newline at end of file
index 4cdffc5ad3581cdb7492ac11fe74b34bd340b72a..ba5fae0f28449a1268d05d8c906193ccbc5f03a7 100644 (file)
@@ -49,6 +49,9 @@
 #include "volumetric.h"
 #include "volume_precache.h"
 
+#if defined( _MSC_VER ) && !defined( __cplusplus )
+# define inline __inline
+#endif // defined( _MSC_VER ) && !defined( __cplusplus )
 
 #include "BKE_global.h"
 
@@ -247,8 +250,7 @@ void multiple_scattering_diffusion(Render *re, float *cache, int res, Material *
        const float fac = ma->vol_ms_intensity;
        const float simframes = ma->vol_ms_steps;
        const int shade_type = ma->vol_shade_type;
-       const float dt = VOL_MS_TIMESTEP;
-
+       
        int i, j, k, m;
        int n = res;
        const int size = (n+2)*(n+2)*(n+2);
@@ -595,6 +597,12 @@ void vol_precache_objectinstance_threads(Render *re, ObjectInstanceRen *obi, Mat
        }
 }
 
+int using_lightcache(Material *ma)
+{
+       return (((ma->vol_shadeflag & MA_VOL_PRECACHESHADING) && (ma->vol_shade_type == MA_VOL_SHADE_SINGLE))
+               || (ELEM(ma->vol_shade_type, MA_VOL_SHADE_MULTIPLE, MA_VOL_SHADE_SINGLEPLUSMULTIPLE)));
+}
+
 /* loop through all objects (and their associated materials)
  * marked for pre-caching in convertblender.c, and pre-cache them */
 void volume_precache(Render *re)
@@ -606,7 +614,7 @@ void volume_precache(Render *re)
        if (re->r.scemode & R_PREVIEWBUTS) return;
 
        for(vo= re->volumes.first; vo; vo= vo->next) {
-               if (vo->ma->vol_shadeflag & MA_VOL_PRECACHESHADING) {
+               if (using_lightcache(vo->ma)) {
                        for(obi= re->instancetable.first; obi; obi= obi->next) {
                                if (obi->obr == vo->obr) {
                                        vol_precache_objectinstance_threads(re, obi, vo->ma, obi->obr->boundbox[0], obi->obr->boundbox[1]);
index c8361844e11cc82f04336a459a03ddfc63c415bf..01c4ac8fa74ba74ac6add06af823fd005fa15bd2 100644 (file)
@@ -514,9 +514,7 @@ static void volumeintegrate(struct ShadeInput *shi, float *col, float *co, float
                        
                        if (R.r.scemode & R_PREVIEWBUTS) {
                                vol_get_scattering(shi, scatter_col, step_mid, stepsize, density);
-                       } else if (((shi->mat->vol_shadeflag & MA_VOL_PRECACHESHADING) &&
-                               (shi->mat->vol_shade_type == MA_VOL_SHADE_SINGLE)) ||
-                               (ELEM(shi->mat->vol_shade_type, MA_VOL_SHADE_MULTIPLE, MA_VOL_SHADE_SINGLEPLUSMULTIPLE))) {
+                       } else if (using_lightcache(shi->mat)) {
                                vol_get_precached_scattering(shi, scatter_col, step_mid);
                        } else
                                vol_get_scattering(shi, scatter_col, step_mid, stepsize, density);